From 3ea8d36c884cc47394a463d29478dfbb32916d49 Mon Sep 17 00:00:00 2001 From: Heiko Strathmann Date: Tue, 27 Feb 2018 12:14:46 +0000 Subject: [PATCH] apply autoformat --- src/shogun/base/Parameter.h | 5 ++-- src/shogun/base/SGObject.cpp | 26 ++++++++++-------- src/shogun/base/SGObject.h | 41 ++++++++++++++++++++-------- src/shogun/classifier/svm/LibSVM.cpp | 8 +++--- src/shogun/machine/Machine.cpp | 3 +- 5 files changed, 51 insertions(+), 32 deletions(-) diff --git a/src/shogun/base/Parameter.h b/src/shogun/base/Parameter.h index c9d80578006..52c2930458b 100644 --- a/src/shogun/base/Parameter.h +++ b/src/shogun/base/Parameter.h @@ -334,8 +334,9 @@ class Parameter void add(CSGObject** param, const char* name, const char* description=""); - template ::value, T>* = nullptr> - void add(T** param,const char* name, const char* description="") + template ::value, + T>* = nullptr> + void add(T** param, const char* name, const char* description = "") { TSGDataType type(CT_SCALAR, ST_NONE, PT_SGOBJECT); add_type(&type, (CSGObject**)param, name, description); diff --git a/src/shogun/base/SGObject.cpp b/src/shogun/base/SGObject.cpp index 920cd47532c..4082483f9e5 100644 --- a/src/shogun/base/SGObject.cpp +++ b/src/shogun/base/SGObject.cpp @@ -35,10 +35,10 @@ #include #include +#include +#include #include #include -#include -#include namespace shogun { @@ -1019,7 +1019,9 @@ CSGObject* CSGObject::create_empty() const void CSGObject::put(const std::string& name, CSGObject* value) { - REQUIRE(value, "Cannot put %s::%s, no object provided.\n", get_name(), name.c_str()); + REQUIRE( + value, "Cannot put %s::%s, no object provided.\n", get_name(), + name.c_str()); if (put_sgobject_type_dispatcher(name, value)) return; @@ -1030,11 +1032,11 @@ void CSGObject::put(const std::string& name, CSGObject* value) if (put_sgobject_type_dispatcher(name, value)) return; - - SG_ERROR("Cannot put object %s as parameter %s::%s of type %s, type does not match.\n", - value->get_name(), get_name(), name.c_str(), - self->map[BaseTag(name)].get_value().type().c_str()); - + SG_ERROR( + "Cannot put object %s as parameter %s::%s of type %s, type does not " + "match.\n", + value->get_name(), get_name(), name.c_str(), + self->map[BaseTag(name)].get_value().type().c_str()); } CSGObject* CSGObject::get(const std::string& name) @@ -1048,9 +1050,9 @@ CSGObject* CSGObject::get(const std::string& name) if (auto* result = get_sgobject_type_dispatcher(name)) return result; - - SG_ERROR("Cannot get parameter %s::%s of type %s as object, not object type.\n", - get_name(), name.c_str(), self->map[BaseTag(name)].get_value().type().c_str()); + SG_ERROR( + "Cannot get parameter %s::%s of type %s as object, not object type.\n", + get_name(), name.c_str(), + self->map[BaseTag(name)].get_value().type().c_str()); return nullptr; } - diff --git a/src/shogun/base/SGObject.h b/src/shogun/base/SGObject.h index 48f6d14af03..02d0c8dc7fc 100644 --- a/src/shogun/base/SGObject.h +++ b/src/shogun/base/SGObject.h @@ -354,17 +354,19 @@ class CSGObject catch (const TypeMismatchException& exc) { SG_ERROR( - "Cannot set parameter %s::%s of type %s, incompatible provided type %s.\n", - get_name(), _tag.name().c_str(), - exc.actual().c_str(), exc.expected().c_str()); + "Cannot set parameter %s::%s of type %s, incompatible " + "provided type %s.\n", + get_name(), _tag.name().c_str(), exc.actual().c_str(), + exc.expected().c_str()); } ref_value(value); update_parameter(_tag, make_any(value)); } else { - SG_ERROR("Parameter %s::%s does not exist.\n", - get_name(), _tag.name().c_str()); + SG_ERROR( + "Parameter %s::%s does not exist.\n", get_name(), + _tag.name().c_str()); } } @@ -374,7 +376,7 @@ class CSGObject { if (dynamic_cast(value)) { - put(Tag(name), (T*) value); + put(Tag(name), (T*)value); return true; } return false; @@ -417,7 +419,8 @@ class CSGObject * @param name name of the parameter * @param value value of the parameter, wrapped in smart pointer */ - template ::value, T>* = nullptr> + template ::value, + T>* = nullptr> void put(const std::string& name, Some value) { put(name, (CSGObject*)(value.get())); @@ -429,7 +432,11 @@ class CSGObject * @param name name of the parameter * @param value value of the parameter along with type information */ - template ::type>::value, T>::type> + template ::type>::value, + T>::type> void put(const std::string& name, T value) { put(Tag(name), value); @@ -452,7 +459,8 @@ class CSGObject catch (const TypeMismatchException& exc) { SG_ERROR( - "Cannot get parameter %s::%s of type %s, incompatible requested type %s.\n", + "Cannot get parameter %s::%s of type %s, incompatible " + "requested type %s.\n", get_name(), _tag.name().c_str(), exc.actual().c_str(), exc.expected().c_str()); } @@ -706,12 +714,21 @@ class CSGObject void init(); /** Overloaded helper to increase reference counter */ - static void ref_value(CSGObject* value) { SG_REF(value); } + static void ref_value(CSGObject* value) + { + SG_REF(value); + } /** Overloaded helper to increase reference counter * Here a no-op for non CSGobject pointer parameters */ - template ::type>::value, T>* = nullptr> - static void ref_value(T value) {} + template ::type>::value, + T>* = nullptr> + static void ref_value(T value) + { + } /** Checks if object has a parameter identified by a BaseTag. * This only checks for name and not type information. diff --git a/src/shogun/classifier/svm/LibSVM.cpp b/src/shogun/classifier/svm/LibSVM.cpp index e2d8a317303..de347b5a38b 100644 --- a/src/shogun/classifier/svm/LibSVM.cpp +++ b/src/shogun/classifier/svm/LibSVM.cpp @@ -60,14 +60,14 @@ bool CLibSVM::train_machine(CFeatures* data) } kernel->init(data, data); } - REQUIRE(kernel->get_num_vec_lhs()==m_labels->get_num_labels(), - "Number of training data (%d) must match number of labels (%d)\n", - kernel->get_num_vec_lhs(), m_labels->get_num_labels()) + REQUIRE( + kernel->get_num_vec_lhs() == m_labels->get_num_labels(), + "Number of training data (%d) must match number of labels (%d)\n", + kernel->get_num_vec_lhs(), m_labels->get_num_labels()) problem.l=m_labels->get_num_labels(); SG_INFO("%d trainlabels\n", problem.l) - // set linear term if (m_linear_term.vlen>0) { diff --git a/src/shogun/machine/Machine.cpp b/src/shogun/machine/Machine.cpp index 673795c6d53..b5a53ec3388 100644 --- a/src/shogun/machine/Machine.cpp +++ b/src/shogun/machine/Machine.cpp @@ -25,8 +25,7 @@ CMachine::CMachine() SG_ADD((machine_int_t*) &m_solver_type, "solver_type", "Type of solver.", MS_NOT_AVAILABLE); - SG_ADD(&m_labels, "labels", - "Labels to be used.", MS_NOT_AVAILABLE); + SG_ADD(&m_labels, "labels", "Labels to be used.", MS_NOT_AVAILABLE); SG_ADD(&m_store_model_features, "store_model_features", "Should feature data of model be stored after training?", MS_NOT_AVAILABLE); SG_ADD(&m_data_locked, "data_locked",