From e8e6b91435e1369fafc15eef2c2fbec9d2327465 Mon Sep 17 00:00:00 2001 From: Michael Jackson Date: Tue, 3 Sep 2024 15:25:41 -0400 Subject: [PATCH] DataArrayUtilities completed Signed-off-by: Michael Jackson --- .../Algorithms/ComputeArrayStatistics.cpp | 2 +- .../Filters/AlignSectionsListFilter.hpp | 3 +-- .../src/SimplnxCore/utils/nanoflann.hpp | 2 +- .../SimplnxCore/wrapping/python/simplnxpy.cpp | 15 ++++------- .../IO/Generic/DataIOCollection.cpp | 5 ++-- .../IO/Generic/DataIOCollection.hpp | 7 +++-- src/simplnx/Filter/FilterTraits.hpp | 2 +- src/simplnx/Utilities/DataArrayUtilities.cpp | 20 ++++++++++++++ src/simplnx/Utilities/DataArrayUtilities.hpp | 26 ++++++++++++------- src/simplnx/Utilities/SIMPLConversion.hpp | 26 +------------------ test/DataArrayTest.cpp | 1 + 11 files changed, 54 insertions(+), 55 deletions(-) diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeArrayStatistics.cpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeArrayStatistics.cpp index 09875f9fea..0e1747af32 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeArrayStatistics.cpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/Algorithms/ComputeArrayStatistics.cpp @@ -271,7 +271,7 @@ class ComputeArrayStatisticsByIndexImpl histogram[m_NumBins - 1]++; } } // end of numTuples loop - } // end of increment else + } // end of increment else if(m_ModalBinRanges) { diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/AlignSectionsListFilter.hpp b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/AlignSectionsListFilter.hpp index a87542e09a..90d45a261a 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/AlignSectionsListFilter.hpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/Filters/AlignSectionsListFilter.hpp @@ -2,9 +2,8 @@ #include "SimplnxCore/SimplnxCore_export.hpp" - -#include "simplnx/Filter/IFilter.hpp" #include "simplnx/Filter/FilterTraits.hpp" +#include "simplnx/Filter/IFilter.hpp" namespace nx::core { diff --git a/src/Plugins/SimplnxCore/src/SimplnxCore/utils/nanoflann.hpp b/src/Plugins/SimplnxCore/src/SimplnxCore/utils/nanoflann.hpp index 42fc0372fe..1d462f1c34 100644 --- a/src/Plugins/SimplnxCore/src/SimplnxCore/utils/nanoflann.hpp +++ b/src/Plugins/SimplnxCore/src/SimplnxCore/utils/nanoflann.hpp @@ -2205,7 +2205,7 @@ struct KDTreeEigenMatrixAdaptor /** @} */ }; // end of KDTreeEigenMatrixAdaptor - /** @} */ +/** @} */ /** @} */ // end of grouping } // namespace nanoflann diff --git a/src/Plugins/SimplnxCore/wrapping/python/simplnxpy.cpp b/src/Plugins/SimplnxCore/wrapping/python/simplnxpy.cpp index 6821e4a83b..7f196cfbd2 100644 --- a/src/Plugins/SimplnxCore/wrapping/python/simplnxpy.cpp +++ b/src/Plugins/SimplnxCore/wrapping/python/simplnxpy.cpp @@ -584,8 +584,7 @@ PYBIND11_MODULE(simplnx, mod) parameters.def("insert_linkable_parameter", &PyInsertLinkableParameter); parameters.def("link_parameters", [](Parameters& self, std::string groupKey, std::string childKey, BoolParameter::ValueType value) { self.linkParameters(groupKey, childKey, value); }); parameters.def("link_parameters", [](Parameters& self, std::string groupKey, std::string childKey, ChoicesParameter::ValueType value) { self.linkParameters(groupKey, childKey, value); }); - parameters.def( - "__getitem__", [](Parameters& self, std::string_view key) { return self.at(key).get(); }, py::return_value_policy::reference_internal); + parameters.def("__getitem__", [](Parameters& self, std::string_view key) { return self.at(key).get(); }, py::return_value_policy::reference_internal); py::class_> iArrayThreshold(mod, "IArrayThreshold"); @@ -1422,12 +1421,10 @@ PYBIND11_MODULE(simplnx, mod) "path"_a); pipeline.def_property("name", &Pipeline::getName, &Pipeline::setName); pipeline.def("execute", &ExecutePipeline); - pipeline.def( - "__getitem__", [](Pipeline& self, Pipeline::index_type index) { return self.at(index); }, py::return_value_policy::reference_internal); + pipeline.def("__getitem__", [](Pipeline& self, Pipeline::index_type index) { return self.at(index); }, py::return_value_policy::reference_internal); pipeline.def("__len__", &Pipeline::size); pipeline.def("size", &Pipeline::size); - pipeline.def( - "__iter__", [](Pipeline& self) { return py::make_iterator(self.begin(), self.end()); }, py::keep_alive<0, 1>()); + pipeline.def("__iter__", [](Pipeline& self) { return py::make_iterator(self.begin(), self.end()); }, py::keep_alive<0, 1>()); pipeline.def( "insert", [internals](Pipeline& self, Pipeline::index_type index, const IFilter& filter, const py::dict& args) { @@ -1441,10 +1438,8 @@ PYBIND11_MODULE(simplnx, mod) pipeline.def("remove", &Pipeline::removeAt, "index"_a); pipelineFilter.def("get_args", [internals](PipelineFilter& self) { return ConvertArgsToDict(*internals, self.getParameters(), self.getArguments()); }); - pipelineFilter.def( - "set_args", [internals](PipelineFilter& self, py::dict& args) { self.setArguments(ConvertDictToArgs(*internals, self.getParameters(), args)); }, "args"_a); - pipelineFilter.def( - "get_filter", [](PipelineFilter& self) { return self.getFilter(); }, py::return_value_policy::reference_internal); + pipelineFilter.def("set_args", [internals](PipelineFilter& self, py::dict& args) { self.setArguments(ConvertDictToArgs(*internals, self.getParameters(), args)); }, "args"_a); + pipelineFilter.def("get_filter", [](PipelineFilter& self) { return self.getFilter(); }, py::return_value_policy::reference_internal); pipelineFilter.def( "name", [](const PipelineFilter& self) { diff --git a/src/simplnx/DataStructure/IO/Generic/DataIOCollection.cpp b/src/simplnx/DataStructure/IO/Generic/DataIOCollection.cpp index f34f9214fb..0a9e1553c7 100644 --- a/src/simplnx/DataStructure/IO/Generic/DataIOCollection.cpp +++ b/src/simplnx/DataStructure/IO/Generic/DataIOCollection.cpp @@ -59,11 +59,11 @@ std::unique_ptr DataIOCollection::createDataStore(const std::string& return nullptr; } -void DataIOCollection::checkStoreDataFormat(uint64 dataSize, std::string& dataFormat) const +std::string DataIOCollection::checkStoreDataFormat(uint64 dataSize, std::string dataFormat) const { if(!dataFormat.empty()) { - return; + return dataFormat; } const Preferences* preferences = Application::GetOrCreateInstance()->getPreferences(); const uint64 largeDataSize = preferences->valueAs(Preferences::k_LargeDataSize_Key); @@ -72,6 +72,7 @@ void DataIOCollection::checkStoreDataFormat(uint64 dataSize, std::string& dataFo { dataFormat = largeDataFormat; } + return dataFormat; } std::vector DataIOCollection::getFormatNames() const diff --git a/src/simplnx/DataStructure/IO/Generic/DataIOCollection.hpp b/src/simplnx/DataStructure/IO/Generic/DataIOCollection.hpp index 61205652ca..e0e11df0c7 100644 --- a/src/simplnx/DataStructure/IO/Generic/DataIOCollection.hpp +++ b/src/simplnx/DataStructure/IO/Generic/DataIOCollection.hpp @@ -1,10 +1,9 @@ #pragma once -#include "simplnx/DataStructure/AbstractDataStore.hpp" -#include "simplnx/simplnx_export.hpp" - #include "simplnx/Common/Types.hpp" #include "simplnx/Common/TypesUtility.hpp" +#include "simplnx/DataStructure/AbstractDataStore.hpp" +#include "simplnx/simplnx_export.hpp" #include #include @@ -63,7 +62,7 @@ class SIMPLNX_EXPORT DataIOCollection /** * @brief Checks the */ - void checkStoreDataFormat(uint64 dataSize, std::string& dataFormat) const; + std::string checkStoreDataFormat(uint64 dataSize, std::string dataFormat) const; iterator begin(); iterator end(); diff --git a/src/simplnx/Filter/FilterTraits.hpp b/src/simplnx/Filter/FilterTraits.hpp index aee7ab32e7..4eeb009a75 100644 --- a/src/simplnx/Filter/FilterTraits.hpp +++ b/src/simplnx/Filter/FilterTraits.hpp @@ -1,6 +1,6 @@ #pragma once -//#include "simplnx/Common/StringLiteral.hpp" +// #include "simplnx/Common/StringLiteral.hpp" #include "simplnx/Filter/IFilter.hpp" #include diff --git a/src/simplnx/Utilities/DataArrayUtilities.cpp b/src/simplnx/Utilities/DataArrayUtilities.cpp index ca5ca0c57d..a86c03e23d 100644 --- a/src/simplnx/Utilities/DataArrayUtilities.cpp +++ b/src/simplnx/Utilities/DataArrayUtilities.cpp @@ -2,6 +2,8 @@ #include "simplnx/Common/Types.hpp" #include "simplnx/Common/TypesUtility.hpp" +#include "simplnx/Core/Application.hpp" +#include "simplnx/DataStructure/IO/Generic/DataIOCollection.hpp" #include "simplnx/Utilities/FilterUtilities.hpp" #include @@ -32,6 +34,24 @@ struct InitializeNeighborListFunctor namespace nx::core { + +std::string GetDataFormatFromPreferences() +{ + std::string dataFormat; + + auto* preferencesPtr = Application::GetOrCreateInstance()->getPreferences(); + if(preferencesPtr->forceOocData()) + { + dataFormat = preferencesPtr->largeDataFormat(); + } + return dataFormat; +} + +std::shared_ptr GetDataCollectionInstance() +{ + return Application::GetOrCreateInstance()->getIOCollection(); +} + //----------------------------------------------------------------------------- Result<> CheckValueConverts(const std::string& value, NumericType numericType) { diff --git a/src/simplnx/Utilities/DataArrayUtilities.hpp b/src/simplnx/Utilities/DataArrayUtilities.hpp index 0e3db14f2a..cb68b8e9c5 100644 --- a/src/simplnx/Utilities/DataArrayUtilities.hpp +++ b/src/simplnx/Utilities/DataArrayUtilities.hpp @@ -2,7 +2,6 @@ #include "simplnx/Common/Array.hpp" #include "simplnx/Common/Result.hpp" -#include "simplnx/Core/Application.hpp" #include "simplnx/DataStructure/AttributeMatrix.hpp" #include "simplnx/DataStructure/DataArray.hpp" #include "simplnx/DataStructure/DataStore.hpp" @@ -12,6 +11,7 @@ #include "simplnx/DataStructure/NeighborList.hpp" #include "simplnx/DataStructure/StringArray.hpp" #include "simplnx/Filter/Actions/CreateArrayAction.hpp" +#include "simplnx/Filter/IFilter.hpp" #include "simplnx/Filter/Output.hpp" #include "simplnx/Parameters/MultiArraySelectionParameter.hpp" #include "simplnx/Utilities/MemoryUtilities.hpp" @@ -345,6 +345,18 @@ uint64 CalculateDataSize(const IDataStore::ShapeType& tupleShape, const IDataSto return numValues * numComponents * sizeof(T); } +/** + * + * @return + */ +std::string GetDataFormatFromPreferences(); + +/** + * + * @return + */ +std::shared_ptr GetDataCollectionInstance(); + /** * @brief Creates a DataStore with the given properties * @tparam T Primitive Type (int, float, ...) @@ -364,13 +376,9 @@ std::shared_ptr> CreateDataStore(const typename IDataStore: } case IDataAction::Mode::Execute: { uint64 dataSize = CalculateDataSize(tupleShape, componentShape); - auto* preferencesPtr = Application::GetOrCreateInstance()->getPreferences(); - if(preferencesPtr->forceOocData()) - { - dataFormat = preferencesPtr->largeDataFormat(); - } - auto ioCollection = Application::GetOrCreateInstance()->getIOCollection(); - ioCollection->checkStoreDataFormat(dataSize, dataFormat); + dataFormat = GetDataFormatFromPreferences(); + auto ioCollection = GetDataCollectionInstance(); + dataFormat = ioCollection->checkStoreDataFormat(dataSize, dataFormat); return ioCollection->createDataStoreWithType(dataFormat, tupleShape, componentShape); } default: { @@ -476,7 +484,7 @@ std::shared_ptr> ConvertDataStore(const AbstractDataStoregetIOCollection(); + auto ioCollection = GetDataCollectionInstance(); std::shared_ptr> newStore = ioCollection->createDataStoreWithType(dataFormat, dataStore.getTupleShape(), dataStore.getComponentShape()); if(newStore == nullptr) { diff --git a/src/simplnx/Utilities/SIMPLConversion.hpp b/src/simplnx/Utilities/SIMPLConversion.hpp index 8024f32364..3f01a87398 100644 --- a/src/simplnx/Utilities/SIMPLConversion.hpp +++ b/src/simplnx/Utilities/SIMPLConversion.hpp @@ -6,24 +6,18 @@ #include "simplnx/Common/TypesUtility.hpp" #include "simplnx/Parameters/ArrayCreationParameter.hpp" #include "simplnx/Parameters/ArraySelectionParameter.hpp" -#ifdef SIMPL_PARAM_CONVERT_ARRAY_THRESHOLD #include "simplnx/Parameters/ArrayThresholdsParameter.hpp" -#endif #include "simplnx/Parameters/AttributeMatrixSelectionParameter.hpp" #include "simplnx/Parameters/BoolParameter.hpp" #include "simplnx/Parameters/CalculatorParameter.hpp" #include "simplnx/Parameters/ChoicesParameter.hpp" -#ifdef SIMPL_PARAM_CONVERT_CREATE_COLOR_MAP #include "simplnx/Parameters/CreateColorMapParameter.hpp" -#endif #include "simplnx/Parameters/DataGroupCreationParameter.hpp" #include "simplnx/Parameters/DataGroupSelectionParameter.hpp" #include "simplnx/Parameters/DataObjectNameParameter.hpp" #include "simplnx/Parameters/DataTypeParameter.hpp" #include "simplnx/Parameters/Dream3dImportParameter.hpp" -#ifdef SIMPL_PARAM_CONVERT_DYNAMIC_TABLE #include "simplnx/Parameters/DynamicTableParameter.hpp" -#endif #include "simplnx/Parameters/EnsembleInfoParameter.hpp" #include "simplnx/Parameters/FileSystemPathParameter.hpp" #include "simplnx/Parameters/GeneratedFileListParameter.hpp" @@ -32,17 +26,11 @@ #include "simplnx/Parameters/MultiPathSelectionParameter.hpp" #include "simplnx/Parameters/NumberParameter.hpp" #include "simplnx/Parameters/NumericTypeParameter.hpp" -#ifdef SIMPL_PARAM_CONVERT_READ_CSV #include "simplnx/Parameters/ReadCSVFileParameter.hpp" -#endif -#ifdef SIMPL_PARAM_CONVERT_READ_HDF5_DATASET #include "simplnx/Parameters/ReadHDF5DatasetParameter.hpp" -#endif #include "simplnx/Parameters/StringParameter.hpp" #include "simplnx/Parameters/VectorParameter.hpp" -// #include "OrientationAnalysis/Parameters/H5EbsdReaderParameter.h" - #include #include @@ -1267,7 +1255,6 @@ struct ChoiceFilterParameterConverter } }; -#ifdef SIMPL_PARAM_CONVERT_DYNAMIC_TABLE struct DynamicTableFilterParameterConverter { using ParameterType = DynamicTableParameter; @@ -1321,9 +1308,7 @@ struct DynamicTableFilterParameterConverter return {std::move(table)}; } }; -#endif -#ifdef SIMPL_PARAM_CONVERT_DYNAMIC_TABLE struct ArrayToDynamicTableFilterParameterConverter { using ParameterType = DynamicTableParameter; @@ -1358,7 +1343,6 @@ struct ArrayToDynamicTableFilterParameterConverter return {std::move(table)}; } }; -#endif struct AttributeMatrixCreationFilterParameterConverter { @@ -1689,7 +1673,7 @@ struct EnsembleInfoFilterParameterConverter return {std::move(value)}; } }; -#ifdef SIMPL_PARAM_CONVERT_CREATE_COLOR_MAP + struct CreateColorMapFilterParameterConverter { using ParameterType = CreateColorMapParameter; @@ -1720,9 +1704,7 @@ struct CreateColorMapFilterParameterConverter return {std::move(value)}; } }; -#endif -#ifdef SIMPL_PARAM_CONVERT_READ_CSV struct ReadASCIIWizardDataFilterParameterConverter { using ParameterType = ReadCSVFileParameter; @@ -1801,9 +1783,7 @@ struct ReadASCIIWizardDataFilterParameterConverter return {std::move(value)}; } }; -#endif -#ifdef SIMPL_PARAM_CONVERT_READ_HDF5_DATASET struct ImportHDF5DatasetFilterParameterConverter { using ParameterType = ReadHDF5DatasetParameter; @@ -1857,7 +1837,6 @@ struct ImportHDF5DatasetFilterParameterConverter return {std::move(value)}; } }; -#endif struct DataArraysToRemoveConverter { @@ -2122,7 +2101,6 @@ struct DataContainerReaderFilterParameterConverter } }; -#ifdef SIMPL_PARAM_CONVERT_ARRAY_THRESHOLD struct ComparisonSelectionFilterParameterConverter { using ParameterType = ArrayThresholdsParameter; @@ -2337,6 +2315,4 @@ struct ComparisonSelectionAdvancedFilterParameterConverter return {std::move(value)}; } }; -#endif - } // namespace nx::core::SIMPLConversion diff --git a/test/DataArrayTest.cpp b/test/DataArrayTest.cpp index 2483ce8e52..628564bec4 100644 --- a/test/DataArrayTest.cpp +++ b/test/DataArrayTest.cpp @@ -3,6 +3,7 @@ #include "simplnx/DataStructure/DataStore.hpp" #include "simplnx/DataStructure/DataStructure.hpp" #include "simplnx/Utilities/DataArrayUtilities.hpp" +#include "simplnx/Core/Application.hpp" #include