Commit 391892a3 authored by Andi Braimllari's avatar Andi Braimllari Committed by David Frank
Browse files

#145 Fix for DataContainer with non-blocked descriptor

parent b0d64ffd
Pipeline #719017 passed with stages
in 11 minutes and 17 seconds
......@@ -386,6 +386,10 @@ namespace elsa
throw LogicError("Trying to access out of bound slice");
}
if (sizeOfLastDim == 1) {
return *this;
}
auto sliceDesc = PartitionDescriptor(desc, sizeOfLastDim);
// Now set the slice
......@@ -403,6 +407,10 @@ namespace elsa
throw LogicError("Trying to access out of bound slice");
}
if (sizeOfLastDim == 1) {
return *this;
}
auto sliceDesc = PartitionDescriptor(desc, sizeOfLastDim);
// Now set the slice
......
......@@ -1272,6 +1272,35 @@ TEST_CASE_TEMPLATE("DataContainer: Slice a DataContainer", data_t, float, double
}
}
}
GIVEN("a 3D DataDescriptor and a 3D random Vector")
{
constexpr index_t size = 28;
constexpr index_t one = 1;
IndexVector_t numCoeff3D(3);
numCoeff3D << size, size, one;
const VolumeDescriptor desc(numCoeff3D);
const Vector_t<data_t> randVec = Vector_t<data_t>::Random(size * size * one);
WHEN("slicing a non-const DataContainer with the size of the last dimension of 1")
{
DataContainer<data_t> dc(desc, randVec);
DataContainer<data_t> res = dc.slice(0);
THEN("the DataContainers match") { REQUIRE_EQ(dc, res); }
}
WHEN("slicing a const DataContainer with the size of the last dimension of 1")
{
const DataContainer<data_t> dc(desc, randVec);
const DataContainer<data_t> res = dc.slice(0);
THEN("the DataContainers match") { REQUIRE_EQ(dc, res); }
}
}
}
// "instantiate" the test templates for CPU types
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment