Skip to content

Commit

Permalink
Start fixing unit tests
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Jackson <[email protected]>
  • Loading branch information
imikejackson committed Apr 3, 2024
1 parent 0057702 commit 2334974
Show file tree
Hide file tree
Showing 9 changed files with 78 additions and 70 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ Result<> ReadImageStack(DataStructure& dataStructure, const DataPath& imageGeomP
Arguments colorToGrayscaleArgs;
colorToGrayscaleArgs.insertOrAssign("conversion_algorithm", std::make_any<ChoicesParameter::ValueType>(0));
colorToGrayscaleArgs.insertOrAssign("color_weights", std::make_any<VectorFloat32Parameter::ValueType>(luminosityValues));
colorToGrayscaleArgs.insertOrAssign("input_data_array_vector", std::make_any<std::vector<DataPath>>(std::vector<DataPath>{imageDataPath}));
colorToGrayscaleArgs.insertOrAssign("input_data_array_paths", std::make_any<std::vector<DataPath>>(std::vector<DataPath>{imageDataPath}));
colorToGrayscaleArgs.insertOrAssign("output_array_prefix", std::make_any<std::string>("gray"));

// Run grayscale filter and process results and messages
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const Uuid k_SimplnxCorePluginId = *Uuid::FromString("05cc618b-781f-4ac0-b9ac-43
const Uuid k_ApplyTransformationToGeometryFilterId = *Uuid::FromString("f5bbc16b-3426-4ae0-b27b-ba7862dc40fe");
const FilterHandle k_ApplyTransformationToGeometryFilterHandle(k_ApplyTransformationToGeometryFilterId, k_SimplnxCorePluginId);

inline constexpr StringLiteral k_SelectedImageGeometryKey = "selected_image_geometry";
inline constexpr StringLiteral k_SelectedImageGeometryKey = "selected_image_geometry_path";
inline constexpr StringLiteral k_CellAttributeMatrixPathKey = "cell_attribute_matrix_path";
inline constexpr StringLiteral k_TransformationTypeKey = "transformation_type";
inline constexpr StringLiteral k_ManualTransformationMatrixKey = "manual_transformation_matrix";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ DataPath ConvertColorToGrayScale(DataStructure& dataStructure, const DataPath& i
constexpr StringLiteral k_ConversionAlgorithm_Key = "conversion_algorithm";
constexpr StringLiteral k_ColorWeights_Key = "color_weights";
constexpr StringLiteral k_ColorChannel_Key = "color_channel";
constexpr StringLiteral k_InputDataArrayVector_Key = "input_data_array_vector";
constexpr StringLiteral k_InputDataArrayVector_Key = "input_data_array_paths";
constexpr StringLiteral k_OutputArrayPrefix_Key = "output_array_prefix";

auto filter = s_FilterList->createFilter(k_ColorToGrayScaleFilterHandle);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,15 @@ TEST_CASE("OrientationAnalysis::AlignSectionsMisorientation Small IN100 Pipeline

// Read Exemplar Shifts File
{
static constexpr StringLiteral k_InputFileKey = "input_file";
static constexpr StringLiteral k_ScalarTypeKey = "scalar_type";
static constexpr StringLiteral k_NTuplesKey = "n_tuples";
static constexpr StringLiteral k_NCompKey = "n_comp";
static constexpr StringLiteral k_NSkipLinesKey = "n_skip_lines";
static constexpr StringLiteral k_DelimiterChoiceKey = "delimiter_choice";
static constexpr StringLiteral k_DataArrayKey = "output_data_array";
constexpr StringLiteral k_InputFile_Key = "input_file";
constexpr StringLiteral k_ScalarType_Key = "scalar_type";
constexpr StringLiteral k_NTuples_Key = "number_tuples";
constexpr StringLiteral k_NComp_Key = "number_comp";
constexpr StringLiteral k_NSkipLines_Key = "skip_line_count";
constexpr StringLiteral k_DelimiterChoice_Key = "delimiter_choice";
constexpr StringLiteral k_DataArrayPath_Key = "output_data_array_path";
constexpr StringLiteral k_DataFormat_Key = "data_format";
constexpr StringLiteral k_AdvancedOptions_Key = "advanced_options";

// Compare the output of the shifts file with the exemplar file

Expand All @@ -84,13 +86,13 @@ TEST_CASE("OrientationAnalysis::AlignSectionsMisorientation Small IN100 Pipeline

Arguments args;
// read in the exemplar shift data file
args.insertOrAssign(k_InputFileKey, std::make_any<FileSystemPathParameter::ValueType>(fs::path(fmt::format("{}/align_sections_misorientation.txt", unit_test::k_TestFilesDir))));
args.insertOrAssign(k_ScalarTypeKey, std::make_any<NumericTypeParameter::ValueType>(nx::core::NumericType::int32));
args.insertOrAssign(k_NTuplesKey, std::make_any<DynamicTableParameter::ValueType>(DynamicTableInfo::TableDataType{{static_cast<double>(116)}}));
args.insertOrAssign(k_NCompKey, std::make_any<uint64>(6));
args.insertOrAssign(k_NSkipLinesKey, std::make_any<uint64>(0));
args.insertOrAssign(k_DelimiterChoiceKey, std::make_any<ChoicesParameter::ValueType>(4));
args.insertOrAssign(k_DataArrayKey, std::make_any<DataPath>(k_ExemplarShiftsPath));
args.insertOrAssign(k_InputFile_Key, std::make_any<FileSystemPathParameter::ValueType>(fs::path(fmt::format("{}/align_sections_misorientation.txt", unit_test::k_TestFilesDir))));
args.insertOrAssign(k_ScalarType_Key, std::make_any<NumericTypeParameter::ValueType>(nx::core::NumericType::int32));
args.insertOrAssign(k_NTuples_Key, std::make_any<DynamicTableParameter::ValueType>(DynamicTableInfo::TableDataType{{static_cast<double>(116)}}));
args.insertOrAssign(k_NComp_Key, std::make_any<uint64>(6));
args.insertOrAssign(k_NSkipLines_Key, std::make_any<uint64>(0));
args.insertOrAssign(k_DelimiterChoice_Key, std::make_any<ChoicesParameter::ValueType>(4));
args.insertOrAssign(k_DataArrayPath_Key, std::make_any<DataPath>(k_ExemplarShiftsPath));

// Preflight the filter and check result
auto preflightResult = filter->preflight(dataStructure, args);
Expand Down Expand Up @@ -140,27 +142,29 @@ TEST_CASE("OrientationAnalysis::AlignSectionsMisorientation Small IN100 Pipeline

// Use the Read Text File Filter to read in the generated Shift File
{
static constexpr StringLiteral k_InputFileKey = "input_file";
static constexpr StringLiteral k_ScalarTypeKey = "scalar_type";
static constexpr StringLiteral k_NTuplesKey = "n_tuples";
static constexpr StringLiteral k_NCompKey = "n_comp";
static constexpr StringLiteral k_NSkipLinesKey = "n_skip_lines";
static constexpr StringLiteral k_DelimiterChoiceKey = "delimiter_choice";
static constexpr StringLiteral k_DataArrayKey = "output_data_array";
constexpr StringLiteral k_InputFile_Key = "input_file";
constexpr StringLiteral k_ScalarType_Key = "scalar_type";
constexpr StringLiteral k_NTuples_Key = "number_tuples";
constexpr StringLiteral k_NComp_Key = "number_comp";
constexpr StringLiteral k_NSkipLines_Key = "skip_line_count";
constexpr StringLiteral k_DelimiterChoice_Key = "delimiter_choice";
constexpr StringLiteral k_DataArrayPath_Key = "output_data_array_path";
constexpr StringLiteral k_DataFormat_Key = "data_format";
constexpr StringLiteral k_AdvancedOptions_Key = "advanced_options";

// Compare the output of the shifts file with the exemplar file

auto filter = filterList->createFilter(k_ReadTextDataArrayFilterHandle);
REQUIRE(nullptr != filter);

Arguments args;
args.insertOrAssign(k_InputFileKey, std::make_any<FileSystemPathParameter::ValueType>(computedShiftsFile));
args.insertOrAssign(k_ScalarTypeKey, std::make_any<NumericTypeParameter::ValueType>(nx::core::NumericType::int32));
args.insertOrAssign(k_NTuplesKey, std::make_any<DynamicTableParameter::ValueType>(DynamicTableInfo::TableDataType{{static_cast<double>(116)}}));
args.insertOrAssign(k_NCompKey, std::make_any<uint64>(6));
args.insertOrAssign(k_NSkipLinesKey, std::make_any<uint64>(0));
args.insertOrAssign(k_DelimiterChoiceKey, std::make_any<ChoicesParameter::ValueType>(4));
args.insertOrAssign(k_DataArrayKey, std::make_any<DataPath>(k_CalculatedShiftsPath));
args.insertOrAssign(k_InputFile_Key, std::make_any<FileSystemPathParameter::ValueType>(computedShiftsFile));
args.insertOrAssign(k_ScalarType_Key, std::make_any<NumericTypeParameter::ValueType>(nx::core::NumericType::int32));
args.insertOrAssign(k_NTuples_Key, std::make_any<DynamicTableParameter::ValueType>(DynamicTableInfo::TableDataType{{static_cast<double>(116)}}));
args.insertOrAssign(k_NComp_Key, std::make_any<uint64>(6));
args.insertOrAssign(k_NSkipLines_Key, std::make_any<uint64>(0));
args.insertOrAssign(k_DelimiterChoice_Key, std::make_any<ChoicesParameter::ValueType>(4));
args.insertOrAssign(k_DataFormat_Key, std::make_any<DataPath>(k_CalculatedShiftsPath));

// Preflight the filter and check result
auto preflightResult = filter->preflight(dataStructure, args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class SIMPLNXCORE_EXPORT MultiThresholdObjects : public IFilter
static inline constexpr StringLiteral k_UseCustomFalseValue = "use_custom_false_value";
static inline constexpr StringLiteral k_CustomTrueValue = "custom_true_value";
static inline constexpr StringLiteral k_CustomFalseValue = "custom_false_value";
static inline constexpr StringLiteral k_CreatedDataPath_Key = "created_data_array_name";
static inline constexpr StringLiteral k_CreatedDataPath_Key = "created_data_array_path";
static inline constexpr StringLiteral k_CreatedMaskType_Key = "created_mask_type";

/**
Expand Down
62 changes: 33 additions & 29 deletions src/Plugins/SimplnxCore/test/AlignSectionsFeatureCentroidTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,28 +84,30 @@ TEST_CASE("SimplnxCore::AlignSectionsFeatureCentroidFilter", "[Reconstruction][A

// Read Exemplar Shifts File
{
static constexpr StringLiteral k_InputFileKey = "input_file";
static constexpr StringLiteral k_ScalarTypeKey = "scalar_type";
static constexpr StringLiteral k_NTuplesKey = "n_tuples";
static constexpr StringLiteral k_NCompKey = "n_comp";
static constexpr StringLiteral k_NSkipLinesKey = "n_skip_lines";
static constexpr StringLiteral k_DelimiterChoiceKey = "delimiter_choice";
static constexpr StringLiteral k_DataArrayKey = "output_data_array";
constexpr StringLiteral k_InputFile_Key = "input_file";
constexpr StringLiteral k_ScalarType_Key = "scalar_type";
constexpr StringLiteral k_NTuples_Key = "number_tuples";
constexpr StringLiteral k_NComp_Key = "number_comp";
constexpr StringLiteral k_NSkipLines_Key = "skip_line_count";
constexpr StringLiteral k_DelimiterChoice_Key = "delimiter_choice";
constexpr StringLiteral k_DataArrayPath_Key = "output_data_array_path";
constexpr StringLiteral k_DataFormat_Key = "data_format";
constexpr StringLiteral k_AdvancedOptions_Key = "advanced_options";

// Compare the output of the shifts file with the exemplar file

ReadTextDataArrayFilter filter;

Arguments args;
// read in the exemplar shift data file
args.insertOrAssign(k_InputFileKey, std::make_any<FileSystemPathParameter::ValueType>(
fs::path(fmt::format("{}/6_6_align_sections_feature_centroids/6_6_align_sections_feature_centroids.txt", unit_test::k_TestFilesDir))));
args.insertOrAssign(k_ScalarTypeKey, std::make_any<NumericTypeParameter::ValueType>(nx::core::NumericType::float32));
args.insertOrAssign(k_NTuplesKey, std::make_any<DynamicTableParameter::ValueType>(k_TupleDims));
args.insertOrAssign(k_NCompKey, std::make_any<uint64>(k_NumColumns));
args.insertOrAssign(k_NSkipLinesKey, std::make_any<uint64>(k_SkipHeaderLines));
args.insertOrAssign(k_DelimiterChoiceKey, std::make_any<ChoicesParameter::ValueType>(k_Comma));
args.insertOrAssign(k_DataArrayKey, std::make_any<DataPath>(k_ExemplarShiftsPath));
args.insertOrAssign(k_InputFile_Key, std::make_any<FileSystemPathParameter::ValueType>(
fs::path(fmt::format("{}/6_6_align_sections_feature_centroids/6_6_align_sections_feature_centroids.txt", unit_test::k_TestFilesDir))));
args.insertOrAssign(k_ScalarType_Key, std::make_any<NumericTypeParameter::ValueType>(nx::core::NumericType::float32));
args.insertOrAssign(k_NTuples_Key, std::make_any<DynamicTableParameter::ValueType>(k_TupleDims));
args.insertOrAssign(k_NComp_Key, std::make_any<uint64>(k_NumColumns));
args.insertOrAssign(k_NSkipLines_Key, std::make_any<uint64>(k_SkipHeaderLines));
args.insertOrAssign(k_DelimiterChoice_Key, std::make_any<ChoicesParameter::ValueType>(k_Comma));
args.insertOrAssign(k_DataArrayPath_Key, std::make_any<DataPath>(k_ExemplarShiftsPath));

// Preflight the filter and check result
auto preflightResult = filter.preflight(dataStructure, args);
Expand All @@ -118,26 +120,28 @@ TEST_CASE("SimplnxCore::AlignSectionsFeatureCentroidFilter", "[Reconstruction][A

// Read Computed Shifts File
{
static constexpr StringLiteral k_InputFileKey = "input_file";
static constexpr StringLiteral k_ScalarTypeKey = "scalar_type";
static constexpr StringLiteral k_NTuplesKey = "n_tuples";
static constexpr StringLiteral k_NCompKey = "n_comp";
static constexpr StringLiteral k_NSkipLinesKey = "n_skip_lines";
static constexpr StringLiteral k_DelimiterChoiceKey = "delimiter_choice";
static constexpr StringLiteral k_DataArrayKey = "output_data_array";
constexpr StringLiteral k_InputFile_Key = "input_file";
constexpr StringLiteral k_ScalarType_Key = "scalar_type";
constexpr StringLiteral k_NTuples_Key = "number_tuples";
constexpr StringLiteral k_NComp_Key = "number_comp";
constexpr StringLiteral k_NSkipLines_Key = "skip_line_count";
constexpr StringLiteral k_DelimiterChoice_Key = "delimiter_choice";
constexpr StringLiteral k_DataArrayPath_Key = "output_data_array_path";
constexpr StringLiteral k_DataFormat_Key = "data_format";
constexpr StringLiteral k_AdvancedOptions_Key = "advanced_options";

// Compare the output of the shifts file with the exemplar file

ReadTextDataArrayFilter filter;

Arguments args;
args.insertOrAssign(k_InputFileKey, std::make_any<FileSystemPathParameter::ValueType>(computedShiftsFile));
args.insertOrAssign(k_ScalarTypeKey, std::make_any<NumericTypeParameter::ValueType>(nx::core::NumericType::float32));
args.insertOrAssign(k_NTuplesKey, std::make_any<DynamicTableParameter::ValueType>(k_TupleDims));
args.insertOrAssign(k_NCompKey, std::make_any<uint64>(k_NumColumns));
args.insertOrAssign(k_NSkipLinesKey, std::make_any<uint64>(k_SkipHeaderLines));
args.insertOrAssign(k_DelimiterChoiceKey, std::make_any<ChoicesParameter::ValueType>(k_Comma));
args.insertOrAssign(k_DataArrayKey, std::make_any<DataPath>(k_CalculatedShiftsPath));
args.insertOrAssign(k_InputFile_Key, std::make_any<FileSystemPathParameter::ValueType>(computedShiftsFile));
args.insertOrAssign(k_ScalarType_Key, std::make_any<NumericTypeParameter::ValueType>(nx::core::NumericType::float32));
args.insertOrAssign(k_NTuples_Key, std::make_any<DynamicTableParameter::ValueType>(k_TupleDims));
args.insertOrAssign(k_NComp_Key, std::make_any<uint64>(k_NumColumns));
args.insertOrAssign(k_NSkipLines_Key, std::make_any<uint64>(k_SkipHeaderLines));
args.insertOrAssign(k_DelimiterChoice_Key, std::make_any<ChoicesParameter::ValueType>(k_Comma));
args.insertOrAssign(k_DataArrayPath_Key, std::make_any<DataPath>(k_CalculatedShiftsPath));

// Preflight the filter and check result
auto preflightResult = filter.preflight(dataStructure, args);
Expand Down
14 changes: 7 additions & 7 deletions src/Plugins/SimplnxCore/test/CoreFilterTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@ TEST_CASE("CoreFilterTest:RunCoreFilter")
Arguments args;
DataPath dataPath({"foo"});

args.insert("input_file", std::make_any<fs::path>(k_FileName));
args.insert("scalar_type", std::make_any<NumericType>(NumericType::int32));
args.insert("n_tuples", std::make_any<DynamicTableParameter::ValueType>(k_TupleDims));
args.insert("n_comp", std::make_any<uint64>(k_NComp));
args.insert("n_skip_lines", std::make_any<uint64>(k_NSkipLines));
args.insert("delimiter_choice", std::make_any<uint64>(0));
args.insert("output_data_array", std::make_any<DataPath>(dataPath));
args.insert(ReadTextDataArrayFilter::k_InputFile_Key, std::make_any<fs::path>(k_FileName));
args.insert(ReadTextDataArrayFilter::k_ScalarType_Key, std::make_any<NumericType>(NumericType::int32));
args.insert(ReadTextDataArrayFilter::k_NTuples_Key, std::make_any<DynamicTableParameter::ValueType>(k_TupleDims));
args.insert(ReadTextDataArrayFilter::k_NComp_Key, std::make_any<uint64>(k_NComp));
args.insert(ReadTextDataArrayFilter::k_NSkipLines_Key, std::make_any<uint64>(k_NSkipLines));
args.insert(ReadTextDataArrayFilter::k_DelimiterChoice_Key, std::make_any<uint64>(0));
args.insert(ReadTextDataArrayFilter::k_DataArrayPath_Key, std::make_any<DataPath>(dataPath));

// auto callback = [](const IFilter::Message& message) { fmt::print("{}: {}\n", message.type, message.message); };
// Result<> result = filter.execute(dataStructure, args, IFilter::MessageHandler{callback});
Expand Down
2 changes: 1 addition & 1 deletion src/Plugins/SimplnxCore/test/DREAM3DFileTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ Pipeline CreateExportPipeline()

args.insert("tuple_dimensions", DynamicTableInfo::TableDataType{{1.0}});
args.insert("initialization_value", std::make_any<std::string>("7"));
args.insert("output_data_array", DataPath({DataNames::k_ArrayName}));
args.insert("output_array_path", DataPath({DataNames::k_ArrayName}));
args.insert("data_format", std::string(""));
pipeline.push_back(k_CreateDataArrayHandle, args);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1212,7 +1212,7 @@ namespace SmallIn100
inline void ExecuteMultiThresholdObjects(DataStructure& dataStructure, const FilterList& filterList)
{
constexpr StringLiteral k_ArrayThresholds_Key = "array_thresholds";
constexpr StringLiteral k_CreatedDataPath_Key = "created_data_path";
constexpr StringLiteral k_CreatedDataPath_Key = "created_data_array_path";
INFO(fmt::format("Error creating Filter '{}' ", k_MultiThresholdObjectsFilterHandle.getFilterName()));

auto filter = filterList.createFilter(k_MultiThresholdObjectsFilterHandle);
Expand Down

0 comments on commit 2334974

Please sign in to comment.