diff --git a/.github/workflows/flucoma-core-ci.yml b/.github/workflows/flucoma-core-ci.yml index 818674a6..0209e8bc 100644 --- a/.github/workflows/flucoma-core-ci.yml +++ b/.github/workflows/flucoma-core-ci.yml @@ -15,7 +15,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-22.04, windows-latest, macOS-latest] + os: [windows-latest] fail-fast: false steps: diff --git a/include/flucoma/data/FluidTensor.hpp b/include/flucoma/data/FluidTensor.hpp index 0b437df0..6231ab47 100644 --- a/include/flucoma/data/FluidTensor.hpp +++ b/include/flucoma/data/FluidTensor.hpp @@ -105,7 +105,27 @@ class FluidTensor //: public FluidTensorBase { static_assert(std::is_convertible::value, "Cannot convert between container value types"); - std::copy(x.begin(), x.end(), mContainer.begin()); + + std::cout << "========== CONVERTER ===============\n"; + for(auto& p: x) std::cout << p << ','; + std::cout << "\n==================================\n"; + std::cout << "========== X ================\n"; + std::cout << x; + std::cout << "\n==================================\n"; + // std::copy(x.begin(), x.end(), mContainer.begin()); + // std::transform(x.begin(), x.end(),mContainer.begin(),[](U in)->T + // { + // return static_cast(in); + // }); + *this = x; + + std::cout << "========== MI CONTAINTER ================\n"; + for(auto& p: mContainer) std::cout << p << ','; + std::cout << "\n==================================\n"; + std::cout << "========== MEEE ================\n"; + std::cout << *this; + std::cout << "\n==================================\n"; + } template @@ -164,6 +184,10 @@ class FluidTensor //: public FluidTensorBase mContainer.reserve(asUnsigned(this->mDesc.size)); impl::insertFlat(init, mContainer); assert(mContainer.size() == asUnsigned(this->mDesc.size)); + std::cout << "checking assert condition\n"; + std::cout << (mContainer.size() == asUnsigned(this->mDesc.size)) << '\n'; + std::cout << "Look inside...\n" << *this; + } template diff --git a/include/flucoma/data/FluidTensor_Support.hpp b/include/flucoma/data/FluidTensor_Support.hpp index c1e69419..a63ed3fe 100644 --- a/include/flucoma/data/FluidTensor_Support.hpp +++ b/include/flucoma/data/FluidTensor_Support.hpp @@ -128,10 +128,20 @@ std::array deriveExtents(const List& list) /// addList and insertFlat populate our container with the contents of /// a nested initializer list structure. -template // terminate -void addList(const T* first, const T* last, Vec& vec) +template // terminate +void addList(InputIter first, InputIter last, Vec& vec) { + + InputIter dum = first; + std::cout << "================Pre Insert===============\n"; + for(;dum!=last; ++dum) std::cout << *dum << ','; + std::cout << '\n'; + vec.insert(vec.end(), first, last); + + std::cout << "================Post Insert===============\n"; + for(const auto& x: vec) std::cout << x << ','; + std::cout << "\n==========================================\n"; } template // recurse diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 394a389a..f69e1c61 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -93,60 +93,60 @@ endfunction() add_test_executable(TestFluidTensor data/TestFluidTensor.cpp) add_test_executable(TestFluidTensorDeath data/death_tests/TestFluidTensorAsserts.cpp) -target_link_libraries(TestFluidTensorDeath PRIVATE - $ -) +# target_link_libraries(TestFluidTensorDeath PRIVATE +# $ +# ) -add_test_executable(TestFluidTensorView data/TestFluidTensorView.cpp) -add_test_executable(TestFluidTensorSupport data/TestFluidTensorSupport.cpp) -add_test_executable(TestFluidDataSet data/TestFluidDataSet.cpp) -add_test_executable(TestFluidSource clients/common/TestFluidSource.cpp) -add_test_executable(TestFluidSink clients/common/TestFluidSink.cpp) -add_test_executable(TestBufferedProcess clients/common/TestBufferedProcess.cpp) +# add_test_executable(TestFluidTensorView data/TestFluidTensorView.cpp) +# add_test_executable(TestFluidTensorSupport data/TestFluidTensorSupport.cpp) +# add_test_executable(TestFluidDataSet data/TestFluidDataSet.cpp) +# add_test_executable(TestFluidSource clients/common/TestFluidSource.cpp) +# add_test_executable(TestFluidSink clients/common/TestFluidSink.cpp) +# add_test_executable(TestBufferedProcess clients/common/TestBufferedProcess.cpp) -add_test_executable(TestNoveltySeg - algorithms/public/TestNoveltySegmentation.cpp -) -add_test_executable(TestOnsetSeg algorithms/public/TestOnsetSegmentation.cpp) -add_test_executable(TestEnvelopeSeg algorithms/public/TestEnvelopeSegmentation.cpp) +# add_test_executable(TestNoveltySeg +# algorithms/public/TestNoveltySegmentation.cpp +# ) +# add_test_executable(TestOnsetSeg algorithms/public/TestOnsetSegmentation.cpp) +# add_test_executable(TestEnvelopeSeg algorithms/public/TestEnvelopeSegmentation.cpp) -add_test_executable(TestEnvelopeGate algorithms/public/TestEnvelopeGate.cpp) +# add_test_executable(TestEnvelopeGate algorithms/public/TestEnvelopeGate.cpp) -add_test_executable(TestTransientSlice algorithms/public/TestTransientSlice.cpp) +# add_test_executable(TestTransientSlice algorithms/public/TestTransientSlice.cpp) -add_test_executable(TestMLP algorithms/public/TestMLP.cpp) -add_test_executable(TestKMeans algorithms/public/TestKMeans.cpp) +# add_test_executable(TestMLP algorithms/public/TestMLP.cpp) +# add_test_executable(TestKMeans algorithms/public/TestKMeans.cpp) -target_link_libraries(TestNoveltySeg PRIVATE TestSignals) -target_link_libraries(TestOnsetSeg PRIVATE TestSignals) -target_link_libraries(TestEnvelopeSeg PRIVATE TestSignals) -target_link_libraries(TestEnvelopeGate PRIVATE TestSignals) -target_link_libraries(TestTransientSlice PRIVATE TestSignals) +# target_link_libraries(TestNoveltySeg PRIVATE TestSignals) +# target_link_libraries(TestOnsetSeg PRIVATE TestSignals) +# target_link_libraries(TestEnvelopeSeg PRIVATE TestSignals) +# target_link_libraries(TestEnvelopeGate PRIVATE TestSignals) +# target_link_libraries(TestTransientSlice PRIVATE TestSignals) include(CTest) include(Catch) catch_discover_tests(TestFluidTensor WORKING_DIRECTORY "${CMAKE_BINARY_DIR}") -catch_discover_tests(TestFluidTensorDeath - WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" - PROPERTIES WILL_FAIL true -) +# catch_discover_tests(TestFluidTensorDeath +# WORKING_DIRECTORY "${CMAKE_BINARY_DIR}" +# PROPERTIES WILL_FAIL true +# ) -catch_discover_tests(TestFluidTensorView WORKING_DIRECTORY "${CMAKE_BINARY_DIR}") -catch_discover_tests(TestFluidTensorSupport WORKING_DIRECTORY "${CMAKE_BINARY_DIR}") -catch_discover_tests(TestFluidDataSet WORKING_DIRECTORY "${CMAKE_BINARY_DIR}") +# catch_discover_tests(TestFluidTensorView WORKING_DIRECTORY "${CMAKE_BINARY_DIR}") +# catch_discover_tests(TestFluidTensorSupport WORKING_DIRECTORY "${CMAKE_BINARY_DIR}") +# catch_discover_tests(TestFluidDataSet WORKING_DIRECTORY "${CMAKE_BINARY_DIR}") -catch_discover_tests(TestNoveltySeg WORKING_DIRECTORY "${CMAKE_BINARY_DIR}") -catch_discover_tests(TestOnsetSeg WORKING_DIRECTORY "${CMAKE_BINARY_DIR}") -catch_discover_tests(TestEnvelopeSeg WORKING_DIRECTORY "${CMAKE_BINARY_DIR}") -catch_discover_tests(TestEnvelopeGate WORKING_DIRECTORY "${CMAKE_BINARY_DIR}") -catch_discover_tests(TestTransientSlice WORKING_DIRECTORY "${CMAKE_BINARY_DIR}") +# catch_discover_tests(TestNoveltySeg WORKING_DIRECTORY "${CMAKE_BINARY_DIR}") +# catch_discover_tests(TestOnsetSeg WORKING_DIRECTORY "${CMAKE_BINARY_DIR}") +# catch_discover_tests(TestEnvelopeSeg WORKING_DIRECTORY "${CMAKE_BINARY_DIR}") +# catch_discover_tests(TestEnvelopeGate WORKING_DIRECTORY "${CMAKE_BINARY_DIR}") +# catch_discover_tests(TestTransientSlice WORKING_DIRECTORY "${CMAKE_BINARY_DIR}") -catch_discover_tests(TestFluidSource WORKING_DIRECTORY "${CMAKE_BINARY_DIR}") -catch_discover_tests(TestFluidSink WORKING_DIRECTORY "${CMAKE_BINARY_DIR}") -catch_discover_tests(TestBufferedProcess WORKING_DIRECTORY "${CMAKE_BINARY_DIR}") +# catch_discover_tests(TestFluidSource WORKING_DIRECTORY "${CMAKE_BINARY_DIR}") +# catch_discover_tests(TestFluidSink WORKING_DIRECTORY "${CMAKE_BINARY_DIR}") +# catch_discover_tests(TestBufferedProcess WORKING_DIRECTORY "${CMAKE_BINARY_DIR}") -catch_discover_tests(TestMLP WORKING_DIRECTORY "${CMAKE_BINARY_DIR}") +# catch_discover_tests(TestMLP WORKING_DIRECTORY "${CMAKE_BINARY_DIR}") -add_compile_tests("FluidTensor Compilation Tests" data/compile_tests/TestFluidTensor_Compile.cpp) +# add_compile_tests("FluidTensor Compilation Tests" data/compile_tests/TestFluidTensor_Compile.cpp) diff --git a/tests/data/TestFluidTensor.cpp b/tests/data/TestFluidTensor.cpp index 3c59fe3c..1975f80b 100644 --- a/tests/data/TestFluidTensor.cpp +++ b/tests/data/TestFluidTensor.cpp @@ -13,118 +13,118 @@ using fluid::FluidTensorView; using fluid::Slice; -TEST_CASE("FluidTensor can be created from a list of dimenions","[FluidTensor]"){ +// TEST_CASE("FluidTensor can be created from a list of dimenions","[FluidTensor]"){ - SECTION("1D creation reports correct sizes"){ - const FluidTensor x(3); +// SECTION("1D creation reports correct sizes"){ +// const FluidTensor x(3); - REQUIRE(x.size() == 3); - REQUIRE(x.rows() == 3); - // REQUIRE(x.cols() == 1); - REQUIRE(std::distance(x.begin(),x.end()) == x.size()); - } - SECTION("2D creation reports correct sizes"){ - const FluidTensor x(3,2); +// REQUIRE(x.size() == 3); +// REQUIRE(x.rows() == 3); +// // REQUIRE(x.cols() == 1); +// REQUIRE(std::distance(x.begin(),x.end()) == x.size()); +// } +// SECTION("2D creation reports correct sizes"){ +// const FluidTensor x(3,2); - REQUIRE(x.size() == (3 * 2)); - REQUIRE(x.rows() == 3); - REQUIRE(x.cols() == 2); - REQUIRE(std::distance(x.begin(),x.end()) == x.size()); - } - SECTION("3D creation reports correct sizes"){ - const FluidTensor x(3,2,5); +// REQUIRE(x.size() == (3 * 2)); +// REQUIRE(x.rows() == 3); +// REQUIRE(x.cols() == 2); +// REQUIRE(std::distance(x.begin(),x.end()) == x.size()); +// } +// SECTION("3D creation reports correct sizes"){ +// const FluidTensor x(3,2,5); - REQUIRE(x.size() == (3 * 2 * 5)); - REQUIRE(x.rows() == 3); - REQUIRE(x.cols() == 2); - REQUIRE(x.descriptor().extents[2] == 5); - REQUIRE(std::distance(x.begin(),x.end()) == x.size()); - } -} - -TEST_CASE("FluidTensor can be initialized from initializer lists","[FluidTensor]"){ - - const std::array y{0,1,2,3,4}; - std::array y1; - std::transform(y.begin(), y.end(),y1.begin(),[](int x){ return x + 5; }); +// REQUIRE(x.size() == (3 * 2 * 5)); +// REQUIRE(x.rows() == 3); +// REQUIRE(x.cols() == 2); +// REQUIRE(x.descriptor().extents[2] == 5); +// REQUIRE(std::distance(x.begin(),x.end()) == x.size()); +// } +// } + +// TEST_CASE("FluidTensor can be initialized from initializer lists","[FluidTensor]"){ + +// const std::array y{0,1,2,3,4}; +// std::array y1; +// std::transform(y.begin(), y.end(),y1.begin(),[](int x){ return x + 5; }); - const std::array c{0,5}; - const std::array c1{1,6}; - const std::array c2{2,7}; - const std::array c3{3,8}; - const std::array c4{4,9}; - - SECTION("1D initialization"){ - const FluidTensor x{0, - 1, - 2, - 3, - 4}; - const std::array y{0,1,2,3,4}; - REQUIRE(x.rows() == 5); - REQUIRE(std::distance(x.begin(),x.end()) == x.size()); - REQUIRE_THAT(x,Catch::Matchers::RangeEquals(y)); - } - - SECTION("2D initialization"){ - //@todo I found a bug: you can enter ragged lists and it compiles :-( - // my incliination is to kill this feature - const FluidTensor x{{0,1,2,3,4}, - {5,6,7,8,9}}; - REQUIRE(x.size() == (2 * 5)); - REQUIRE(x.rows() == 2); - REQUIRE(x.cols() == 5); - REQUIRE(std::distance(x.begin(),x.end()) == x.size()); - REQUIRE_THAT(x.row(0),Catch::Matchers::RangeEquals(y)); - REQUIRE_THAT(x.row(1),Catch::Matchers::RangeEquals(y1)); - - REQUIRE_THAT(x.col(0),Catch::Matchers::RangeEquals(c)); - REQUIRE_THAT(x.col(1),Catch::Matchers::RangeEquals(c1)); - REQUIRE_THAT(x.col(2),Catch::Matchers::RangeEquals(c2)); - REQUIRE_THAT(x.col(3),Catch::Matchers::RangeEquals(c3)); - REQUIRE_THAT(x.col(4),Catch::Matchers::RangeEquals(c4)); - } -} - -TEST_CASE("FluidTensor data can be accessed by index and by slice","[FluidTensor]"){ - - const FluidTensor x{{0,1,2,3,4},{5,6,7,8,9}}; - - SECTION("Index Access"){ - for(int i = 0; i < 2; ++i) - for(int j = 0; j < 5; ++j) - CHECK(x(i,j) == (i * 5) + j); - } - - SECTION("Slice Access"){ - //cols - for(int i = 0; i < 5; ++i) - { - const auto y = x(Slice(0),i); - const std::array z = {i, i + 5}; - CHECK(y.size() == 2); - CHECK_THAT(y, Catch::Matchers::RangeEquals(z)); - } - - //rows - for(int i = 0; i < 2; ++i) - { - const auto y = x(i,Slice(0)); - const std::array z = {(i * 5), (i * 5) + 1, (i * 5) + 2, (i * 5) + 3, (i * 5) + 4}; - CHECK(y.size() == 5); - CHECK_THAT(y, Catch::Matchers::RangeEquals(z)); - } - } - - //rectangles - { - const auto y = x(Slice(0,2),Slice(1,2));//both rows, 2 cols offset 1 - const std::array z = {1,2,6,7}; - CHECK(y.size() == 4); - CHECK_THAT(y, Catch::Matchers::RangeEquals(z)); - } - -} +// const std::array c{0,5}; +// const std::array c1{1,6}; +// const std::array c2{2,7}; +// const std::array c3{3,8}; +// const std::array c4{4,9}; + +// SECTION("1D initialization"){ +// const FluidTensor x{0, +// 1, +// 2, +// 3, +// 4}; +// const std::array y{0,1,2,3,4}; +// REQUIRE(x.rows() == 5); +// REQUIRE(std::distance(x.begin(),x.end()) == x.size()); +// REQUIRE_THAT(x,Catch::Matchers::RangeEquals(y)); +// } + +// SECTION("2D initialization"){ +// //@todo I found a bug: you can enter ragged lists and it compiles :-( +// // my incliination is to kill this feature +// const FluidTensor x{{0,1,2,3,4}, +// {5,6,7,8,9}}; +// REQUIRE(x.size() == (2 * 5)); +// REQUIRE(x.rows() == 2); +// REQUIRE(x.cols() == 5); +// REQUIRE(std::distance(x.begin(),x.end()) == x.size()); +// REQUIRE_THAT(x.row(0),Catch::Matchers::RangeEquals(y)); +// REQUIRE_THAT(x.row(1),Catch::Matchers::RangeEquals(y1)); + +// REQUIRE_THAT(x.col(0),Catch::Matchers::RangeEquals(c)); +// REQUIRE_THAT(x.col(1),Catch::Matchers::RangeEquals(c1)); +// REQUIRE_THAT(x.col(2),Catch::Matchers::RangeEquals(c2)); +// REQUIRE_THAT(x.col(3),Catch::Matchers::RangeEquals(c3)); +// REQUIRE_THAT(x.col(4),Catch::Matchers::RangeEquals(c4)); +// } +// } + +// TEST_CASE("FluidTensor data can be accessed by index and by slice","[FluidTensor]"){ + +// const FluidTensor x{{0,1,2,3,4},{5,6,7,8,9}}; + +// SECTION("Index Access"){ +// for(int i = 0; i < 2; ++i) +// for(int j = 0; j < 5; ++j) +// CHECK(x(i,j) == (i * 5) + j); +// } + +// SECTION("Slice Access"){ +// //cols +// for(int i = 0; i < 5; ++i) +// { +// const auto y = x(Slice(0),i); +// const std::array z = {i, i + 5}; +// CHECK(y.size() == 2); +// CHECK_THAT(y, Catch::Matchers::RangeEquals(z)); +// } + +// //rows +// for(int i = 0; i < 2; ++i) +// { +// const auto y = x(i,Slice(0)); +// const std::array z = {(i * 5), (i * 5) + 1, (i * 5) + 2, (i * 5) + 3, (i * 5) + 4}; +// CHECK(y.size() == 5); +// CHECK_THAT(y, Catch::Matchers::RangeEquals(z)); +// } +// } + +// //rectangles +// { +// const auto y = x(Slice(0,2),Slice(1,2));//both rows, 2 cols offset 1 +// const std::array z = {1,2,6,7}; +// CHECK(y.size() == 4); +// CHECK_THAT(y, Catch::Matchers::RangeEquals(z)); +// } + +// } TEST_CASE("FluidTensor can be copied","[FluidTensor]"){ const FluidTensor x{{0,1,2,3,4},{5,6,7,8,9}}; @@ -168,72 +168,72 @@ TEST_CASE("FluidTensor can be copied","[FluidTensor]"){ } } -TEST_CASE("FluidTensor can be moved","[FluidTensor]"){ - FluidTensor x{{0,1,2,3,4},{5,6,7,8,9}}; - SECTION("Move construct") { - const FluidTensor y(FluidTensor{{0,1,2,3,4},{5,6,7,8,9}}); - CHECK(y.size() == x.size()); - CHECK(y.rows() == x.rows()); - CHECK(y.cols() == x.cols()); - CHECK(y.descriptor() == x.descriptor()); - CHECK_THAT(y, Catch::Matchers::RangeEquals(x)); - } +// TEST_CASE("FluidTensor can be moved","[FluidTensor]"){ +// FluidTensor x{{0,1,2,3,4},{5,6,7,8,9}}; +// SECTION("Move construct") { +// const FluidTensor y(FluidTensor{{0,1,2,3,4},{5,6,7,8,9}}); +// CHECK(y.size() == x.size()); +// CHECK(y.rows() == x.rows()); +// CHECK(y.cols() == x.cols()); +// CHECK(y.descriptor() == x.descriptor()); +// CHECK_THAT(y, Catch::Matchers::RangeEquals(x)); +// } - SECTION("Move assign") { - FluidTensor y; - y = FluidTensor{{0,1,2,3,4},{5,6,7,8,9}}; - CHECK(y.size() == x.size()); - CHECK(y.rows() == x.rows()); - CHECK(y.cols() == x.cols()); - CHECK(y.descriptor() == x.descriptor()); - CHECK_THAT(y, Catch::Matchers::RangeEquals(x)); - } -} - -TEST_CASE("FluidTensor can be resized","[FluidTensor]"){ - SECTION("resize gives correct dimensions") - { - FluidTensor x(1,1); - x.resize(3,4); - CHECK(x.size() == (3 * 4)); - CHECK(x.rows() == 3); - CHECK(x.cols() == 4); - } - - SECTION("resize dim correct dimensions") - { - FluidTensor x(1,1); - x.resizeDim(0,2); - x.resizeDim(1,3); - CHECK(x.size() == (3 * 4)); - CHECK(x.rows() == 3); - CHECK(x.cols() == 4); - } - - SECTION("delete row preserves data") - { - FluidTensor x{ - {0,1,2},{3,4,5},{6,7,8} - }; - x.deleteRow(1); - std::array y{0,1,2,6,7,8}; - CHECK(x.size() == 6); - CHECK(x.rows() == 2); - CHECK(x.cols() == 3); - REQUIRE_THAT(x, Catch::Matchers::RangeEquals(y)); - } -} - -TEST_CASE("const FluidTensor returns View(const T)","[FluidTensor]"){ - SECTION("const rows and cols"){ - const FluidTensor x{ - {0,1,2},{3,4,5},{6,7,8} - }; - CHECK(std::is_same>()); - CHECK(std::is_same>()); - CHECK(std::is_same>()); - CHECK(std::is_same>()); - CHECK(std::is_same>()); - CHECK(std::is_same()); - } -} +// SECTION("Move assign") { +// FluidTensor y; +// y = FluidTensor{{0,1,2,3,4},{5,6,7,8,9}}; +// CHECK(y.size() == x.size()); +// CHECK(y.rows() == x.rows()); +// CHECK(y.cols() == x.cols()); +// CHECK(y.descriptor() == x.descriptor()); +// CHECK_THAT(y, Catch::Matchers::RangeEquals(x)); +// } +// } + +// TEST_CASE("FluidTensor can be resized","[FluidTensor]"){ +// SECTION("resize gives correct dimensions") +// { +// FluidTensor x(1,1); +// x.resize(3,4); +// CHECK(x.size() == (3 * 4)); +// CHECK(x.rows() == 3); +// CHECK(x.cols() == 4); +// } + +// SECTION("resize dim correct dimensions") +// { +// FluidTensor x(1,1); +// x.resizeDim(0,2); +// x.resizeDim(1,3); +// CHECK(x.size() == (3 * 4)); +// CHECK(x.rows() == 3); +// CHECK(x.cols() == 4); +// } + +// SECTION("delete row preserves data") +// { +// FluidTensor x{ +// {0,1,2},{3,4,5},{6,7,8} +// }; +// x.deleteRow(1); +// std::array y{0,1,2,6,7,8}; +// CHECK(x.size() == 6); +// CHECK(x.rows() == 2); +// CHECK(x.cols() == 3); +// REQUIRE_THAT(x, Catch::Matchers::RangeEquals(y)); +// } +// } + +// TEST_CASE("const FluidTensor returns View(const T)","[FluidTensor]"){ +// SECTION("const rows and cols"){ +// const FluidTensor x{ +// {0,1,2},{3,4,5},{6,7,8} +// }; +// CHECK(std::is_same>()); +// CHECK(std::is_same>()); +// CHECK(std::is_same>()); +// CHECK(std::is_same>()); +// CHECK(std::is_same>()); +// CHECK(std::is_same()); +// } +// }