Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 20 additions & 14 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Version 1.1.0

* FEAT #376: Allow arbitrary values for `Categorical`, `Ordinal`, and `Constant` hyperparameters.
* FIX #375: Use `object` dtype for `Constant` np.array of values to prevent numpy type conversions of values.


# Version 1.0.1

* FIX #373: Fix `ForbiddenEqualsRelation` when evaluating on vectors of values.
Expand Down Expand Up @@ -92,7 +98,7 @@

# Version 0.4.15

* Add `pyproject.toml` to support wheel installation as required in
* Add `pyproject.toml` to support wheel installation as required in
[PEP518](https://medium.com/@grassfedcode/pep-517-and-518-in-plain-english-47208ca8b7a6)

# Version 0.4.14
Expand Down Expand Up @@ -120,7 +126,7 @@
* ADD #135: Add weights to the sampling of categorical hyperparameters.
* MAINT #129: Performance improvements for the generation of neighbor configurations.
* MAINT #130: Test the installability of a distribution on travis-ci.
* FIX #140: Fixes a bug which led to samples lower than the lower bound of
* FIX #140: Fixes a bug which led to samples lower than the lower bound of
`UniformFloatHyperparemeter` if the lower bound was larger than zero and quantization was used.
* FIX # 138: Fixes a bug in which the readme wasn't read correctly on systems not using UTF8 as
their default encoding.
Expand All @@ -145,29 +151,29 @@

# Version 0.4.9

* Fixes an issue where adding a new forbidden for an unknown hyperparameter
* Fixes an issue where adding a new forbidden for an unknown hyperparameter
did not result in an immediate exception.
* Add a new argument `vector` to `util.deactivate_inactive_hyperparameters`
* Make the number of categories a public variable for categorical and
ordinal hyperparameters

# Version 0.4.8

* Fixes an issue which made serialization of `ForbiddenInCondition` to json
* Fixes an issue which made serialization of `ForbiddenInCondition` to json
fail.
* MAINT #101: Improved error message on setting illegal value in a
* MAINT #101: Improved error message on setting illegal value in a
configuration.
* DOC #91: Added a documentation to automl.github.io/ConfigSpace

# Version 0.4.7

* Tests Python3.7.
* Fixes #87: better handling of Conjunctions when adding them to the
* Fixes #87: better handling of Conjunctions when adding them to the
configuration space.
* MAINT: Improved type annotation in `util.py` which results in improved
performance (due to better Cython optimization).
* MAINT: `util.get_one_exchange_neighborhood` now accepts two arguments
`num_neighbors` and `stdev` which govern the neighborhood creation behaviour
* MAINT: `util.get_one_exchange_neighborhood` now accepts two arguments
`num_neighbors` and `stdev` which govern the neighborhood creation behaviour
of several continuous hyperparameters.
* NEW #85: Add function to obtain active hyperparameters
* NEW #84: Add field for meta-data to the configuration space object.
Expand Down Expand Up @@ -291,21 +297,21 @@

# Version 0.2.1

* FIX: bug which changed order of hyperparameters when adding new
hyperparameter. This was non-deterministic due to the use of dict instead
* FIX: bug which changed order of hyperparameters when adding new
hyperparameter. This was non-deterministic due to the use of dict instead
of OrderedDict.
* FIX: compare configurations with == instead of numpy.allclose.
* FIX: issue 2, syntax error no longer present during installation
* FIX: json serialization of configurations and their hyperparameters can now
be deserialized by json and still compare equal
be deserialized by json and still compare equal

# Version 0.2

* FIX: bug which made integer values have different float values in the
* FIX: bug which made integer values have different float values in the
underlying vector representation.
* FIX: bug which could make two configuration spaces compare unequal due to
* FIX: bug which could make two configuration spaces compare unequal due to
the use of defaultdict
* FEATURE: new feature add_configuration_space, which allows to add a whole
* FEATURE: new feature add_configuration_space, which allows to add a whole
configuration space into an existing configuration space
* FEATURE: python3.5 support
* FIX: add function get_parent() to Conjunctions (issue #1)
Expand Down
22 changes: 22 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,28 @@ Those are introduced in the [user guide](./guide.md)
* You can now use your editor to jump to definition and see the source code.
* Contribute more easily!

There is no also better support in Categorical, Ordinal and Constant hyperparameters,
for arbitrary values, for example:

```python
from dataclasses import dataclass
from ConfigSpace import ConfigurationSpace, Constant

@dataclass
class A:
a: int

def f() -> None:
return None

cs = ConfigurationSpace({
"cat": [True, False, None],
"othercat": [A(1), f],
"constant": Constant("constant": (24, 25)),
})
```


With this, we have also deprecated many of the previous functions, simplifying the API
where possible or improving it's clarity. We have tried hard to keep everything backwards
compatible, and also recommend the new functionality to use!
Expand Down
9 changes: 5 additions & 4 deletions src/ConfigSpace/api/types/categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from typing_extensions import TypeAlias

from ConfigSpace.hyperparameters import CategoricalHyperparameter, OrdinalHyperparameter
from ConfigSpace.types import NotSet, _NotSet

# We only accept these types in `items`
T: TypeAlias = Union[str, int, float]
Expand All @@ -16,7 +17,7 @@ def Categorical(
name: str,
items: Sequence[T],
*,
default: T | None = None,
default: T | _NotSet = NotSet,
weights: Sequence[float] | None = None,
ordered: Literal[False],
meta: dict | None = None,
Expand All @@ -29,7 +30,7 @@ def Categorical(
name: str,
items: Sequence[T],
*,
default: T | None = None,
default: T | _NotSet = NotSet,
weights: Sequence[float] | None = None,
ordered: Literal[True],
meta: dict | None = None,
Expand All @@ -42,7 +43,7 @@ def Categorical(
name: str,
items: Sequence[T],
*,
default: T | None = None,
default: T | _NotSet = NotSet,
weights: Sequence[float] | None = None,
ordered: bool = ...,
meta: dict | None = None,
Expand All @@ -53,7 +54,7 @@ def Categorical(
name: str,
items: Sequence[T],
*,
default: T | None = None,
default: T | _NotSet = NotSet,
weights: Sequence[float] | None = None,
ordered: bool = False,
meta: dict | None = None,
Expand Down
10 changes: 1 addition & 9 deletions src/ConfigSpace/conditions.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,13 @@
import numpy as np
from more_itertools import all_equal, unique_everseen

from ConfigSpace.types import f64
from ConfigSpace.types import NotSet, f64

if TYPE_CHECKING:
from ConfigSpace.hyperparameters.hyperparameter import Hyperparameter
from ConfigSpace.types import Array, Mask


class _NotSet:
def __repr__(self) -> str:
return "ValueNotSetObject"


NotSet = _NotSet() # Sentinal value for unset values


class Condition(ABC):
def __init__(
self,
Expand Down
3 changes: 1 addition & 2 deletions src/ConfigSpace/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@

import numpy as np

from ConfigSpace.conditions import NotSet
from ConfigSpace.exceptions import IllegalValueError
from ConfigSpace.hyperparameters import FloatHyperparameter
from ConfigSpace.types import f64
from ConfigSpace.types import NotSet, f64

if TYPE_CHECKING:
from ConfigSpace.configuration_space import ConfigurationSpace
Expand Down
8 changes: 2 additions & 6 deletions src/ConfigSpace/configuration_space.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,9 @@ def _parse_hyperparameters_from_dict(
raise ValueError(f"Can't have empty list for categorical {name}")

yield CategoricalHyperparameter(name, hp)

# If it's an allowed type, it's a constant
elif isinstance(hp, (int, str, float)):
yield Constant(name, hp)

else:
raise ValueError(f"Unknown value '{hp}' for '{name}'")
# It's a constant
yield Constant(name, hp)


class ConfigurationSpace(Mapping[str, Hyperparameter]):
Expand Down
Loading