From 70e22d19d3c8f3a5ec64bbb32b1f353a889abb9c Mon Sep 17 00:00:00 2001 From: "Fernando J. Iglesias Garcia" Date: Mon, 15 Apr 2024 15:34:47 +0200 Subject: [PATCH 1/9] Add explicit definition of copy constructor and others. clang-check warned about depecrated use of implicitly defined copy constructor since copy assignment existed. Rule of Five. --- include/tapkee/defines/methods.hpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/tapkee/defines/methods.hpp b/include/tapkee/defines/methods.hpp index a98ea8d..81a895e 100644 --- a/include/tapkee/defines/methods.hpp +++ b/include/tapkee/defines/methods.hpp @@ -108,6 +108,9 @@ template struct Method this->name_ = m.name_; return *this; } + Method(const Method& m) = default; + Method(Method&& m) = delete; + Method& operator=(Method&& m) = delete; const char* name() const { return name_; From 9443cfe34f1df912a50ddbfdffc9513323005cbc Mon Sep 17 00:00:00 2001 From: "Fernando J. Iglesias Garcia" Date: Mon, 15 Apr 2024 15:41:06 +0200 Subject: [PATCH 2/9] Destructor was still missing and copy assignment defaultable -> Rule of 0. --- include/tapkee/defines/methods.hpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/include/tapkee/defines/methods.hpp b/include/tapkee/defines/methods.hpp index 81a895e..e556e7d 100644 --- a/include/tapkee/defines/methods.hpp +++ b/include/tapkee/defines/methods.hpp @@ -103,14 +103,6 @@ template struct Method Method(const M& m) : name_(m.name_) { } - Method& operator=(const Method& m) - { - this->name_ = m.name_; - return *this; - } - Method(const Method& m) = default; - Method(Method&& m) = delete; - Method& operator=(Method&& m) = delete; const char* name() const { return name_; From 211e3490e016e7a748dc3b15ce768563cbc8cd79 Mon Sep 17 00:00:00 2001 From: "Fernando J. Iglesias Garcia" Date: Mon, 15 Apr 2024 15:41:51 +0200 Subject: [PATCH 3/9] Address compilation warnings about deprecated comma in subscripting. open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1161r3.html --- test/unit/interface.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/test/unit/interface.cpp b/test/unit/interface.cpp index 6331566..0cbf180 100644 --- a/test/unit/interface.cpp +++ b/test/unit/interface.cpp @@ -144,7 +144,7 @@ TEST(Interface, ParametersSet) { int td = 3; int k = 5; - tapkee::ParametersSet pg = tapkee::kwargs[target_dimension = td, num_neighbors = k]; + tapkee::ParametersSet pg = tapkee::kwargs[(target_dimension = td, num_neighbors = k)]; ASSERT_EQ(static_cast(pg[target_dimension]), td); ASSERT_EQ(static_cast(pg[num_neighbors]), k); } @@ -152,7 +152,7 @@ TEST(Interface, ParametersSet) TEST(Interface, OneParameterParametersSet) { int td = 3; - tapkee::ParametersSet pg = tapkee::kwargs[target_dimension = td]; + tapkee::ParametersSet pg = tapkee::kwargs[(target_dimension = td)]; ASSERT_EQ(static_cast(pg[target_dimension]), td); } @@ -168,7 +168,7 @@ TEST(Interface, WrongParameterValueKernelLocallyLinearEmbedding) TapkeeOutput output; // fails with wrong parameter type as '-1' is not a valid value. ASSERT_THROW(output = embed(data.begin(), data.end(), kcb, dcb, fcb, - tapkee::kwargs[method = KernelLocallyLinearEmbedding, num_neighbors = -3]), + tapkee::kwargs[(method = KernelLocallyLinearEmbedding, num_neighbors = -3)]), wrong_parameter_error); } @@ -206,7 +206,7 @@ TEST(Interface, CancellationPassThru) TapkeeOutput output; // should cancel ASSERT_THROW(output = embed(data.begin(), data.end(), kcb, dcb, fcb, - tapkee::kwargs[method = PassThru, cancel_function = always_cancel]), + tapkee::kwargs[(method = PassThru, cancel_function = always_cancel)]), cancelled_exception); } @@ -220,7 +220,7 @@ TEST(Interface, NoReductionMethodSetFailPassThru) TapkeeOutput output; // should fail with missed parameter - ASSERT_THROW(output = embed(data.begin(), data.end(), kcb, dcb, fcb, tapkee::kwargs[eigen_method = Dense]), + ASSERT_THROW(output = embed(data.begin(), data.end(), kcb, dcb, fcb, tapkee::kwargs[(eigen_method = Dense)]), missed_parameter_error); } @@ -236,7 +236,7 @@ TEST(Interface, UnsupportedRandomizedForGeneralizedLE) TapkeeOutput output; ASSERT_THROW(output = embed(data.begin(), data.end(), kcb, dcb, fcb, - tapkee::kwargs[method = LaplacianEigenmaps, eigen_method = Randomized]), + tapkee::kwargs[(method = LaplacianEigenmaps, eigen_method = Randomized)]), unsupported_method_error); } @@ -253,7 +253,7 @@ TEST(Interface, EigenDecompositionFailMDS) TapkeeOutput output; ASSERT_THROW(output = tapkee::embed(data.begin(), data.end(), kcb, dcb, fcb, - tapkee::kwargs[method = MultidimensionalScaling, eigen_method = Randomized]), + tapkee::kwargs[(method = MultidimensionalScaling, eigen_method = Randomized)]), eigendecomposition_error); } @@ -271,6 +271,6 @@ TEST(Interface, NotEnoughMemoryMDS) tapkee::TapkeeOutput output; // tries to form 10000000 x 10000000 matrix (won't work on any machine in 2013) ASSERT_THROW(output = embed(data.begin(), data.end(), kcb, dcb, fcb, - tapkee::kwargs[method = MultidimensionalScaling, eigen_method = Dense]), + tapkee::kwargs[(method = MultidimensionalScaling, eigen_method = Dense)]), not_enough_memory_error); } From 9d1de4e2a367d10236db68ff1d56f019706bb99b Mon Sep 17 00:00:00 2001 From: "Fernando J. Iglesias Garcia" Date: Mon, 15 Apr 2024 15:43:35 +0200 Subject: [PATCH 4/9] Remove unused code in Barnes-Hut-SNE from clang-check. --- .../external/barnes_hut_sne/quadtree.hpp | 46 ------------------- 1 file changed, 46 deletions(-) diff --git a/include/tapkee/external/barnes_hut_sne/quadtree.hpp b/include/tapkee/external/barnes_hut_sne/quadtree.hpp index 07af420..b34f8d4 100644 --- a/include/tapkee/external/barnes_hut_sne/quadtree.hpp +++ b/include/tapkee/external/barnes_hut_sne/quadtree.hpp @@ -299,52 +299,6 @@ class QuadTree return true; } - // Rebuilds a possibly incorrect tree (LAURENS: This function is not tested yet!) - void rebuildTree() - { - for (int n = 0; n < size; n++) - { - // Check whether point is erroneous - ScalarType* point = data + index[n] * QT_NO_DIMS; - if (!boundary.containsPoint(point)) - { - - // Remove erroneous point - int rem_index = index[n]; - for (int m = n + 1; m < size; m++) - index[m - 1] = index[m]; - index[size - 1] = -1; - size--; - - // Update center-of-mass and counter in all parents - bool done = false; - QuadTree* node = this; - while (!done) - { - for (int d = 0; d < QT_NO_DIMS; d++) - { - node->center_of_mass[d] = ((ScalarType)node->cum_size * node->center_of_mass[d] - point[d]) / - (ScalarType)(node->cum_size - 1); - } - node->cum_size--; - if (node->getParent() == NULL) - done = true; - else - node = node->getParent(); - } - - // Reinsert point in the root tree - node->insert(rem_index); - } - } - - // Rebuild lower parts of the tree - northWest->rebuildTree(); - northEast->rebuildTree(); - southWest->rebuildTree(); - southEast->rebuildTree(); - } - // Build a list of all indices in quadtree void getAllIndices(int* indices) { From 4aa66f2ca8978bec9c3f2a2802f300e1a4baa7c6 Mon Sep 17 00:00:00 2001 From: "Fernando J. Iglesias Garcia" Date: Tue, 16 Apr 2024 08:10:05 +0200 Subject: [PATCH 5/9] Add #includes. --- include/tapkee/defines/types.hpp | 2 ++ include/tapkee/projection.hpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/include/tapkee/defines/types.hpp b/include/tapkee/defines/types.hpp index 19f4a29..0ab7750 100644 --- a/include/tapkee/defines/types.hpp +++ b/include/tapkee/defines/types.hpp @@ -4,6 +4,8 @@ */ #pragma once +#include + namespace tapkee { #ifdef TAPKEE_CUSTOM_INTERNAL_NUMTYPE diff --git a/include/tapkee/projection.hpp b/include/tapkee/projection.hpp index 6a50a18..20169a3 100644 --- a/include/tapkee/projection.hpp +++ b/include/tapkee/projection.hpp @@ -4,6 +4,8 @@ */ #pragma once +#include + #include namespace tapkee From 4db78c440b438624f6d52b7d8187559ae0b2ec28 Mon Sep 17 00:00:00 2001 From: "Fernando J. Iglesias Garcia" Date: Tue, 16 Apr 2024 09:04:59 +0200 Subject: [PATCH 6/9] Delete file. --- include/tapkee/callbacks/neighbor_callbacks.hpp | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 include/tapkee/callbacks/neighbor_callbacks.hpp diff --git a/include/tapkee/callbacks/neighbor_callbacks.hpp b/include/tapkee/callbacks/neighbor_callbacks.hpp deleted file mode 100644 index e83bcf6..0000000 --- a/include/tapkee/callbacks/neighbor_callbacks.hpp +++ /dev/null @@ -1,14 +0,0 @@ -/* This software is distributed under BSD 3-clause license (see LICENSE file). - * - * Copyright (c) 2012-2013 Sergey Lisitsyn - */ -#pragma once - -/* Tapkee includes */ -#include -/* End of Tapkee includes */ - -template struct neighbors_finder -{ - virtual Neighbors find_neighbors(RandomAccessIterator begin, RandomAccessIterator end, IndexType k); -}; From b5ca911f9ee787af247c952b264af66e5609a3b2 Mon Sep 17 00:00:00 2001 From: "Fernando J. Iglesias Garcia" Date: Tue, 16 Apr 2024 09:20:10 +0200 Subject: [PATCH 7/9] Add methods traits include. --- include/tapkee/defines/methods.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/include/tapkee/defines/methods.hpp b/include/tapkee/defines/methods.hpp index e556e7d..5bc2521 100644 --- a/include/tapkee/defines/methods.hpp +++ b/include/tapkee/defines/methods.hpp @@ -5,6 +5,7 @@ #pragma once #include +#include namespace tapkee { From 1bb3e7ca469378c0abe4a216220a8a617dedcc71 Mon Sep 17 00:00:00 2001 From: "Fernando J. Iglesias Garcia" Date: Tue, 16 Apr 2024 09:29:52 +0200 Subject: [PATCH 8/9] Address clang-check's red herring can't initialize int with const char*. --- include/tapkee/utils/naming.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/tapkee/utils/naming.hpp b/include/tapkee/utils/naming.hpp index fbff795..0f52445 100644 --- a/include/tapkee/utils/naming.hpp +++ b/include/tapkee/utils/naming.hpp @@ -4,6 +4,8 @@ */ #pragma once +#include + namespace tapkee { From f80a18d2dbed387fe2522144401a61b8dc35ac50 Mon Sep 17 00:00:00 2001 From: "Fernando J. Iglesias Garcia" Date: Tue, 16 Apr 2024 09:32:04 +0200 Subject: [PATCH 9/9] Add std include. --- include/tapkee/utils/naming.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/tapkee/utils/naming.hpp b/include/tapkee/utils/naming.hpp index 0f52445..f54ba49 100644 --- a/include/tapkee/utils/naming.hpp +++ b/include/tapkee/utils/naming.hpp @@ -6,6 +6,8 @@ #include +#include + namespace tapkee {