Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: xtensor stores #1001

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 20 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ find_package(span-lite CONFIG REQUIRED)
find_package(Eigen3 REQUIRED)
find_package(boost_mp11 CONFIG REQUIRED)
find_package(nod CONFIG REQUIRED)
find_package(xtl CONFIG REQUIRED)
find_package(xtensor CONFIG REQUIRED)
find_package(xtensor-io CONFIG REQUIRED)

# -----------------------------------------------------------------------
# Find HDF5 and get the path to the DLL libraries and put that into a
Expand Down Expand Up @@ -226,14 +229,17 @@ endif()

target_link_libraries(simplnx
PUBLIC
fmt::fmt
nlohmann_json::nlohmann_json
nonstd::expected-lite
nonstd::span-lite
Eigen3::Eigen
HDF5::HDF5
Boost::mp11
nod::nod
fmt::fmt
nlohmann_json::nlohmann_json
nonstd::expected-lite
nonstd::span-lite
Eigen3::Eigen
HDF5::HDF5
Boost::mp11
nod::nod
xtl
xtensor
xtensor-io
)

if(UNIX)
Expand Down Expand Up @@ -406,6 +412,8 @@ set(SIMPLNX_HDRS
${SIMPLNX_SOURCE_DIR}/DataStructure/Montage/GridTileIndex.hpp

${SIMPLNX_SOURCE_DIR}/DataStructure/AbstractDataStore.hpp
${SIMPLNX_SOURCE_DIR}/DataStructure/AbstractListStore.hpp
${SIMPLNX_SOURCE_DIR}/DataStructure/AbstractStringStore.hpp
${SIMPLNX_SOURCE_DIR}/DataStructure/AttributeMatrix.hpp
${SIMPLNX_SOURCE_DIR}/DataStructure/BaseGroup.hpp
${SIMPLNX_SOURCE_DIR}/DataStructure/DataArray.hpp
Expand All @@ -424,8 +432,10 @@ set(SIMPLNX_HDRS
${SIMPLNX_SOURCE_DIR}/DataStructure/LinkedPath.hpp
${SIMPLNX_SOURCE_DIR}/DataStructure/Metadata.hpp
${SIMPLNX_SOURCE_DIR}/DataStructure/NeighborList.hpp
${SIMPLNX_SOURCE_DIR}/DataStructure/ListStore.hpp
${SIMPLNX_SOURCE_DIR}/DataStructure/ScalarData.hpp
${SIMPLNX_SOURCE_DIR}/DataStructure/StringArray.hpp
${SIMPLNX_SOURCE_DIR}/DataStructure/StringStore.hpp

${SIMPLNX_SOURCE_DIR}/Filter/AbstractParameter.hpp
${SIMPLNX_SOURCE_DIR}/Filter/AnyCloneable.hpp
Expand Down Expand Up @@ -627,6 +637,7 @@ set(SIMPLNX_SRCS
${SIMPLNX_SOURCE_DIR}/DataStructure/Montage/GridMontage.cpp
${SIMPLNX_SOURCE_DIR}/DataStructure/Montage/GridTileIndex.cpp

${SIMPLNX_SOURCE_DIR}/DataStructure/AbstractStringStore.cpp
${SIMPLNX_SOURCE_DIR}/DataStructure/AttributeMatrix.cpp
${SIMPLNX_SOURCE_DIR}/DataStructure/BaseGroup.cpp
${SIMPLNX_SOURCE_DIR}/DataStructure/DataGroup.cpp
Expand All @@ -639,6 +650,7 @@ set(SIMPLNX_SRCS
${SIMPLNX_SOURCE_DIR}/DataStructure/Metadata.cpp
${SIMPLNX_SOURCE_DIR}/DataStructure/NeighborList.cpp
${SIMPLNX_SOURCE_DIR}/DataStructure/StringArray.cpp
${SIMPLNX_SOURCE_DIR}/DataStructure/StringStore.cpp

${SIMPLNX_SOURCE_DIR}/Filter/AbstractParameter.cpp
${SIMPLNX_SOURCE_DIR}/Filter/Arguments.cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,8 @@ DataStore<UnderlyingType_t<PixelT>> ConvertImageToDataStore(itk::Image<PixelT, D
using ImageType = itk::Image<PixelT, Dimension>;
using T = UnderlyingType_t<PixelT>;
typename ImageType::SizeType imageSize = image.GetLargestPossibleRegion().GetSize();
std::vector<usize> tDims(imageSize.rbegin(), imageSize.rend());
std::vector<usize> cDims = GetComponentDimensions<PixelT>();
typename DataStore<T>::ShapeType tDims(imageSize.rbegin(), imageSize.rend());
typename DataStore<T>::ShapeType cDims = GetComponentDimensions<PixelT>();
if constexpr(Dimension == 2)
{
tDims.insert(tDims.begin(), 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,7 @@ Result<> ComputeFeatureNeighborCAxisMisalignments::operator()()
}
}

for(size_t i = 1; i < totalFeatures; i++)
{
// Set the vector for each list into the NeighborList Object
NeighborList<float>::SharedVectorType misaL(new std::vector<float>);
misaL->assign(misalignmentLists[i].begin(), misalignmentLists[i].end());
cAxisMisalignmentList.setList(static_cast<int32_t>(i), misaL);
}
cAxisMisalignmentList.setLists(misalignmentLists);

return result;
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Result<> ComputeMisorientations::operator()()
QuatF q1(inAvgQuats[quatIndex], inAvgQuats[quatIndex + 1], inAvgQuats[quatIndex + 2], inAvgQuats[quatIndex + 3]);
uint32_t xtalType1 = inXtalStruct[inFeaturePhases[i]];

const NeighborList<int32_t>::VectorType& featureNeighborList = inNeighborList.getListReference(static_cast<int32_t>(i));
const NeighborList<int32_t>::VectorType featureNeighborList = inNeighborList.at(static_cast<int32_t>(i));

tempMisorientationLists[i].assign(featureNeighborList.size(), -1.0);

Expand Down Expand Up @@ -103,13 +103,14 @@ Result<> ComputeMisorientations::operator()()

// Output Variables
auto& outMisorientationList = m_DataStructure.getDataRefAs<NeighborList<float32>>(m_InputValues->MisorientationListArrayName);
outMisorientationList.setLists(tempMisorientationLists);
// Set the vector for each list into the NeighborList Object
for(size_t i = 1; i < totalFeatures; i++)
{
// Construct a shared vector<float> through the std::vector<> copy constructor.
NeighborList<float>::SharedVectorType sharedMisorientationList(new std::vector<float>(tempMisorientationLists[i]));
outMisorientationList.setList(static_cast<int32_t>(i), sharedMisorientationList);
}
// for(size_t i = 1; i < totalFeatures; i++)
//{
// // Construct a shared vector<float> through the std::vector<> copy constructor.
// NeighborList<float>::SharedVectorType sharedMisorientationList(new std::vector<float>(tempMisorientationLists[i]));
// outMisorientationList.setList(static_cast<int32_t>(i), sharedMisorientationList);
//}

return {};
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,20 +100,25 @@ Result<> ComputeSlipTransmissionMetrics::operator()()
auto& F7L = m_DataStructure.getDataRefAs<Float32NeighborList>(m_InputValues->F7ListArrayName);
auto& mPrimeL = m_DataStructure.getDataRefAs<Float32NeighborList>(m_InputValues->mPrimeListArrayName);

for(usize i = 1; i < totalFeatures; i++)
{
Float32NeighborList::SharedVectorType f1L(new std::vector<float32>(F1Lists[i]));
F1L.setList(static_cast<int32>(i), f1L);
F1L.setLists(F1Lists);
F1sptL.setLists(F1sPtLists);
F7L.setLists(F7Lists);
mPrimeL.setLists(mPrimeLists);

Float32NeighborList::SharedVectorType f1sptL(new std::vector<float32>(F1sPtLists[i]));
F1sptL.setList(static_cast<int32>(i), f1sptL);
// for(usize i = 1; i < totalFeatures; i++)
//{
// Float32NeighborList::SharedVectorType f1L(new std::vector<float32>(F1Lists[i]));
// F1L.setList(static_cast<int32>(i), f1L);

Float32NeighborList::SharedVectorType f7L(new std::vector<float32>(F7Lists[i]));
F7L.setList(static_cast<int32>(i), f7L);
// Float32NeighborList::SharedVectorType f1sptL(new std::vector<float32>(F1sPtLists[i]));
// F1sptL.setList(static_cast<int32>(i), f1sptL);

Float32NeighborList::SharedVectorType primeL(new std::vector<float32>(mPrimeLists[i]));
mPrimeL.setList(static_cast<int32>(i), primeL);
}
// Float32NeighborList::SharedVectorType f7L(new std::vector<float32>(F7Lists[i]));
// F7L.setList(static_cast<int32>(i), f7L);

// Float32NeighborList::SharedVectorType primeL(new std::vector<float32>(mPrimeLists[i]));
// mPrimeL.setList(static_cast<int32>(i), primeL);
//}

if(emitLaueClassWarning)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,9 @@ class ComputeArrayStatisticsByIndexImpl
else
{
auto modeList = m_ModeArray->getList(j);
for(int i = 0; i < modeList->size(); i++)
for(int i = 0; i < modeList.size(); i++)
{
const float32 mode = modeList->at(i);
const float32 mode = modeList.at(i);
const auto modalBin = static_cast<int32>((mode - histMin) / increment);
float32 minBinValue = 0.0f;
float32 maxBinValue = 0.0f;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,12 +280,14 @@ Result<> ComputeFeatureClustering::operator()()
rdf[(m_InputValues->NumberOfBins * m_InputValues->PhaseNumber) + i] = oldCount[i] / randomRDF[i + 1];
}

for(usize i = 1; i < totalFeatures; i++)
{
// Set the vector for each list into the Clustering Object
NeighborList<float32>::SharedVectorType sharedClusterLst(new std::vector<float32>);
sharedClusterLst->assign(clusters[i].begin(), clusters[i].end());
clusteringList.setList(static_cast<int>(i), sharedClusterLst);
}
clusteringList.setLists(clusters);

// for(usize i = 1; i < totalFeatures; i++)
//{
// // Set the vector for each list into the Clustering Object
// NeighborList<float32>::SharedVectorType sharedClusterLst(new std::vector<float32>);
// sharedClusterLst->assign(clusters[i].begin(), clusters[i].end());
// clusteringList.setList(static_cast<int>(i), sharedClusterLst);
// }
return {};
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ struct MapPointCloudDataByKernelFunctor
continue;
}
index = (z * dims[1] * dims[0]) + (y * dims[0]) + x;
interpolatedDataPtr->addEntry(index, kernelVals[counter] * inputData[vertIdx]);
interpolatedDataPtr->addEntry(index, kernelVals[counter] * inputData.at(vertIdx));
counter++;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class SIMPLNXCORE_EXPORT CalculatorArray : public ICalculatorArray
else
{
auto* tempArray =
Float64Array::Create(dataStructure, dataArray->getName(), std::make_shared<Float64DataStore>(Float64DataStore(nullptr, dataArray->getTupleShape(), dataArray->getComponentShape())));
Float64Array::Create(dataStructure, dataArray->getName(), std::make_shared<Float64DataStore>(Float64DataStore(dataArray->getTupleShape(), dataArray->getComponentShape(), {})));
m_ArrayId = std::optional{tempArray->getId()};
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <catch2/catch.hpp>

#include <filesystem>
#include <iostream>
#include <string>

namespace fs = std::filesystem;
Expand Down Expand Up @@ -719,6 +720,7 @@ TEST_CASE("SimplnxCore::ApplyTransformationToGeometryFilter:Precomputed_Image_NN
const DataPath calculatedPath({apply_transformation_to_geometry::k_InputGeometryName, k_CellData, "Data"});
const auto& exemplarData = dataStructure.getDataRefAs<IDataArray>(exemplarPath);
const auto& calculatedData = dataStructure.getDataRefAs<IDataArray>(calculatedPath);

UnitTest::CompareDataArrays<int32>(exemplarData, calculatedData);
}
}
16 changes: 8 additions & 8 deletions src/Plugins/SimplnxCore/test/ComputeArrayStatisticsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ TEST_CASE("SimplnxCore::ComputeArrayStatisticsFilter: Test Algorithm", "[Simplnx
auto maxVal = (*maxArray)[0];
auto meanVal = (*meanArray)[0];
auto medianVal = (*medianArray)[0];
auto modeVals = (*modeArray).getListReference(0);
auto modalBinRangesVals = (*modalBinRangesArray).getListReference(0);
auto modeVals = (*modeArray).getList(0);
auto modalBinRangesVals = (*modalBinRangesArray).getList(0);
auto stdVal = (*stdArray)[0];
stdVal = std::ceil(stdVal * 100.0f) / 100.0f; // round value to 2 decimal places
auto sumVal = (*sumArray)[0];
Expand Down Expand Up @@ -384,12 +384,12 @@ TEST_CASE("SimplnxCore::ComputeArrayStatisticsFilter: Test Algorithm By Index",
auto medianVal1 = (*medianArray)[0];
auto medianVal2 = (*medianArray)[1];
auto medianVal3 = (*medianArray)[2];
auto modes0 = (*modeArray).getListReference(0);
auto modes1 = (*modeArray).getListReference(1);
auto modes2 = (*modeArray).getListReference(2);
auto modalBinRange0 = (*modalBinRangesArray).getListReference(0);
auto modalBinRange1 = (*modalBinRangesArray).getListReference(1);
auto modalBinRange2 = (*modalBinRangesArray).getListReference(2);
auto modes0 = (*modeArray).getList(0);
auto modes1 = (*modeArray).getList(1);
auto modes2 = (*modeArray).getList(2);
auto modalBinRange0 = (*modalBinRangesArray).getList(0);
auto modalBinRange1 = (*modalBinRangesArray).getList(1);
auto modalBinRange2 = (*modalBinRangesArray).getList(2);
auto stdVal1 = (*stdArray)[0];
auto stdVal2 = (*stdArray)[1];
auto stdVal3 = (*stdArray)[2];
Expand Down
2 changes: 2 additions & 0 deletions src/simplnx/Core/Application.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once

#define NOMINMAX

#include "simplnx/Core/Preferences.hpp"
#include "simplnx/DataStructure/DataObject.hpp"
#include "simplnx/Filter/FilterList.hpp"
Expand Down
Loading
Loading