Skip to content

Commit 4d69931

Browse files
authored
Fixes equality with ordering of hyperparameters (#212)
1 parent 9856e62 commit 4d69931

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

ConfigSpace/hyperparameters.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1506,7 +1506,7 @@ cdef class CategoricalHyperparameter(Hyperparameter):
15061506

15071507
return (
15081508
self.name == other.name and
1509-
self.choices == other.choices
1509+
set(self.choices) == set(other.choices)
15101510
)
15111511

15121512
def __hash__(self):

test/test_hyperparameters.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,11 @@ def test_categorical(self):
577577
self.assertNotEqual(f1, f2)
578578
self.assertNotEqual(f1, "UniformFloat")
579579

580+
# Test that order of categoricals does not matter
581+
f7 = CategoricalHyperparameter("param", ["a", "b"])
582+
f7_ = CategoricalHyperparameter("param", ["b", "a"])
583+
assert f7 == f7_
584+
580585
# test that meta-data is stored correctly
581586
f_meta = CategoricalHyperparameter("param", ["a", "b"], default_value="a",
582587
meta=dict(self.meta_data))

0 commit comments

Comments
 (0)