diff --git a/Makefile b/Makefile index 9b99264..47d0419 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,8 @@ clean: ## Clean up rm -rf build dist *.egg-info if [ -f fimdlp/cfimdlp.cpp ]; then rm fimdlp/cfimdlp.cpp; fi; if [ -f fimdlp/cppfimdlp.cpython-310-darwin.so ]; then rm fimdlp/cppfimdlp.cpython-310-darwin.so; fi; + if [ -d fimdlp/testcpp/build ]; then rm -fr fimdlp/testcpp/build/* ; fi; + if [ -d fimdlp/testcpp/lcoverage ]; then rm -fr fimdlp/testcpp/lcoverage/* ; fi; test: cd fimdlp/testcpp && ./test diff --git a/fimdlp/CPPFImdlp.cpp b/fimdlp/CPPFImdlp.cpp index 4b415c6..b7ae995 100644 --- a/fimdlp/CPPFImdlp.cpp +++ b/fimdlp/CPPFImdlp.cpp @@ -267,8 +267,4 @@ namespace mdlp { { cutPoints = cutPoints_; } - indices_t CPPFImdlp::getIndices() - { - return indices; - } } diff --git a/fimdlp/cppfimdlp.cpython-310-darwin.so b/fimdlp/cppfimdlp.cpython-310-darwin.so index 60cc322..0963e6e 100755 Binary files a/fimdlp/cppfimdlp.cpython-310-darwin.so and b/fimdlp/cppfimdlp.cpython-310-darwin.so differ diff --git a/fimdlp/testcpp/FImdlp_unittest.cc b/fimdlp/testcpp/FImdlp_unittest.cc index e16a47f..df90f23 100644 --- a/fimdlp/testcpp/FImdlp_unittest.cc +++ b/fimdlp/testcpp/FImdlp_unittest.cc @@ -13,6 +13,10 @@ namespace mdlp { y = { 1, 1, 1, 1, 1, 2, 2, 2, 2, 2 }; fit(X, y); } + void setProposal(bool value) + { + proposal = value; + } void initCutPoints() { setCutPoints(cutPoints_t()); @@ -150,4 +154,24 @@ namespace mdlp { computed = getCutPoints(); checkVectors(expected, computed); } + TEST_F(TestFImdlp, Constructor) + { + samples X = { 5.7, 5.3, 5.2, 5.1, 5.0, 5.6, 5.1, 6.0, 5.1, 5.9 }; + labels y = { 1, 1, 1, 1, 1, 2, 2, 2, 2, 2 }; + setProposal(false); + fit(X, y); + computeCutPointsOriginal(); + cutPoints_t expected; + vector computed = getCutPoints(); + expected = { + { 0, 4, -1, -3.4028234663852886e+38, 5.15 }, { 4, 6, -1, 5.15, 5.45 }, + { 6, 10, -1, 5.45, 3.4028234663852886e+38 } + }; + computed = getCutPoints(); + int expectedSize = expected.size(); + EXPECT_EQ(computed.size(), expected.size()); + for (auto i = 0; i < expectedSize; i++) { + EXPECT_NEAR(computed[i], expected[i].toValue, .00000001); + } + } } \ No newline at end of file