Skip to content

Commit

Permalink
Fixes equality with ordering of hyperparameters (#212)
Browse files Browse the repository at this point in the history
  • Loading branch information
eddiebergman committed Dec 15, 2021
1 parent 9856e62 commit 4d69931
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ConfigSpace/hyperparameters.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1506,7 +1506,7 @@ cdef class CategoricalHyperparameter(Hyperparameter):

return (
self.name == other.name and
self.choices == other.choices
set(self.choices) == set(other.choices)
)

def __hash__(self):
Expand Down
5 changes: 5 additions & 0 deletions test/test_hyperparameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,11 @@ def test_categorical(self):
self.assertNotEqual(f1, f2)
self.assertNotEqual(f1, "UniformFloat")

# Test that order of categoricals does not matter
f7 = CategoricalHyperparameter("param", ["a", "b"])
f7_ = CategoricalHyperparameter("param", ["b", "a"])
assert f7 == f7_

# test that meta-data is stored correctly
f_meta = CategoricalHyperparameter("param", ["a", "b"], default_value="a",
meta=dict(self.meta_data))
Expand Down

0 comments on commit 4d69931

Please sign in to comment.