Skip to content

Commit

Permalink
DataArrayUtilities completed
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Jackson <[email protected]>
  • Loading branch information
imikejackson committed Sep 10, 2024
1 parent e493881 commit e8e6b91
Show file tree
Hide file tree
Showing 11 changed files with 54 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2205,7 +2205,7 @@ struct KDTreeEigenMatrixAdaptor
/** @} */

}; // end of KDTreeEigenMatrixAdaptor
/** @} */
/** @} */

/** @} */ // end of grouping
} // namespace nanoflann
Expand Down
15 changes: 5 additions & 10 deletions src/Plugins/SimplnxCore/wrapping/python/simplnxpy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -584,8 +584,7 @@ PYBIND11_MODULE(simplnx, mod)
parameters.def("insert_linkable_parameter", &PyInsertLinkableParameter<ChoicesParameter>);
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, std::shared_ptr<IArrayThreshold>> iArrayThreshold(mod, "IArrayThreshold");

Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down
5 changes: 3 additions & 2 deletions src/simplnx/DataStructure/IO/Generic/DataIOCollection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ std::unique_ptr<IDataStore> 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<uint64>(Preferences::k_LargeDataSize_Key);
Expand All @@ -72,6 +72,7 @@ void DataIOCollection::checkStoreDataFormat(uint64 dataSize, std::string& dataFo
{
dataFormat = largeDataFormat;
}
return dataFormat;
}

std::vector<std::string> DataIOCollection::getFormatNames() const
Expand Down
7 changes: 3 additions & 4 deletions src/simplnx/DataStructure/IO/Generic/DataIOCollection.hpp
Original file line number Diff line number Diff line change
@@ -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 <map>
#include <memory>
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/simplnx/Filter/FilterTraits.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

//#include "simplnx/Common/StringLiteral.hpp"
// #include "simplnx/Common/StringLiteral.hpp"
#include "simplnx/Filter/IFilter.hpp"

#include <type_traits>
Expand Down
20 changes: 20 additions & 0 deletions src/simplnx/Utilities/DataArrayUtilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <set>
Expand Down Expand Up @@ -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<DataIOCollection> GetDataCollectionInstance()
{
return Application::GetOrCreateInstance()->getIOCollection();
}

//-----------------------------------------------------------------------------
Result<> CheckValueConverts(const std::string& value, NumericType numericType)
{
Expand Down
26 changes: 17 additions & 9 deletions src/simplnx/Utilities/DataArrayUtilities.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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<DataIOCollection> GetDataCollectionInstance();

/**
* @brief Creates a DataStore with the given properties
* @tparam T Primitive Type (int, float, ...)
Expand All @@ -364,13 +376,9 @@ std::shared_ptr<AbstractDataStore<T>> CreateDataStore(const typename IDataStore:
}
case IDataAction::Mode::Execute: {
uint64 dataSize = CalculateDataSize<T>(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<T>(dataFormat, tupleShape, componentShape);
}
default: {
Expand Down Expand Up @@ -476,7 +484,7 @@ std::shared_ptr<AbstractDataStore<T>> ConvertDataStore(const AbstractDataStore<T
return nullptr;
}

auto ioCollection = Application::GetOrCreateInstance()->getIOCollection();
auto ioCollection = GetDataCollectionInstance();
std::shared_ptr<AbstractDataStore<T>> newStore = ioCollection->createDataStoreWithType<T>(dataFormat, dataStore.getTupleShape(), dataStore.getComponentShape());
if(newStore == nullptr)
{
Expand Down
26 changes: 1 addition & 25 deletions src/simplnx/Utilities/SIMPLConversion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 <nlohmann/json.hpp>

#include <string_view>
Expand Down Expand Up @@ -1267,7 +1255,6 @@ struct ChoiceFilterParameterConverter
}
};

#ifdef SIMPL_PARAM_CONVERT_DYNAMIC_TABLE
struct DynamicTableFilterParameterConverter
{
using ParameterType = DynamicTableParameter;
Expand Down Expand Up @@ -1321,9 +1308,7 @@ struct DynamicTableFilterParameterConverter
return {std::move(table)};
}
};
#endif

#ifdef SIMPL_PARAM_CONVERT_DYNAMIC_TABLE
struct ArrayToDynamicTableFilterParameterConverter
{
using ParameterType = DynamicTableParameter;
Expand Down Expand Up @@ -1358,7 +1343,6 @@ struct ArrayToDynamicTableFilterParameterConverter
return {std::move(table)};
}
};
#endif

struct AttributeMatrixCreationFilterParameterConverter
{
Expand Down Expand Up @@ -1689,7 +1673,7 @@ struct EnsembleInfoFilterParameterConverter
return {std::move(value)};
}
};
#ifdef SIMPL_PARAM_CONVERT_CREATE_COLOR_MAP

struct CreateColorMapFilterParameterConverter
{
using ParameterType = CreateColorMapParameter;
Expand Down Expand Up @@ -1720,9 +1704,7 @@ struct CreateColorMapFilterParameterConverter
return {std::move(value)};
}
};
#endif

#ifdef SIMPL_PARAM_CONVERT_READ_CSV
struct ReadASCIIWizardDataFilterParameterConverter
{
using ParameterType = ReadCSVFileParameter;
Expand Down Expand Up @@ -1801,9 +1783,7 @@ struct ReadASCIIWizardDataFilterParameterConverter
return {std::move(value)};
}
};
#endif

#ifdef SIMPL_PARAM_CONVERT_READ_HDF5_DATASET
struct ImportHDF5DatasetFilterParameterConverter
{
using ParameterType = ReadHDF5DatasetParameter;
Expand Down Expand Up @@ -1857,7 +1837,6 @@ struct ImportHDF5DatasetFilterParameterConverter
return {std::move(value)};
}
};
#endif

struct DataArraysToRemoveConverter
{
Expand Down Expand Up @@ -2122,7 +2101,6 @@ struct DataContainerReaderFilterParameterConverter
}
};

#ifdef SIMPL_PARAM_CONVERT_ARRAY_THRESHOLD
struct ComparisonSelectionFilterParameterConverter
{
using ParameterType = ArrayThresholdsParameter;
Expand Down Expand Up @@ -2337,6 +2315,4 @@ struct ComparisonSelectionAdvancedFilterParameterConverter
return {std::move(value)};
}
};
#endif

} // namespace nx::core::SIMPLConversion
1 change: 1 addition & 0 deletions test/DataArrayTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <catch2/catch.hpp>

Expand Down

0 comments on commit e8e6b91

Please sign in to comment.