Skip to content

Commit

Permalink
Disabled test that old parameter names and tag parameter names match
Browse files Browse the repository at this point in the history
Also fix available_objects namespace
  • Loading branch information
karlnapf committed Jan 24, 2018
1 parent 2e6dc14 commit 1d0c05a
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/shogun/base/SGObject.h
Expand Up @@ -23,8 +23,8 @@
#include <shogun/lib/parameter_observers/ObservedValue.h>
#include <shogun/lib/tag.h>

#include <utility>
#include <set>
#include <utility>

/** \namespace shogun
* @brief all of classes and functions are contained in the shogun namespace
Expand Down
2 changes: 1 addition & 1 deletion src/shogun/base/class_list.cpp.templ
Expand Up @@ -75,7 +75,7 @@ void shogun::delete_object(CSGObject* object)
delete object;
}

std::set<std::string> available_objects()
std::set<std::string> shogun::available_objects()
{
std::set<std::string> result;
for (class_list_entry_t* i=class_list; i->m_class_name != NULL;
Expand Down
43 changes: 42 additions & 1 deletion tests/unit/base/SGObject_unittest.cc
Expand Up @@ -4,22 +4,25 @@
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* Written (W) 2013 Heiko Strathmann
* Written (W) 2013-2018 Heiko Strathmann
* Written (W) 2014 Thoralf Klein
* Written (W) 2015 Wu Lin
*/

#include "MockObject.h"
#include <shogun/base/class_list.h>
#include <shogun/base/some.h>
#include <shogun/features/DenseFeatures.h>
#include <shogun/io/SerializableAsciiFile.h>
#include <shogun/kernel/GaussianKernel.h>
#include <shogun/kernel/LinearKernel.h>
#include <shogun/lib/DataType.h>
#include <shogun/machine/gp/ExactInferenceMethod.h>
#include <shogun/machine/gp/GaussianLikelihood.h>
#include <shogun/machine/gp/ZeroMean.h>
#include <shogun/neuralnets/NeuralNetwork.h>
#include <shogun/regression/GaussianProcessRegression.h>

#ifdef HAVE_PTHREAD
#include <pthread.h>
#endif
Expand Down Expand Up @@ -545,3 +548,41 @@ TEST(SGObject, watched_parameter_object)
obj = nullptr;
EXPECT_EQ(other_obj->ref_count(), 1);
}

// temporary test until old parameter framework is gone
// enable test to hunt for parameters not registered in tags
// see https://github.com/shogun-toolbox/shogun/issues/4117
TEST(SGObjectAll, DISABLED_tag_coverage)
{
auto class_names = available_objects();

for (auto class_name : class_names)
{
auto obj = create(class_name.c_str(), PT_NOT_GENERIC);

// templated classes cannot be created in the above way
if (!obj)
{
// only test single generic type here: all types have the same
// parameter names
obj = create(class_name.c_str(), PT_FLOAT64);
}

// whether templated or not
ASSERT_NE(obj, nullptr);

// old parameter framework names
std::set<std::string> old_names;
for (auto i : range(obj->m_parameters->get_num_parameters()))
old_names.insert(obj->m_parameters->get_parameter(i)->m_name);
auto tag_names = obj->parameter_names();

// hack to increase readability of error messages
old_names.insert("Class: " + class_name);
tag_names.insert("Class: " + class_name);

EXPECT_EQ(tag_names, old_names);

SG_UNREF(obj);
}
}

0 comments on commit 1d0c05a

Please sign in to comment.