From b4bc440872ede253ef45c66f11515e4a214c5403 Mon Sep 17 00:00:00 2001 From: Jan Grewe Date: Sun, 23 May 2021 12:49:43 +0200 Subject: [PATCH 1/5] [data_access] refactor positionAndExtentInData --- include/nix/util/dataAccess.hpp | 12 ++++++------ src/util/dataAccess.cpp | 14 +++++++------- test/BaseTestDataAccess.cpp | 4 ++-- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/include/nix/util/dataAccess.hpp b/include/nix/util/dataAccess.hpp index 935b6b22c..1349b349f 100644 --- a/include/nix/util/dataAccess.hpp +++ b/include/nix/util/dataAccess.hpp @@ -397,23 +397,23 @@ NIXAPI DEPRECATED DataView retrieveData(const Tag &tag, const DataArray &array, /** * @brief Checks whether a given position is in the extent of the given DataArray. * - * @param data The data array. + * @param data_size The extent of the data array. * @param position The position. * * @return True if the position is in the extent of the data array, false otherwise. */ -NIXAPI bool positionInData(const DataArray &data, const NDSize &position); +NIXAPI bool positionInData(const NDSize &data_size, const NDSize &position); /** - * @brief Checks whether a given position plus count is in the extent of the given DataArray. + * @brief Checks whether a given offset plus count is in the extent of the given DataArray. * * @param data The DataArray. - * @param position The position + * @param offset The offset * @param count The number of elements per dimension. * - * @return True if position and count are in the extent of the data array, false otherwise. + * @return True if offset and offset + count are in the extent of the data array, false otherwise. */ -NIXAPI bool positionAndExtentInData(const DataArray &data, const NDSize &position, const NDSize &count); +NIXAPI bool positionAndExtentInData(const DataArray &data, const NDSize &offset, const NDSize &count); /** * @brief Retruns the feature data associated with a Tag. diff --git a/src/util/dataAccess.cpp b/src/util/dataAccess.cpp index f5c71a758..0b18543f8 100644 --- a/src/util/dataAccess.cpp +++ b/src/util/dataAccess.cpp @@ -519,10 +519,8 @@ void getOffsetAndCount(const MultiTag &tag, const DataArray &array, ndsize_t ind } -bool positionInData(const DataArray &data, const NDSize &position) { - NDSize data_size = data.dataExtent(); +bool positionInData(const NDSize &data_size, const NDSize &position) { bool valid = true; - if (!(data_size.size() == position.size())) { return false; } @@ -533,10 +531,12 @@ bool positionInData(const DataArray &data, const NDSize &position) { } -bool positionAndExtentInData(const DataArray &data, const NDSize &position, const NDSize &count) { - NDSize pos = position + count; - pos -= 1; - return positionInData(data, pos); +bool positionAndExtentInData(const DataArray &data, const NDSize &offset, const NDSize &count) { + NDSize end_pos = offset + count; + NDSize data_size = data.dataExtent(); + bool valid = positionInData(data_size, offset); + valid &= positionInData(data_size, end_pos); + return valid; } diff --git a/test/BaseTestDataAccess.cpp b/test/BaseTestDataAccess.cpp index 895258d2e..54b54d49d 100644 --- a/test/BaseTestDataAccess.cpp +++ b/test/BaseTestDataAccess.cpp @@ -317,11 +317,11 @@ void BaseTestDataAccess::testOffsetAndCount() { void BaseTestDataAccess::testPositionInData() { NDSize offsets, counts; util::getOffsetAndCount(multi_tag, data_array, 0, offsets, counts); - CPPUNIT_ASSERT(util::positionInData(data_array, offsets)); + CPPUNIT_ASSERT(util::positionInData(data_array.dataExtent(), offsets)); CPPUNIT_ASSERT(util::positionAndExtentInData(data_array, offsets, counts)); util::getOffsetAndCount(multi_tag, data_array, 1, offsets, counts); - CPPUNIT_ASSERT(util::positionInData(data_array, offsets)); + CPPUNIT_ASSERT(util::positionInData(data_array.dataExtent(), offsets)); CPPUNIT_ASSERT(!util::positionAndExtentInData(data_array, offsets, counts)); } From cee3f712155dab5d206e8fcc5ddc9ee54d24a87a Mon Sep 17 00:00:00 2001 From: Jan Grewe Date: Mon, 9 May 2022 14:01:42 +0200 Subject: [PATCH 2/5] [data access] debug code --- include/nix/DataView.hpp | 5 ++++- src/Dimensions.cpp | 6 ++++++ src/util/dataAccess.cpp | 24 ++++++++++++++++++++---- test/BaseTestMultiTag.cpp | 1 + 4 files changed, 31 insertions(+), 5 deletions(-) diff --git a/include/nix/DataView.hpp b/include/nix/DataView.hpp index 05e6503af..e4bb4da5f 100644 --- a/include/nix/DataView.hpp +++ b/include/nix/DataView.hpp @@ -19,6 +19,7 @@ class NIXAPI DataView : public DataSet { public: DataView(DataArray da, NDSize count, NDSize offset) : array(std::move(da)), offset(std::move(offset)), count(std::move(count)) { + std::cerr << "\tDataView Constructor " << std::endl; if (this->offset.size() != array.dataExtent().size()) { throw IncompatibleDimensions("DataView offset dimensionality does not match dimensionality of data", "nix::DataView"); @@ -28,7 +29,9 @@ class NIXAPI DataView : public DataSet { } if (this->offset + this->count > array.dataExtent()) { throw OutOfBounds("Trying to create DataView which is out of bounds"); - } + } + std::cerr << "\tDataView Constructor " << std::endl; + } // the DataIO interface implementation diff --git a/src/Dimensions.cpp b/src/Dimensions.cpp index f86220084..fbebf3bc1 100644 --- a/src/Dimensions.cpp +++ b/src/Dimensions.cpp @@ -665,8 +665,11 @@ boost::optional> RangeDimension::indexOf(double st PositionMatch endMatching = (match == RangeMatch::Inclusive) ? PositionMatch::LessOrEqual : PositionMatch::Less; boost::optional ei = getIndex(end, ticks, endMatching); if (ei && *si <= *ei) { + std::cerr << *si << " " << *ei << std::endl; range = std::pair(*si, *ei); } + if (!ei) + std::cerr << "\t Returning empty range!\n"; return range; } @@ -722,6 +725,9 @@ std::vector>> RangeDimension::inde for (size_t i = 0; i < start_positions.size(); ++i) { boost::optional> range; range = this->indexOf(start_positions[i], end_positions[i], ticks, match); + std::cerr << "\t" << start_positions[i] << ", " << end_positions[i] << std::endl; + if (range) + std::cerr << "\t" << range->first << ", " << range->second << std::endl; indices.push_back(range); } return indices; diff --git a/src/util/dataAccess.cpp b/src/util/dataAccess.cpp index 0b18543f8..f49768fae 100644 --- a/src/util/dataAccess.cpp +++ b/src/util/dataAccess.cpp @@ -72,6 +72,7 @@ vector>> positionToIndex(const vector RangeDimension dim; dim = dimension; indices = positionToIndex(start_positions, end_positions, units, range_matching, dim); + std::cerr << "\tposition_to_index::RangeDim" << std::endl; } return indices; } @@ -150,6 +151,7 @@ vector>> positionToIndex(const vector vector scaled_end(count); string dim_unit = dimension.unit() ? *dimension.unit() : "none"; scalePositions(start_positions, end_positions, units, dim_unit, scaled_start, scaled_end); + std::cerr << "\trange match " << (range_matching == RangeMatch::Exclusive) << std::endl; return dimension.indexOf(scaled_start, scaled_end, range_matching); } @@ -482,30 +484,38 @@ void getOffsetAndCount(const MultiTag &tag, const DataArray &array, const vector vector temp_units(start_positions[dim_index].size(), units[dim_index]); vector>> ranges = positionToIndex(start_positions[dim_index], end_positions[dim_index], temp_units, match, dimensions[dim_index]); - + data_indices.push_back(ranges); } + std::cerr << "\nping!! dataaccess 490" << std::endl; // at this point we do have all the start and end indices of the tagged positions that the caller wants the data of. // data_indices contains for each dimension a vector of optionals, one for each position index for (size_t i = 0; i < indices.size(); ++i) { // for each of the requested positions + std::cerr << "\tposition: " << i << std::endl; NDSize data_offset(dimcount_sizet, 0); NDSize data_count(dimcount_sizet, 1); for (size_t dim_index =0; dim_index < dimensions.size(); ++dim_index) { // for each dimension optional> opt_range = data_indices[dim_index][i]; + std::cerr << "\topt range is valid: " << (opt_range.is_initialized()) << std::endl; if (opt_range) { data_offset[dim_index] = (*opt_range).first; ndsize_t count = (*opt_range).second - (*opt_range).first; data_count[dim_index] += count; + std::cerr << count << std::endl; } else { + data_count[dim_index] = 0; if (end_positions[dim_index][i] == start_positions[dim_index][i]) { + std::cerr << "\topt range is invalid: " << std::endl; optional ofst = positionToIndex(end_positions[dim_index][i], units[dim_index], PositionMatch::GreaterOrEqual, dimensions[dim_index]); if (!ofst) { throw nix::OutOfBounds("util::offsetAndCount:An invalid range was encountered!"); } - temp_offset[i] = *ofst; + temp_offset[i] = *ofst; // I do not remeber what this might be good for... } } } + std::cerr << "\tsetting offset and count: " << data_offset << "\t" << data_count < taggedData(const MultiTag &tag, vector &position_indi vector counts, offsets; vector views; + // if no positions are given, we will return dataviews for all positions if (position_indices.size() < 1) { size_t pos_count = check::fits_in_size_t(tag.positions().dataExtent()[0], "Number of positions > size_t."); @@ -683,12 +694,17 @@ vector taggedData(const MultiTag &tag, vector &position_indi } getOffsetAndCount(tag, array, position_indices, offsets, counts, match); - + std::cerr << "taggedData 697" << offsets[0] << counts[0] << std::endl; for (size_t i = 0; i < offsets.size(); ++i) { + std::cerr << "\tcheck posistion and extents " << std::endl; + if (!positionAndExtentInData(array, offsets[i], counts[i])) { - throw OutOfBounds("References data slice out of the extent of the DataArray!", 0); + std::cerr << "\tFail! " << std::endl; + + //throw OutOfBounds("Referenced data slice out of the extent of the DataArray!", 0); } DataView io = DataView(array, counts[i], offsets[i]); + std::cerr << "ping survived until here!" << std::endl; views.push_back(io); } return views; diff --git a/test/BaseTestMultiTag.cpp b/test/BaseTestMultiTag.cpp index 2d9beeaff..b884e8648 100644 --- a/test/BaseTestMultiTag.cpp +++ b/test/BaseTestMultiTag.cpp @@ -380,6 +380,7 @@ void BaseTestMultiTag::testDataAccess() { DataView ret_data = multi_tag.taggedData(0, 0); NDSize data_size = ret_data.dataExtent(); CPPUNIT_ASSERT(data_size.size() == 3); + std::cerr << ret_data.dataExtent() << std::endl; CPPUNIT_ASSERT(data_size[0] == 1 && data_size[1] == 6 && data_size[2] == 2); ret_data = multi_tag.taggedData(0, data_array.name()); From f1c03cddd4f45443c718ba3bb6a9a68f8849e5a4 Mon Sep 17 00:00:00 2001 From: Jan Grewe Date: Sat, 14 May 2022 14:27:02 +0200 Subject: [PATCH 3/5] [dimensions] more tests for dimensions --- test/BaseTestDataAccess.cpp | 19 +++++++++++++------ test/BaseTestDimension.cpp | 7 ++++++- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/test/BaseTestDataAccess.cpp b/test/BaseTestDataAccess.cpp index 54b54d49d..9c38c8f26 100644 --- a/test/BaseTestDataAccess.cpp +++ b/test/BaseTestDataAccess.cpp @@ -198,7 +198,8 @@ void BaseTestDataAccess::testPositionToIndexSetDimension() { CPPUNIT_ASSERT_THROW(util::positionToIndex({5.0, 0.}, {10.5}, RangeMatch::Inclusive, setDim), std::runtime_error); - vector>> ranges = util::positionToIndex({5.0, 0.}, {10.5, 1.0}, RangeMatch::Inclusive, setDim); + vector>> ranges; + ranges = util::positionToIndex({5.0, 0.}, {10.5, 1.0}, RangeMatch::Inclusive, setDim); CPPUNIT_ASSERT(ranges.size() == 2); CPPUNIT_ASSERT(!ranges[0]); CPPUNIT_ASSERT(ranges[1] && (*ranges[1]).first == 0 && (*ranges[1]).second == 1); @@ -288,19 +289,18 @@ void BaseTestDataAccess::testOffsetAndCount() { CPPUNIT_ASSERT_THROW(util::getOffsetAndCount(multi_tag, data_array, -1, offsets, counts), nix::OutOfBounds); // not a valid position index CPPUNIT_ASSERT_THROW(util::getOffsetAndCount(multi_tag, data_array, 3, offsets, counts), nix::OutOfBounds); // not a valid position index - util::getOffsetAndCount(multi_tag, data_array, 0, offsets, counts); + util::getOffsetAndCount(multi_tag, data_array, 0, offsets, counts, RangeMatch::Inclusive); CPPUNIT_ASSERT(offsets.size() == 4); CPPUNIT_ASSERT(counts.size() == 4); CPPUNIT_ASSERT(offsets[0] == 0 && offsets[1] == 3 && offsets[2] == 2 && offsets[3] == 1); CPPUNIT_ASSERT(counts[0] == 1 && counts[1] == 7 && counts[2] == 2 && counts[3] == 3); - util::getOffsetAndCount(multi_tag, data_array, 0, offsets, counts, RangeMatch::Exclusive); CPPUNIT_ASSERT(offsets.size() == 4); CPPUNIT_ASSERT(counts.size() == 4); CPPUNIT_ASSERT(offsets[0] == 0 && offsets[1] == 3 && offsets[2] == 2 && offsets[3] == 1); - CPPUNIT_ASSERT(counts[0] == 1 && counts[1] == 6 && counts[2] == 2 && counts[3] == 2); + CPPUNIT_ASSERT(counts[0] == 1 && counts[1] == 7 && counts[2] == 2 && counts[3] == 3); - util::getOffsetAndCount(multi_tag, data_array, 1, offsets, counts); + util::getOffsetAndCount(multi_tag, data_array, 1, offsets, counts, RangeMatch::Inclusive); CPPUNIT_ASSERT(offsets.size() == 4); CPPUNIT_ASSERT(counts.size() == 4); CPPUNIT_ASSERT(offsets[0] == 0 && offsets[1] == 8 && offsets[2] == 1 && offsets[3] == 1); @@ -323,6 +323,14 @@ void BaseTestDataAccess::testPositionInData() { util::getOffsetAndCount(multi_tag, data_array, 1, offsets, counts); CPPUNIT_ASSERT(util::positionInData(data_array.dataExtent(), offsets)); CPPUNIT_ASSERT(!util::positionAndExtentInData(data_array, offsets, counts)); + + util::getOffsetAndCount(multi_tag, data_array, 0, offsets, counts, RangeMatch::Exclusive); + CPPUNIT_ASSERT(util::positionInData(data_array.dataExtent(), offsets)); + CPPUNIT_ASSERT(util::positionAndExtentInData(data_array, offsets, counts)); + + util::getOffsetAndCount(multi_tag, data_array, 1, offsets, counts, RangeMatch::Exclusive); + CPPUNIT_ASSERT(util::positionInData(data_array.dataExtent(), offsets)); + CPPUNIT_ASSERT(!util::positionAndExtentInData(data_array, offsets, counts)); } @@ -454,7 +462,6 @@ void BaseTestDataAccess::testMultiTagFeatureData() { } } index_data.setData(data1); - DataArray tagged_data = block.createDataArray("tagged feature data", "test", nix::DataType::Double, {10, 20, 10, 10}); dim1 = tagged_data.appendSampledDimension(1.0); dim1.unit("ms"); diff --git a/test/BaseTestDimension.cpp b/test/BaseTestDimension.cpp index cd19a866e..644d4d62c 100644 --- a/test/BaseTestDimension.cpp +++ b/test/BaseTestDimension.cpp @@ -661,7 +661,7 @@ void BaseTestDimension::testRangeDimUnit() { std::vector ticks; for (size_t i = 0; i < 5; i++) { - ticks.push_back(i * boost::math::constants::pi()); + ticks.push_back(i * boost::math::constants::pi()); } Dimension d = data_array.appendRangeDimension(ticks); CPPUNIT_ASSERT(d.dimensionType() == DimensionType::Range); @@ -822,6 +822,11 @@ void BaseTestDimension::testRangeDimIndexOf() { CPPUNIT_ASSERT(!range); range = rd.indexOf(100., -100., {}, RangeMatch::Exclusive); CPPUNIT_ASSERT(!range); + range = rd.indexOf(-100., -100, {}, RangeMatch::Inclusive); + CPPUNIT_ASSERT(range); + CPPUNIT_ASSERT(range && (*range).first == 0 && (*range).second == 0); + range = rd.indexOf(-100., -100, {}, RangeMatch::Exclusive); + CPPUNIT_ASSERT(!range); range = rd.indexOf(100., -100., rd.ticks(), RangeMatch::Exclusive); CPPUNIT_ASSERT(!range); From 120dad7c1428fe8999dd76b901d378f0a23fe3a3 Mon Sep 17 00:00:00 2001 From: Jan Grewe Date: Sat, 14 May 2022 14:27:08 +0200 Subject: [PATCH 4/5] [Dimensions/dataaccess] delegate range matching handling to dataAccess methods --- src/Dimensions.cpp | 29 +++++++++++++---------------- src/util/dataAccess.cpp | 35 +++++++++++++++-------------------- 2 files changed, 28 insertions(+), 36 deletions(-) diff --git a/src/Dimensions.cpp b/src/Dimensions.cpp index fbebf3bc1..c6ed758b9 100644 --- a/src/Dimensions.cpp +++ b/src/Dimensions.cpp @@ -263,14 +263,15 @@ boost::optional> SampledDimension::indexOf(const d boost::optional> SampledDimension::indexOf(double start, double end, const double sampling_interval, const double offset, const RangeMatch match) const { boost::optional> indices; - PositionMatch pos_match = match == RangeMatch::Inclusive ? PositionMatch::LessOrEqual : PositionMatch::Less; - if (start > end) { return indices; } + PositionMatch end_matching; + end_matching = (match == RangeMatch::Inclusive) ? PositionMatch::LessOrEqual : PositionMatch::Less; + boost::optional si = getSampledIndex(start, offset, sampling_interval, PositionMatch::GreaterOrEqual); - boost::optional ei = getSampledIndex(end, offset, sampling_interval, pos_match); - + boost::optional ei = getSampledIndex(end, offset, sampling_interval, end_matching); + if (si && ei && *si <= *ei) { indices = std::pair(*si, *ei); } @@ -453,10 +454,12 @@ boost::optional> SetDimension::indexOf(double star if (start > end) { return index; } - PositionMatch end_match = match == RangeMatch::Inclusive ? PositionMatch::LessOrEqual : PositionMatch::Less; - + PositionMatch end_matching; + end_matching = (match == RangeMatch::Inclusive) ? PositionMatch::LessOrEqual : PositionMatch::Less; + boost::optional si = getSetIndex(start, set_labels, PositionMatch::GreaterOrEqual); - boost::optional ei = getSetIndex(end, set_labels, end_match); + boost::optional ei = getSetIndex(end, set_labels, end_matching); + if (si && ei && *si <= *ei) { index = std::pair(*si, *ei); } @@ -662,14 +665,12 @@ boost::optional> RangeDimension::indexOf(double st if (!si) { return range; } - PositionMatch endMatching = (match == RangeMatch::Inclusive) ? PositionMatch::LessOrEqual : PositionMatch::Less; - boost::optional ei = getIndex(end, ticks, endMatching); + PositionMatch end_matching; + end_matching = (match == RangeMatch::Inclusive) ? PositionMatch::LessOrEqual : PositionMatch::Less; + boost::optional ei = getIndex(end, ticks, end_matching); if (ei && *si <= *ei) { - std::cerr << *si << " " << *ei << std::endl; range = std::pair(*si, *ei); } - if (!ei) - std::cerr << "\t Returning empty range!\n"; return range; } @@ -719,15 +720,11 @@ std::vector>> RangeDimension::inde if (start_positions.size() != end_positions.size()) { throw runtime_error("Dimension::IndexOf - Number of start and end positions must match!"); } - std::vector>> indices; vector ticks = this->ticks(); for (size_t i = 0; i < start_positions.size(); ++i) { boost::optional> range; range = this->indexOf(start_positions[i], end_positions[i], ticks, match); - std::cerr << "\t" << start_positions[i] << ", " << end_positions[i] << std::endl; - if (range) - std::cerr << "\t" << range->first << ", " << range->second << std::endl; indices.push_back(range); } return indices; diff --git a/src/util/dataAccess.cpp b/src/util/dataAccess.cpp index f49768fae..b897fc016 100644 --- a/src/util/dataAccess.cpp +++ b/src/util/dataAccess.cpp @@ -72,7 +72,6 @@ vector>> positionToIndex(const vector RangeDimension dim; dim = dimension; indices = positionToIndex(start_positions, end_positions, units, range_matching, dim); - std::cerr << "\tposition_to_index::RangeDim" << std::endl; } return indices; } @@ -151,7 +150,6 @@ vector>> positionToIndex(const vector vector scaled_end(count); string dim_unit = dimension.unit() ? *dimension.unit() : "none"; scalePositions(start_positions, end_positions, units, dim_unit, scaled_start, scaled_end); - std::cerr << "\trange match " << (range_matching == RangeMatch::Exclusive) << std::endl; return dimension.indexOf(scaled_start, scaled_end, range_matching); } @@ -482,39 +480,40 @@ void getOffsetAndCount(const MultiTag &tag, const DataArray &array, const vector vector>>> data_indices; for (size_t dim_index = 0; dim_index < dimensions.size(); ++dim_index) { vector temp_units(start_positions[dim_index].size(), units[dim_index]); - vector>> ranges = positionToIndex(start_positions[dim_index], end_positions[dim_index], - temp_units, match, dimensions[dim_index]); + vector>> ranges; + RangeMatch rm; // The range match needs to be adjusted if the extent is 0.0 in that case we want have an inclusive matching + if (start_positions[dim_index] == end_positions[dim_index]) { + rm = RangeMatch::Inclusive; + } else { + rm = match; + } + ranges = positionToIndex(start_positions[dim_index], end_positions[dim_index], + temp_units, rm, dimensions[dim_index]); data_indices.push_back(ranges); } - std::cerr << "\nping!! dataaccess 490" << std::endl; // at this point we do have all the start and end indices of the tagged positions that the caller wants the data of. // data_indices contains for each dimension a vector of optionals, one for each position index for (size_t i = 0; i < indices.size(); ++i) { // for each of the requested positions - std::cerr << "\tposition: " << i << std::endl; NDSize data_offset(dimcount_sizet, 0); NDSize data_count(dimcount_sizet, 1); for (size_t dim_index =0; dim_index < dimensions.size(); ++dim_index) { // for each dimension optional> opt_range = data_indices[dim_index][i]; - std::cerr << "\topt range is valid: " << (opt_range.is_initialized()) << std::endl; if (opt_range) { data_offset[dim_index] = (*opt_range).first; ndsize_t count = (*opt_range).second - (*opt_range).first; data_count[dim_index] += count; - std::cerr << count << std::endl; } else { data_count[dim_index] = 0; if (end_positions[dim_index][i] == start_positions[dim_index][i]) { - std::cerr << "\topt range is invalid: " << std::endl; optional ofst = positionToIndex(end_positions[dim_index][i], units[dim_index], PositionMatch::GreaterOrEqual, dimensions[dim_index]); if (!ofst) { throw nix::OutOfBounds("util::offsetAndCount:An invalid range was encountered!"); } - temp_offset[i] = *ofst; // I do not remeber what this might be good for... + temp_offset[i] = *ofst; // I do not remember what this might be good for... } } } - std::cerr << "\tsetting offset and count: " << data_offset << "\t" << data_count < taggedData(const MultiTag &tag, vector &position_indi } getOffsetAndCount(tag, array, position_indices, offsets, counts, match); - std::cerr << "taggedData 697" << offsets[0] << counts[0] << std::endl; for (size_t i = 0; i < offsets.size(); ++i) { - std::cerr << "\tcheck posistion and extents " << std::endl; - - if (!positionAndExtentInData(array, offsets[i], counts[i])) { - std::cerr << "\tFail! " << std::endl; - - //throw OutOfBounds("Referenced data slice out of the extent of the DataArray!", 0); + /* + if (!positionAndExtentInData(array, offsets[i], counts[i])) { + throw OutOfBounds("Referenced data slice out of the extent of the DataArray!", 0); } + */ DataView io = DataView(array, counts[i], offsets[i]); - std::cerr << "ping survived until here!" << std::endl; views.push_back(io); } return views; From 0f41b27fb9717f262063af73087864fda26c3aa8 Mon Sep 17 00:00:00 2001 From: Jan Grewe Date: Wed, 25 May 2022 10:29:00 +0200 Subject: [PATCH 5/5] [cleanup] remove cerr and commnets --- include/nix/DataView.hpp | 6 +----- src/util/dataAccess.cpp | 5 ----- test/BaseTestMultiTag.cpp | 1 - 3 files changed, 1 insertion(+), 11 deletions(-) diff --git a/include/nix/DataView.hpp b/include/nix/DataView.hpp index e4bb4da5f..63586078f 100644 --- a/include/nix/DataView.hpp +++ b/include/nix/DataView.hpp @@ -19,8 +19,6 @@ class NIXAPI DataView : public DataSet { public: DataView(DataArray da, NDSize count, NDSize offset) : array(std::move(da)), offset(std::move(offset)), count(std::move(count)) { - std::cerr << "\tDataView Constructor " << std::endl; - if (this->offset.size() != array.dataExtent().size()) { throw IncompatibleDimensions("DataView offset dimensionality does not match dimensionality of data", "nix::DataView"); } @@ -30,8 +28,6 @@ class NIXAPI DataView : public DataSet { if (this->offset + this->count > array.dataExtent()) { throw OutOfBounds("Trying to create DataView which is out of bounds"); } - std::cerr << "\tDataView Constructor " << std::endl; - } // the DataIO interface implementation @@ -62,4 +58,4 @@ class NIXAPI DataView : public DataSet { } // nix:: -#endif // DATA_VIEW_HPP \ No newline at end of file +#endif // DATA_VIEW_HPP diff --git a/src/util/dataAccess.cpp b/src/util/dataAccess.cpp index b897fc016..b0df91c6d 100644 --- a/src/util/dataAccess.cpp +++ b/src/util/dataAccess.cpp @@ -694,11 +694,6 @@ vector taggedData(const MultiTag &tag, vector &position_indi getOffsetAndCount(tag, array, position_indices, offsets, counts, match); for (size_t i = 0; i < offsets.size(); ++i) { - /* - if (!positionAndExtentInData(array, offsets[i], counts[i])) { - throw OutOfBounds("Referenced data slice out of the extent of the DataArray!", 0); - } - */ DataView io = DataView(array, counts[i], offsets[i]); views.push_back(io); } diff --git a/test/BaseTestMultiTag.cpp b/test/BaseTestMultiTag.cpp index b884e8648..2d9beeaff 100644 --- a/test/BaseTestMultiTag.cpp +++ b/test/BaseTestMultiTag.cpp @@ -380,7 +380,6 @@ void BaseTestMultiTag::testDataAccess() { DataView ret_data = multi_tag.taggedData(0, 0); NDSize data_size = ret_data.dataExtent(); CPPUNIT_ASSERT(data_size.size() == 3); - std::cerr << ret_data.dataExtent() << std::endl; CPPUNIT_ASSERT(data_size[0] == 1 && data_size[1] == 6 && data_size[2] == 2); ret_data = multi_tag.taggedData(0, data_array.name());