-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Remove namespaces #3269
Remove namespaces #3269
Conversation
Okay, finished 10 percent of this PR and still a lot of things to do, I will continue later this weekend |
Thanks! I know it is very tedious ... I tried to fix the static code analysis warnings, but I think that they are false positives. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left a couple of comments, and some of them are relevant.
Everything looks good to me.
@@ -51,7 +50,7 @@ TEST_CASE("AMFMaxIterationTerminationTest", "[TerminationPolicyTest]") | |||
// Custom tighter tolerance. | |||
MaxIterationTermination mit(10); // Only 10 iterations. | |||
AMF<MaxIterationTermination, | |||
RandomInitialization, | |||
RandomAMFInitialization, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well noticed
@@ -24,31 +24,30 @@ inline void MockCategoricalData(arma::mat& d, | |||
// We'll build a spiral dataset plus two noisy categorical features. We need | |||
// to build the distributions for the categorical features (they'll be | |||
// discrete distributions). | |||
mlpack::distribution::DiscreteDistribution c1[5]; | |||
mlpack::DiscreteDistribution c1[5]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you keeping the mlpack namespace here? why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The MockCategoricalData()
function isn't in any namespace, so I fully qualify mlpack::
here. 👍
@@ -16,9 +16,6 @@ | |||
#include "test_catch_tools.hpp" | |||
|
|||
using namespace mlpack; | |||
using namespace mlpack::math; | |||
using namespace mlpack::kpca; | |||
using namespace mlpack::kernel; | |||
using namespace std; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using namespace std; |
* | ||
* mlpack is free software; you may redistribute it and/or modify it under the | ||
* terms of the 3-clause BSD license. You should have received a copy of the | ||
* 3-clause BSD license along with mlpack. If not, see | ||
* http://www.opensource.org/licenses/BSD-3-Clause for more information. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Funny how many files did not have the license in them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I used to have a script I ran to check that every file had a license, but it has been many years since I ran it...
if (modeStr == "dual-tree") | ||
kde->Mode() = KDEMode::DUAL_TREE_MODE; | ||
kde->Mode() = KDEMode::KDE_DUAL_TREE_MODE; | ||
else if (modeStr == "single-tree") | ||
kde->Mode() = KDEMode::SINGLE_TREE_MODE; | ||
kde->Mode() = KDEMode::KDE_SINGLE_TREE_MODE; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the KDE necessary here in the KDE_DUAL_TREE_MODE
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah---the DUAL_TREE_MODE
name is already taken by the NSMode
enum (which is used for various neighbor searching classes). This might not be the best possible solution, but I think it'll work for now.
src/mlpack/methods/ann/layer/not_adapted/multiply_merge_impl.hpp
Outdated
Show resolved
Hide resolved
#ifndef MLPACK_CORE_TREE_BUILD_TREE_HPP | ||
#define MLPACK_CORE_TREE_BUILD_TREE_HPP | ||
|
||
#include <mlpack/prereqs.hpp> | ||
|
||
namespace mlpack { | ||
|
||
//! Construct tree that rearranges the dataset. | ||
template<typename TreeType, typename MatType> | ||
TreeType* BuildTree( | ||
MatType&& dataset, | ||
std::vector<size_t>& oldFromNew, | ||
const typename std::enable_if< | ||
TreeTraits<TreeType>::RearrangesDataset>::type* = 0) | ||
{ | ||
return new TreeType(std::forward<MatType>(dataset), oldFromNew); | ||
} | ||
|
||
//! Construct tree that doesn't rearrange the dataset. | ||
template<typename TreeType, typename MatType> | ||
TreeType* BuildTree( | ||
MatType&& dataset, | ||
const std::vector<size_t>& /* oldFromNew */, | ||
const typename std::enable_if< | ||
!TreeTraits<TreeType>::RearrangesDataset>::type* = 0) | ||
{ | ||
return new TreeType(std::forward<MatType>(dataset)); | ||
} | ||
|
||
} // namespace mlpack |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now, I see where this has been moved
Co-authored-by: Omar Shrit <omar@shrit.me>
Co-authored-by: Omar Shrit <omar@shrit.me>
Co-authored-by: Omar Shrit <omar@shrit.me>
Co-authored-by: Omar Shrit <omar@shrit.me>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Second approval provided automatically after 24 hours. 👍
This PR implements the result of the discussion in #3261:
All namespaces under
mlpack::
are now removed, exceptmlpack::data
andmlpack::util
.mlpack::data
remains because it is very specific to utilities for loading/saving data, andmlpack::util
is utility stuff that shouldn't ever really be touched by users anyway, so it makes sense to keep it separate.mlpack::bindings
is also left as-is, because users shouldn't ever be using things in that namespace.All
using namespace ...
declarations in test files and examples are updated accordingly; onlyusing namespace mlpack
should be needed.The
namespace_compat.hpp
file is added, which reintroduces reverse-compatibility namespaces like this:That can help make transitions for users to mlpack 4 a little less painful.