Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clang and warnings fixes #88

Merged
merged 9 commits into from
Apr 16, 2024
14 changes: 0 additions & 14 deletions include/tapkee/callbacks/neighbor_callbacks.hpp

This file was deleted.

6 changes: 1 addition & 5 deletions include/tapkee/defines/methods.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#pragma once

#include <tapkee/defines/types.hpp>
#include <tapkee/traits/methods_traits.hpp>

namespace tapkee
{
Expand Down Expand Up @@ -103,11 +104,6 @@ template <typename M> struct Method
Method(const M& m) : name_(m.name_)
{
}
Method& operator=(const Method& m)
{
this->name_ = m.name_;
return *this;
}
const char* name() const
{
return name_;
Expand Down
2 changes: 2 additions & 0 deletions include/tapkee/defines/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
*/
#pragma once

#include <tapkee/defines/eigen3.hpp>

namespace tapkee
{
#ifdef TAPKEE_CUSTOM_INTERNAL_NUMTYPE
Expand Down
46 changes: 0 additions & 46 deletions include/tapkee/external/barnes_hut_sne/quadtree.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
2 changes: 2 additions & 0 deletions include/tapkee/projection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
*/
#pragma once

#include <tapkee/defines/types.hpp>

#include <memory>

namespace tapkee
Expand Down
4 changes: 4 additions & 0 deletions include/tapkee/utils/naming.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
*/
#pragma once

#include <tapkee/defines/methods.hpp>

#include <string>

namespace tapkee
{

Expand Down
16 changes: 8 additions & 8 deletions test/unit/interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,15 @@ 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<int>(pg[target_dimension]), td);
ASSERT_EQ(static_cast<int>(pg[num_neighbors]), k);
}

TEST(Interface, OneParameterParametersSet)
{
int td = 3;
tapkee::ParametersSet pg = tapkee::kwargs[target_dimension = td];
tapkee::ParametersSet pg = tapkee::kwargs[(target_dimension = td)];
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oeps, I think I overlooked when changing this one ':-) without parentheses there should still be no warning in this one. I will modify it back.

ASSERT_EQ(static_cast<int>(pg[target_dimension]), td);
}

Expand All @@ -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);
}

Expand Down Expand Up @@ -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);
}

Expand All @@ -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)]),
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as in the other comment in this one.

missed_parameter_error);
}

Expand All @@ -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);
}

Expand All @@ -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);
}

Expand All @@ -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);
}
Loading