diff --git a/bindings/python/cconfigspace/feature_space.py b/bindings/python/cconfigspace/feature_space.py index 8dba5b99..0531103c 100644 --- a/bindings/python/cconfigspace/feature_space.py +++ b/bindings/python/cconfigspace/feature_space.py @@ -5,7 +5,6 @@ ccs_create_feature_space = _ccs_get_function("ccs_create_feature_space", [ct.c_char_p, ct.c_size_t, ct.POINTER(ccs_parameter), ct.POINTER(ccs_feature_space)]) ccs_feature_space_get_default_features = _ccs_get_function("ccs_feature_space_get_default_features", [ccs_feature_space, ct.POINTER(ccs_features)]) -ccs_feature_space_check_features = _ccs_get_function("ccs_feature_space_check_features", [ccs_feature_space, ccs_features, ct.POINTER(ccs_bool)]) class FeatureSpace(Context): def __init__(self, handle = None, retain = False, auto_release = True, @@ -34,10 +33,4 @@ def default_features(self): self._default_features = Features.from_handle(v) return self._default_features - def check(self, features): - valid = ccs_bool() - res = ccs_feature_space_check_features(self.handle, features.handle, ct.byref(valid)) - Error.check(res) - return False if valid.value == 0 else True - from .features import Features diff --git a/bindings/python/cconfigspace/features.py b/bindings/python/cconfigspace/features.py index 1afca326..6f5d17bb 100644 --- a/bindings/python/cconfigspace/features.py +++ b/bindings/python/cconfigspace/features.py @@ -6,7 +6,6 @@ ccs_create_features = _ccs_get_function("ccs_create_features", [ccs_feature_space, ct.c_size_t, ct.POINTER(Datum), ct.POINTER(ccs_features)]) ccs_features_get_feature_space = _ccs_get_function("ccs_features_get_feature_space", [ccs_features, ct.POINTER(ccs_feature_space)]) -ccs_features_check = _ccs_get_function("ccs_features_check", [ccs_features, ct.POINTER(ccs_bool)]) class Features(Binding): def __init__(self, handle = None, retain = False, auto_release = True, @@ -42,10 +41,4 @@ def feature_space(self): self._feature_space = FeatureSpace.from_handle(v) return self._feature_space - def check(self): - valid = ccs_bool() - res = ccs_features_check(self.handle, ct.byref(valid)) - Error.check(res) - return False if valid.value == 0 else True - from .feature_space import FeatureSpace diff --git a/bindings/ruby/lib/cconfigspace/feature_space.rb b/bindings/ruby/lib/cconfigspace/feature_space.rb index 2c054702..307b2eb4 100644 --- a/bindings/ruby/lib/cconfigspace/feature_space.rb +++ b/bindings/ruby/lib/cconfigspace/feature_space.rb @@ -1,7 +1,6 @@ module CCS attach_function :ccs_create_feature_space, [:string, :size_t, :pointer, :pointer], :ccs_result_t attach_function :ccs_feature_space_get_default_features, [:ccs_feature_space_t, :pointer], :ccs_result_t - attach_function :ccs_feature_space_check_features, [:ccs_feature_space_t, :ccs_features_t, :pointer], :ccs_result_t class FeatureSpace < Context add_handle_property :default_features, :ccs_features_t, :ccs_feature_space_get_default_features, memoize: true @@ -24,11 +23,5 @@ def self.from_handle(handle, retain: true, auto_release: true) self::new(handle, retain: retain, auto_release: auto_release) end - def check(features) - ptr = MemoryPointer::new(:ccs_bool_t) - CCS.error_check CCS.ccs_feature_space_check_features(@handle, features, ptr) - return ptr.read_ccs_bool_t == CCS::FALSE ? false : true - end - end end diff --git a/bindings/ruby/lib/cconfigspace/features.rb b/bindings/ruby/lib/cconfigspace/features.rb index 509773f4..b12d0ac2 100644 --- a/bindings/ruby/lib/cconfigspace/features.rb +++ b/bindings/ruby/lib/cconfigspace/features.rb @@ -1,7 +1,6 @@ module CCS attach_function :ccs_create_features, [:ccs_feature_space_t, :size_t, :pointer, :pointer], :ccs_result_t - attach_function :ccs_features_check, [:ccs_features_t, :pointer], :ccs_result_t class Features < Binding alias feature_space context @@ -32,12 +31,6 @@ def self.from_handle(handle, retain: true, auto_release: true) self::new(handle, retain: retain, auto_release: auto_release) end - def check - ptr = MemoryPointer::new(:ccs_bool_t) - CCS.error_check CCS.ccs_features_check(@handle, ptr) - return ptr.read_ccs_bool_t == CCS::FALSE ? false : true - end - end end diff --git a/include/cconfigspace/feature_space.h b/include/cconfigspace/feature_space.h index 96834ccc..4ace1df8 100644 --- a/include/cconfigspace/feature_space.h +++ b/include/cconfigspace/feature_space.h @@ -57,30 +57,6 @@ ccs_feature_space_get_default_features( ccs_feature_space_t feature_space, ccs_features_t *features_ret); -/** - * Check that a features is a valid in a feature space. - * @param[in] feature_space - * @param[in] features - * @param[out] is_valid_ret a pointer to a variable that will hold the result - * of the check. Result will be #CCS_TRUE if the - * features is valid. Result will be #CCS_FALSE if - * an parameter value is not a valid value - * for this parameter; - * @return #CCS_RESULT_SUCCESS on success - * @return #CCS_RESULT_ERROR_INVALID_OBJECT if \p feature_space is not a valid - * CCS feature space; or if \p features is not a valid CCS features - * @return #CCS_RESULT_ERROR_INVALID_FEATURES if \p features is not associated - * to the feature space; or if the number of values contained in \p features is - * not equal to the number of parameters in the feature space - * @remarks - * This function is thread-safe - */ -extern ccs_result_t -ccs_feature_space_check_features( - ccs_feature_space_t feature_space, - ccs_features_t features, - ccs_bool_t *is_valid_ret); - #ifdef __cplusplus } #endif diff --git a/include/cconfigspace/features.h b/include/cconfigspace/features.h index 9f8e6533..8811f72a 100644 --- a/include/cconfigspace/features.h +++ b/include/cconfigspace/features.h @@ -55,25 +55,6 @@ ccs_features_get_feature_space( ccs_features_t features, ccs_feature_space_t *feature_space_ret); -/** - * Check that the features is a valid features for the feature space. - * @param[in] features - * @param[out] is_valid_ret a pointer to a variable that will hold the result - * of the check. Result will be #CCS_TRUE if the - * features is valid. Result will be #CCS_FALSE if - * an parameter value is not a valid value - * for this parameter - * @return #CCS_RESULT_SUCCESS on success - * @return #CCS_RESULT_ERROR_INVALID_OBJECT if \p features is not a valid CCS - * features - * @return #CCS_RESULT_ERROR_INVALID_CONFIGURATION if \p features is found to be - * invalid - * @remarks - * This function is thread-safe - */ -extern ccs_result_t -ccs_features_check(ccs_features_t features, ccs_bool_t *is_valid_ret); - #ifdef __cplusplus } #endif diff --git a/src/feature_space.c b/src/feature_space.c index 7d75ae28..90fed2fc 100644 --- a/src/feature_space.c +++ b/src/feature_space.c @@ -155,37 +155,3 @@ ccs_feature_space_get_default_features( ccs_release_object(features); return err; } - -static inline ccs_result_t -_check_features( - ccs_feature_space_t feature_space, - ccs_features_t features, - ccs_bool_t *is_valid_ret) -{ - ccs_parameter_t *parameters = feature_space->data->parameters; - size_t num_parameters = feature_space->data->num_parameters; - ccs_datum_t *values = features->data->values; - *is_valid_ret = CCS_TRUE; - for (size_t i = 0; i < num_parameters; i++) { - CCS_VALIDATE(ccs_parameter_check_value( - parameters[i], values[i], is_valid_ret)); - if (*is_valid_ret == CCS_FALSE) - return CCS_RESULT_SUCCESS; - } - return CCS_RESULT_SUCCESS; -} - -ccs_result_t -ccs_feature_space_check_features( - ccs_feature_space_t feature_space, - ccs_features_t features, - ccs_bool_t *is_valid_ret) -{ - CCS_CHECK_OBJ(feature_space, CCS_OBJECT_TYPE_FEATURE_SPACE); - CCS_CHECK_OBJ(features, CCS_OBJECT_TYPE_FEATURES); - CCS_REFUTE( - features->data->feature_space != feature_space, - CCS_RESULT_ERROR_INVALID_FEATURES); - CCS_VALIDATE(_check_features(feature_space, features, is_valid_ret)); - return CCS_RESULT_SUCCESS; -} diff --git a/src/features.c b/src/features.c index 7fd4358f..33ba9dcb 100644 --- a/src/features.c +++ b/src/features.c @@ -109,14 +109,13 @@ _ccs_create_features( memcpy(feat->data->values, values, num_parameters * sizeof(ccs_datum_t)); for (size_t i = 0; i < num_values; i++) - if (values[i].flags & CCS_DATUM_FLAG_TRANSIENT) - CCS_VALIDATE_ERR_GOTO( - err, - ccs_context_validate_value( - (ccs_context_t)feature_space, i, - values[i], - feat->data->values + i), - errinit); + CCS_VALIDATE_ERR_GOTO( + err, + ccs_context_validate_value( + (ccs_context_t)feature_space, i, + values[i], + feat->data->values + i), + errinit); } *features_ret = feat; return CCS_RESULT_SUCCESS; @@ -155,12 +154,3 @@ ccs_features_get_feature_space( (ccs_binding_t)features, (ccs_context_t *)feature_space_ret)); return CCS_RESULT_SUCCESS; } - -ccs_result_t -ccs_features_check(ccs_features_t features, ccs_bool_t *is_valid_ret) -{ - CCS_CHECK_OBJ(features, CCS_OBJECT_TYPE_FEATURES); - CCS_VALIDATE(ccs_feature_space_check_features( - features->data->feature_space, features, is_valid_ret)); - return CCS_RESULT_SUCCESS; -} diff --git a/src/tuner.c b/src/tuner.c index 313b81fa..9147d201 100644 --- a/src/tuner.c +++ b/src/tuner.c @@ -73,19 +73,18 @@ ccs_tuner_ask( size_t *num_configurations_ret) { CCS_CHECK_OBJ(tuner, CCS_OBJECT_TYPE_TUNER); - if (features) + if (features) { + _ccs_tuner_common_data_t *d = + (_ccs_tuner_common_data_t *)tuner->data; CCS_CHECK_OBJ(features, CCS_OBJECT_TYPE_FEATURES); + CCS_REFUTE( + features->data->feature_space != d->feature_space, + CCS_RESULT_ERROR_INVALID_FEATURES); + } CCS_CHECK_ARY(num_configurations, configurations); CCS_REFUTE( !configurations && !num_configurations_ret, CCS_RESULT_ERROR_INVALID_VALUE); - _ccs_tuner_common_data_t *d = (_ccs_tuner_common_data_t *)tuner->data; - if (d->feature_space && features) { - ccs_bool_t valid; - CCS_VALIDATE(ccs_feature_space_check_features( - d->feature_space, features, &valid)); - CCS_REFUTE(!valid, CCS_RESULT_ERROR_INVALID_FEATURES); - } ccs_result_t err = CCS_RESULT_SUCCESS; _ccs_tuner_ops_t *ops = ccs_tuner_get_ops(tuner); CCS_OBJ_RDLOCK(tuner); @@ -196,18 +195,17 @@ ccs_tuner_suggest( ccs_search_configuration_t *configuration) { CCS_CHECK_OBJ(tuner, CCS_OBJECT_TYPE_TUNER); + if (features) { + _ccs_tuner_common_data_t *d = + (_ccs_tuner_common_data_t *)tuner->data; + CCS_CHECK_OBJ(features, CCS_OBJECT_TYPE_FEATURES); + CCS_REFUTE( + features->data->feature_space != d->feature_space, + CCS_RESULT_ERROR_INVALID_FEATURES); + } _ccs_tuner_ops_t *ops = ccs_tuner_get_ops(tuner); CCS_REFUTE(!ops->suggest, CCS_RESULT_ERROR_UNSUPPORTED_OPERATION); - if (features) - CCS_CHECK_OBJ(features, CCS_OBJECT_TYPE_FEATURES); CCS_CHECK_PTR(configuration); - _ccs_tuner_common_data_t *d = (_ccs_tuner_common_data_t *)tuner->data; - if (d->feature_space) { - ccs_bool_t valid; - CCS_VALIDATE(ccs_feature_space_check_features( - d->feature_space, features, &valid)); - CCS_REFUTE(!valid, CCS_RESULT_ERROR_INVALID_FEATURES); - } ccs_result_t err = CCS_RESULT_SUCCESS; CCS_OBJ_RDLOCK(tuner); CCS_VALIDATE_ERR_GOTO( diff --git a/tests/test_feature_space.c b/tests/test_feature_space.c index dcf305c9..8ee248fb 100644 --- a/tests/test_feature_space.c +++ b/tests/test_feature_space.c @@ -129,7 +129,6 @@ test_features(void) ccs_datum_t datum; size_t num_values_ret; int cmp; - ccs_bool_t check; parameters[0] = create_dummy_parameter("param1"); parameters[1] = create_dummy_parameter("param2"); @@ -169,15 +168,6 @@ test_features(void) assert(values[1].type == datum.type); assert(values[1].value.f == datum.value.f); - err = ccs_features_check(features1, &check); - assert(err == CCS_RESULT_SUCCESS); - assert(check); - - err = ccs_feature_space_check_features( - feature_space, features1, &check); - assert(err == CCS_RESULT_SUCCESS); - assert(check); - err = ccs_create_features(feature_space, 3, values, &features2); assert(err == CCS_RESULT_SUCCESS); @@ -201,16 +191,7 @@ test_features(void) values[1] = ccs_float(10.0); err = ccs_create_features(feature_space, 3, values, &features2); - assert(err == CCS_RESULT_SUCCESS); - - err = ccs_features_check(features2, &check); - assert(err == CCS_RESULT_SUCCESS); - assert(!check); - - err = ccs_feature_space_check_features( - feature_space, features2, &check); - assert(err == CCS_RESULT_SUCCESS); - assert(!check); + assert(err == CCS_RESULT_ERROR_INVALID_VALUE); for (size_t i = 0; i < 3; i++) { err = ccs_release_object(parameters[i]);