Skip to content

Commit

Permalink
MAINT change function names to be more self-explaining
Browse files Browse the repository at this point in the history
  • Loading branch information
mfeurer committed Feb 14, 2017
1 parent b638d44 commit 423be96
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion smac/configspace/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ConfigSpace import ConfigurationSpace, Configuration
from ConfigSpace.io import pcs
from ConfigSpace.util import get_random_neighbor, get_one_exchange_neighbourhood
from smac.configspace.util import impute_inactive_hyperparameters
from smac.configspace.util import convert_configurations_to_array
2 changes: 1 addition & 1 deletion smac/configspace/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from smac.configspace import Configuration


def impute_inactive_hyperparameters(configs: List[Configuration]) -> np.ndarray:
def convert_configurations_to_array(configs: List[Configuration]) -> np.ndarray:
"""Impute inactive hyperparameters in configurations with their default.
Necessary to apply an EPM to the data.
Expand Down
8 changes: 4 additions & 4 deletions smac/runhistory/runhistory2epm.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from smac.tae.execute_ta_run import StatusType
from smac.runhistory.runhistory import RunHistory, RunKey, RunValue
from smac.configspace import impute_inactive_hyperparameters
from smac.configspace import convert_configurations_to_array
import smac.epm.base_imputor
from smac.utils import constants

Expand Down Expand Up @@ -296,12 +296,12 @@ def _build_matrix(self, run_dict, runhistory, instances=None, par_factor=1):
for row, (key, run) in enumerate(run_dict.items()):
# Scaling is automatically done in configSpace
conf = runhistory.ids_config[key.config_id]
conf_array = impute_inactive_hyperparameters([conf])[0]
conf_vector = convert_configurations_to_array([conf])[0]
if self.n_feats:
feats = self.instance_features[key.instance_id]
X[row, :] = np.hstack((conf_array, feats))
X[row, :] = np.hstack((conf_vector, feats))
else:
X[row, :] = conf_array
X[row, :] = conf_vector
# run_array[row, -1] = instances[row]
if self.scenario.run_obj == "runtime":
if run.status != StatusType.SUCCESS:
Expand Down
4 changes: 2 additions & 2 deletions smac/smbo/local_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import numpy as np

from smac.configspace import get_one_exchange_neighbourhood, \
impute_inactive_hyperparameters
convert_configurations_to_array

__author__ = "Aaron Klein, Marius Lindauer"
__copyright__ = "Copyright 2015, ML4AAD"
Expand Down Expand Up @@ -97,7 +97,7 @@ def maximize(self, start_point, *args):

for neighbor in all_neighbors:
s_time = time.time()
neighbor_array_ = impute_inactive_hyperparameters([neighbor])
neighbor_array_ = convert_configurations_to_array([neighbor])

acq_val = self.acquisition_function(neighbor_array_, *args)

Expand Down
4 changes: 2 additions & 2 deletions smac/smbo/smbo.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from smac.stats.stats import Stats
from smac.initial_design.initial_design import InitialDesign
from smac.scenario.scenario import Scenario
from smac.configspace import Configuration, impute_inactive_hyperparameters
from smac.configspace import Configuration, convert_configurations_to_array


__author__ = "Aaron Klein, Marius Lindauer, Matthias Feurer"
Expand Down Expand Up @@ -303,7 +303,7 @@ def _sort_configs_by_acq_value(self, configs):
"""

config_array = impute_inactive_hyperparameters(configs)
config_array = convert_configurations_to_array(configs)
acq_values = self.acquisition_func(config_array)

# From here
Expand Down
2 changes: 1 addition & 1 deletion test/test_configspace/test_configspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def test_impute_inactive_hyperparameters(self):
cs.add_condition(EqualsCondition(b, a, 1))
cs.seed(1)
configs = cs.sample_configuration(size=100)
config_array = smac.configspace.impute_inactive_hyperparameters(configs)
config_array = smac.configspace.convert_configurations_to_array(configs)
for line in config_array:
if line[0] == 0:
self.assertEqual(line[1], 1)
Expand Down
2 changes: 1 addition & 1 deletion test/test_smbo/test_smbo.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def test_choose_next_empty_X_2(self):
self.assertEqual(len(x), 1)
self.assertIsInstance(x[0], Configuration)

@mock.patch('smac.smbo.smbo.impute_inactive_hyperparameters')
@mock.patch('smac.smbo.smbo.convert_configurations_to_array')
@mock.patch.object(EI, '__call__')
@mock.patch.object(ConfigurationSpace, 'sample_configuration')
def test_get_next_by_random_search_sorted(self,
Expand Down

0 comments on commit 423be96

Please sign in to comment.