Skip to content

Normal integer

ConfigSpace.hyperparameters.normal_integer #

NormalIntegerHyperparameter dataclass #

NormalIntegerHyperparameter(
    name: str,
    mu: Number,
    sigma: Number,
    lower: Number,
    upper: Number,
    default_value: Number | None = None,
    log: bool = False,
    meta: Mapping[Hashable, Any] | None = None,
)

Bases: IntegerHyperparameter

A normally distributed integer hyperparameter.

The 'mu' and 'sigma' parameters define the mean and standard deviation of the normal distribution. The 'lower' and 'upper' parameters move the distribution from the [0, 1]-range and scale it appropriately, but the shape of the distribution is preserved as if it were in [0, 1]-range.

Its values are sampled from a normal distribution N(mu, sigma).

```python exec="True" result="python" source="material-block" from ConfigSpace import NormalIntegerHyperparameter

n = NormalIntegerHyperparameter('n', mu=150, sigma=20, lower=100, upper=200) print(n)

PARAMETER DESCRIPTION
name

Name of the hyperparameter, with which it can be accessed

TYPE: str

mu

Mean of the normal distribution

TYPE: Number

sigma

Standard deviation of the normal distribution

TYPE: Number

lower

Lower bound of of values from which the hyperparameter represents

TYPE: Number

upper

Upper bound of of values from which the hyperparameter represents

TYPE: Number

default_value

The default value of this hyperparameter

TYPE: Number | None DEFAULT: None

log

If True the values will be sampled on a log-scale

TYPE: bool DEFAULT: False

meta

Field for holding meta data provided by the user. Not used by ConfigSpace.

TYPE: Mapping[Hashable, Any] | None DEFAULT: None

Source code in src/ConfigSpace/hyperparameters/normal_integer.py
def __init__(
    self,
    name: str,
    mu: Number,
    sigma: Number,
    lower: Number,
    upper: Number,
    default_value: Number | None = None,
    log: bool = False,
    meta: Mapping[Hashable, Any] | None = None,
) -> None:
    """A normally distributed integer hyperparameter.

    Args:
        name:
            Name of the hyperparameter, with which it can be accessed
        mu:
            Mean of the normal distribution
        sigma:
            Standard deviation of the normal distribution
        lower:
            Lower bound of of values from which the hyperparameter represents
        upper:
            Upper bound of of values from which the hyperparameter represents
        default_value:
            The default value of this hyperparameter
        log:
            If `True` the values will be sampled on a log-scale
        meta:
            Field for holding meta data provided by the user. Not used by
            ConfigSpace.
    """
    if mu <= 0 and log:
        raise ValueError(
            f"Hyperparameter '{name}' has illegal settings: "
            f"mu={mu} must be positive for log-scale.",
        )

    self.mu = float(mu)
    self.sigma = float(sigma)
    self.lower = int(np.rint(lower))
    self.upper = int(np.rint(upper))
    self.log = bool(log)

    try:
        scaler = UnitScaler(
            i64(self.lower),
            i64(self.upper),
            log=self.log,
            dtype=i64,
        )
    except ValueError as e:
        raise ValueError(f"Hyperparameter '{name}' has illegal settings") from e

    if default_value is None:
        _default_value = int(np.rint(np.clip(self.mu, self.lower, self.upper)))
    else:
        if not is_close_to_integer(f64(default_value), atol=ATOL):
            raise TypeError(
                f"`default_value` for hyperparameter '{name}' must be an integer."
                f" Got '{type(default_value).__name__}' for {default_value=}.",
            )

        _default_value = int(np.rint(default_value))

    size = self.upper - self.lower + 1

    vectorized_mu = scaler.to_vector(np.array([self.mu]))[0]
    vectorized_sigma = scaler.vectorize_size(f64(self.sigma))

    vec_truncnorm_dist = truncnorm(  # type: ignore
        a=(0.0 - vectorized_mu) / vectorized_sigma,
        b=(1.0 - vectorized_mu) / vectorized_sigma,
        loc=vectorized_mu,
        scale=vectorized_sigma,
    )

    vector_dist = DiscretizedContinuousScipyDistribution(
        rv=vec_truncnorm_dist,  # type: ignore
        steps=int(size),
        lower_vectorized=f64(0.0),
        upper_vectorized=f64(1.0),
    )
    super().__init__(
        name=name,
        size=int(size),
        default_value=_default_value,
        meta=meta,
        transformer=scaler,
        vector_dist=vector_dist,
        neighborhood=vector_dist.neighborhood,
        neighborhood_size=self._integer_neighborhood_size,
        value_cast=int,
    )

default_value instance-attribute #

default_value: int

The default value of this hyperparameter.

log instance-attribute #

log: bool = bool(log)

If True the values of the hyperparameter will be sampled on a log-scale.

lower instance-attribute #

lower: int = int(rint(lower))

Lower bound of a range of values from which the hyperparameter represents.

lower_vectorized property #

lower_vectorized: f64

Lower bound of the hyperparameter in vector space.

meta instance-attribute #

meta: Mapping[Hashable, Any] | None

Field for holding meta data provided by the user. Not used by the ConfigSpace.

mu instance-attribute #

mu: float = float(mu)

Mean of the normal distribution.

name instance-attribute #

name: str

Name of the hyperparameter, with which it can be accessed.

sigma instance-attribute #

sigma: float = float(sigma)

Standard deviation of the normal distribution.

size class-attribute instance-attribute #

size: int = field(init=False)

Size of the hyperparameter, which is the count of ints between upper and lower, inclusive.

upper instance-attribute #

upper: int = int(rint(upper))

Upper bound of a range of values from which the hyperparameter represents.

upper_vectorized property #

upper_vectorized: f64

Upper bound of the hyperparameter in vector space.

copy #

copy(**kwargs: Any) -> Self

Create a copy of the hyperparameter with updated attributes.

PARAMETER DESCRIPTION
**kwargs

The attributes to update.

TYPE: Any DEFAULT: {}

RETURNS DESCRIPTION
Self

A copy of the hyperparameter with the updated attributes.

Source code in src/ConfigSpace/hyperparameters/hyperparameter.py
def copy(self, **kwargs: Any) -> Self:
    """Create a copy of the hyperparameter with updated attributes.

    Args:
        **kwargs:
            The attributes to update.

    Returns:
        A copy of the hyperparameter with the updated attributes.
    """
    # HACK: Really the only thing implementing Hyperparameter should be a dataclass
    # If a hyperparameter is somehow not a dataclass, it will likely need to
    # overwrite this.
    return replace(self, **kwargs)  # type: ignore

get_max_density #

get_max_density() -> float

Get the maximum density of the hyperparameter distribution.

Source code in src/ConfigSpace/hyperparameters/hyperparameter.py
def get_max_density(self) -> float:
    """Get the maximum density of the hyperparameter distribution."""
    return self._vector_dist.max_density()

get_neighbors #

get_neighbors(
    value: f64,
    rs: RandomState,
    number: int | None = None,
    std: float | None = None,
    transform: bool = False,
) -> Array[f64]

Deprecated.

Source code in src/ConfigSpace/hyperparameters/hyperparameter.py
@deprecated("Please use `neighbors_vectorized`  instead.")
def get_neighbors(
    self,
    value: f64,
    rs: np.random.RandomState,
    number: int | None = None,
    std: float | None = None,
    transform: bool = False,
) -> Array[f64]:
    """Deprecated."""
    if transform is True:
        raise RuntimeError(
            "Previous `get_neighbors` with `transform=True` had different"
            " behaviour depending on the hyperparameter. Notably numerics"
            " were still considered to be in vectorized form while for ordinals"
            " they were considered to be in value form."
            "\nPlease use either `neighbors_vectorized` or `neighbors_values`"
            " instead, depending on your need. You can use `to_value` or"
            " `to_vector` to switch between the results of the two.",
        )

    if number is None:
        warnings.warn(
            "Please provide a number of neighbors to sample. The"
            " default used to be `4` but will be explicitly required"
            " in the futurefuture.",
            DeprecationWarning,
            stacklevel=2,
        )
        number = 4

    return self.neighbors_vectorized(value, number, std=std, seed=rs)

get_num_neighbors #

get_num_neighbors(
    value: ValueT | DType | _NotSet = NotSet,
) -> int | float

Get the number of neighbors to sample for a given value.

PARAMETER DESCRIPTION
value

The value to get the number of neighbors for. If None the default value is used. Defaults to None.

TYPE: ValueT | DType | _NotSet DEFAULT: NotSet

RETURNS DESCRIPTION
int | float

The number of neighbors to sample.

Source code in src/ConfigSpace/hyperparameters/hyperparameter.py
def get_num_neighbors(
    self,
    value: ValueT | DType | _NotSet = NotSet,
) -> int | float:
    """Get the number of neighbors to sample for a given value.

    Args:
        value:
            The value to get the number of neighbors for. If `None` the
            default value is used. Defaults to `None`.

    Returns:
        The number of neighbors to sample.
    """
    return (
        self._neighborhood_size(value)
        if callable(self._neighborhood_size)
        else self._neighborhood_size
    )

get_size #

get_size() -> int | float

Deprecated.

Source code in src/ConfigSpace/hyperparameters/hyperparameter.py
@deprecated("Please use `.size` attribute instead.")
def get_size(self) -> int | float:
    """Deprecated."""
    return self.size

has_neighbors #

has_neighbors() -> bool

Deprecated.

Source code in src/ConfigSpace/hyperparameters/hyperparameter.py
@deprecated("Please use `get_num_neighbors() > 0` or `hp.size > 1` instead.")
def has_neighbors(self) -> bool:
    """Deprecated."""
    return self.get_num_neighbors() > 0
is_legal(value: DType) -> bool

Deprecated.

Source code in src/ConfigSpace/hyperparameters/hyperparameter.py
@deprecated("Please use `legal_value(value)` instead")
def is_legal(self, value: DType) -> bool:
    """Deprecated."""
    return self.legal_value(value)
is_legal_vector(value: f64) -> bool

Deprecated.

Source code in src/ConfigSpace/hyperparameters/hyperparameter.py
@deprecated("Please use `legal_vector(vector)` instead.")
def is_legal_vector(self, value: f64) -> bool:
    """Deprecated."""
    return self.legal_vector(value)

legal_value #

legal_value(
    value: (
        ValueT
        | DType
        | Sequence[ValueT | DType]
        | Array[Any]
    ),
) -> bool | Mask

Check if a value is legal for this hyperparameter.

PARAMETER DESCRIPTION
value

The value to check.

TYPE: ValueT | DType | Sequence[ValueT | DType] | Array[Any]

RETURNS DESCRIPTION
bool | Mask

True if the value is legal, False otherwise. If value is an array of values, a mask of legal values is returned.

Source code in src/ConfigSpace/hyperparameters/hyperparameter.py
def legal_value(
    self,
    value: ValueT | DType | Sequence[ValueT | DType] | Array[Any],
) -> bool | Mask:
    """Check if a value is legal for this hyperparameter.

    Args:
        value:
            The value to check.

    Returns:
        `True` if the value is legal, `False` otherwise. If `value` is an
        array of values, a mask of legal values is returned.
    """
    if isinstance(value, np.ndarray):
        return self._transformer.legal_value(value)

    if isinstance(value, Sequence) and not isinstance(value, str):
        return self._transformer.legal_value(np.asarray(value))

    return self._transformer.legal_value_single(value)  # type: ignore

legal_vector #

legal_vector(vector: Number | Array[f64]) -> Mask | bool

Check if a vectorized value is legal for this hyperparameter.

PARAMETER DESCRIPTION
vector

The vectorized value to check.

TYPE: Number | Array[f64]

RETURNS DESCRIPTION
Mask | bool

True if the vector is legal, False otherwise. If vector is an array of vectors, a mask of legal values is returned.

Source code in src/ConfigSpace/hyperparameters/hyperparameter.py
def legal_vector(self, vector: Number | Array[f64]) -> Mask | bool:
    """Check if a vectorized value is legal for this hyperparameter.

    Args:
        vector:
            The vectorized value to check.

    Returns:
        `True` if the vector is legal, `False` otherwise. If `vector` is an
        array of vectors, a mask of legal values is returned.
    """
    if isinstance(vector, np.ndarray):
        if not np.issubdtype(vector.dtype, np.number):
            raise ValueError(
                "The vector must be of a numeric dtype to check for legality."
                f"Got {vector.dtype=} for {vector=}.",
            )
        return self._transformer.legal_vector(vector)

    if not isinstance(vector, (int, float, np.number)):
        return False

    return self._transformer.legal_vector_single(f64(vector))

neighbors_values #

neighbors_values(
    value: ValueT | DType,
    n: int,
    *,
    std: float | None = None,
    seed: RandomState | None = None
) -> Array[DType]

Sample neighbors of a value.

PARAMETER DESCRIPTION
value

The value to sample neighbors from.

TYPE: ValueT | DType

n

The number of unique neighbors to sample.

Warning

If there are less than n legal neighbors, then all legal neighbors are returned, which is some number less than n.

TYPE: int

std

The standard deviation of the neighborhood. If None the neighborhood is deterministic. Defaults to None.

Warning

Hyperparameter subclasses are under no obligation to use this if it does not make sense, i.e. for an OrdinalHyperparameter or a CategoricalHyperparameter.

TYPE: float | None DEFAULT: None

seed

The random state to use for sampling. If None the global random state is used. Defaults to None.

TYPE: RandomState | None DEFAULT: None

RETURNS DESCRIPTION
Array[DType]

The sampled neighbors in value space.

Source code in src/ConfigSpace/hyperparameters/hyperparameter.py
def neighbors_values(
    self,
    value: ValueT | DType,
    n: int,
    *,
    std: float | None = None,
    seed: np.random.RandomState | None = None,
) -> Array[DType]:
    """Sample neighbors of a value.

    Args:
        value:
            The value to sample neighbors from.
        n:
            The number of **unique** neighbors to sample.

            !!! warning

                If there are less than `n` legal neighbors, then all legal
                neighbors are returned, which is some number less than `n`.
        std:
            The standard deviation of the neighborhood. If `None` the
            neighborhood is deterministic. Defaults to `None`.

            !!! warning

                Hyperparameter subclasses are under no obligation to use
                this if it does not make sense, i.e. for an
                [`OrdinalHyperparameter`][ConfigSpace.hyperparameters.OrdinalHyperparameter]
                or a
                [`CategoricalHyperparameter`][ConfigSpace.hyperparameters.CategoricalHyperparameter].

        seed:
            The random state to use for sampling. If `None` the global
            random state is used. Defaults to `None`.

    Returns:
        The sampled neighbors in value space.
    """
    vector = self.to_vector(value)
    return self.to_value(
        vector=self.neighbors_vectorized(vector, n, std=std, seed=seed),
    )

neighbors_vectorized #

neighbors_vectorized(
    vector: Number,
    n: int,
    *,
    std: float | None = None,
    seed: RandomState | None = None
) -> Array[f64]

Sample neighbors of a vectorized value.

PARAMETER DESCRIPTION
vector

The vectorized value to sample neighbors from.

TYPE: Number

n

The number of unique neighbors to sample.

Warning

If there are less than n legal neighbors, then all legal neighbors are returned, which is some number less than n.

TYPE: int

std

The standard deviation of the neighborhood. If None the neighborhood is deterministic. Defaults to None.

Warning

Hyperparameter subclasses are under no obligation to use this if it does not make sense, i.e. for an OrdinalHyperparameter or a CategoricalHyperparameter.

TYPE: float | None DEFAULT: None

seed

The random state to use for sampling. If None the global random state is used. Defaults to None.

TYPE: RandomState | None DEFAULT: None

RETURNS DESCRIPTION
Array[f64]

The sampled neighbors in vectorized space.

Source code in src/ConfigSpace/hyperparameters/hyperparameter.py
def neighbors_vectorized(
    self,
    vector: Number,
    n: int,
    *,
    std: float | None = None,
    seed: np.random.RandomState | None = None,
) -> Array[f64]:
    """Sample neighbors of a vectorized value.

    Args:
        vector:
            The vectorized value to sample neighbors from.
        n:
            The number of **unique** neighbors to sample.

            !!! warning

                If there are less than `n` legal neighbors, then all legal
                neighbors are returned, which is some number less than `n`.
        std:
            The standard deviation of the neighborhood. If `None` the
            neighborhood is deterministic. Defaults to `None`.

            !!! warning

                Hyperparameter subclasses are under no obligation to use
                this if it does not make sense, i.e. for an
                [`OrdinalHyperparameter`][ConfigSpace.hyperparameters.OrdinalHyperparameter]
                or a
                [`CategoricalHyperparameter`][ConfigSpace.hyperparameters.CategoricalHyperparameter].

        seed:
            The random state to use for sampling. If `None` the global
            random state is used. Defaults to `None`.

    Returns:
        The sampled neighbors in vectorized space.
    """
    if std is not None:
        assert 0.0 <= std <= 1.0, f"std must be in [0, 1], got {std}"

    if not self.legal_vector(vector):
        raise ValueError(
            f"Vector value {vector} is not legal for hyperparameter '{self.name}'."
            f"\n{self}",
        )

    return self._neighborhood(f64(vector), n, std=std, seed=seed)

pdf #

pdf(vector: DType | Array[DType]) -> f64 | Array[f64]

Deprecated.

Source code in src/ConfigSpace/hyperparameters/hyperparameter.py
@deprecated("Please use `pdf_values(value)` instead.")
def pdf(
    self,
    vector: DType | Array[DType],  # NOTE: New convention this should be value
) -> f64 | Array[f64]:
    """Deprecated."""
    if isinstance(vector, np.ndarray):
        return self.pdf_values(vector)

    return self.pdf_values(np.asarray([vector]))[0]  # type: ignore

pdf_values #

pdf_values(
    values: Sequence[ValueT | DType] | Array[DType],
) -> Array[f64]

Get the probability density of an array of values.

PARAMETER DESCRIPTION
values

The values to get the probability density of.

TYPE: Sequence[ValueT | DType] | Array[DType]

RETURNS DESCRIPTION
Array[f64]

The probability density of the values. Where values are not legal, the probability density is zero.

Source code in src/ConfigSpace/hyperparameters/hyperparameter.py
def pdf_values(
    self,
    values: Sequence[ValueT | DType] | Array[DType],
) -> Array[f64]:
    """Get the probability density of an array of values.

    Args:
        values:
            The values to get the probability density of.

    Returns:
        The probability density of the values. Where values are not legal,
        the probability density is zero.
    """
    if isinstance(values, np.ndarray) and values.ndim != 1:
        raise ValueError("Method pdf expects a one-dimensional numpy array")

    vector = self.to_vector(values)
    return self.pdf_vector(vector)

pdf_vector #

pdf_vector(vector: Array[f64]) -> Array[f64]

Get the probability density of an array of vectorized values.

PARAMETER DESCRIPTION
vector

The vectorized values to get the probability density of.

TYPE: Array[f64]

RETURNS DESCRIPTION
Array[f64]

The probability density of the vectorized values. Where vectorized values are not legal, the probability density is zero.

Source code in src/ConfigSpace/hyperparameters/hyperparameter.py
def pdf_vector(self, vector: Array[f64]) -> Array[f64]:
    """Get the probability density of an array of vectorized values.

    Args:
        vector:
            The vectorized values to get the probability density of.

    Returns:
        The probability density of the vectorized values. Where vectorized
        values are not legal, the probability density is zero.
    """
    legal_mask: Array[f64] = self.legal_vector(vector).astype(f64)
    return self._vector_dist.pdf_vector(vector) * legal_mask

rvs #

rvs(
    size: int | None = None,
    *,
    random_state: (
        Generator | RandomState | int | None
    ) = None
) -> ValueT | Array[DType]

Sample a value from this hyperparameter, compatbile with scipy.stats.rvs.

PARAMETER DESCRIPTION
size

The number of values to sample. If None a single value is sampled. Defaults to None.

TYPE: int | None DEFAULT: None

random_state

The random state to use for sampling. If None the global random state is used. Defaults to None.

TYPE: Generator | RandomState | int | None DEFAULT: None

RETURNS DESCRIPTION
ValueT | Array[DType]

The sampled value or an array of sampled values, depending on size=.

Source code in src/ConfigSpace/hyperparameters/hyperparameter.py
def rvs(
    self,
    size: int | None = None,
    *,
    random_state: np.random.Generator | np.random.RandomState | int | None = None,
) -> ValueT | Array[DType]:
    """Sample a value from this hyperparameter, compatbile with scipy.stats.rvs.

    Args:
        size:
            The number of values to sample. If `None` a single value is
            sampled. Defaults to `None`.
        random_state:
            The random state to use for sampling. If `None` the global
            random state is used. Defaults to `None`.


    Returns:
        The sampled value or an array of sampled values, depending on `size=`.
    """
    if isinstance(random_state, int) or random_state is None:
        random_state = np.random.RandomState(random_state)
    elif isinstance(random_state, np.random.Generator):
        # HACK: This is to enable backwards compatibliity with numpy<=2.0,
        # where the default integer type is np.int32.
        MAX_INT = np.iinfo(np.int32).max
        random_state = np.random.RandomState(int(random_state.integers(0, MAX_INT)))

    vector = self.sample_vector(size=size, seed=random_state)
    return self.to_value(vector)

sample #

sample(rs: RandomState) -> ValueT

Deprecated.

Source code in src/ConfigSpace/hyperparameters/hyperparameter.py
@deprecated("Please use `sample_value(seed=rs)` instead.")
def sample(self, rs: np.random.RandomState) -> ValueT:
    """Deprecated."""
    return self.sample_value(seed=rs)

sample_value #

sample_value(
    size: int | None = None,
    *,
    seed: RandomState | None = None
) -> ValueT | Array[DType]

Sample a value from this hyperparameter.

PARAMETER DESCRIPTION
size

The number of values to sample. If None a single value is sampled. Defaults to None.

TYPE: int | None DEFAULT: None

seed

The random state to use for sampling. If None the global random state is used. Defaults to None.

TYPE: RandomState | None DEFAULT: None

RETURNS DESCRIPTION
ValueT | Array[DType]

The sampled value or an array of sampled values, depending on size=.

Source code in src/ConfigSpace/hyperparameters/hyperparameter.py
def sample_value(
    self,
    size: int | None = None,
    *,
    seed: np.random.RandomState | None = None,
) -> ValueT | Array[DType]:
    """Sample a value from this hyperparameter.

    Args:
        size:
            The number of values to sample. If `None` a single value is
            sampled. Defaults to `None`.
        seed:
            The random state to use for sampling. If `None` the global
            random state is used. Defaults to `None`.

    Returns:
        The sampled value or an array of sampled values, depending on `size=`.
    """
    samples = self.sample_vector(size=size, seed=seed)
    return self.to_value(samples)

sample_vector #

sample_vector(
    size: int | None = None,
    *,
    seed: RandomState | None = None
) -> f64 | Array[f64]

Sample a vectorized value from this hyperparameter.

PARAMETER DESCRIPTION
size

The number of values to sample. If None a single value is sampled. Defaults to None.

TYPE: int | None DEFAULT: None

seed

The random state to use for sampling. If None the global random state is used. Defaults to None.

TYPE: RandomState | None DEFAULT: None

RETURNS DESCRIPTION
f64 | Array[f64]

The sampled vector or an array of sampled vectors, depending on size=.

Source code in src/ConfigSpace/hyperparameters/hyperparameter.py
def sample_vector(
    self,
    size: int | None = None,
    *,
    seed: np.random.RandomState | None = None,
) -> f64 | Array[f64]:
    """Sample a vectorized value from this hyperparameter.

    Args:
        size:
            The number of values to sample. If `None` a single value is
            sampled. Defaults to `None`.
        seed:
            The random state to use for sampling. If `None` the global
            random state is used. Defaults to `None`.

    Returns:
        The sampled vector or an array of sampled vectors, depending on `size=`.
    """
    if size is None:
        return self._vector_dist.sample_vector(n=1, seed=seed)[0]  # type: ignore
    return self._vector_dist.sample_vector(n=size, seed=seed)

to_float #

Convert this hyperparameter to a normal float hyperparameter.

Source code in src/ConfigSpace/hyperparameters/normal_integer.py
def to_float(self) -> NormalFloatHyperparameter:
    """Convert this hyperparameter to a normal float hyperparameter."""
    from ConfigSpace.hyperparameters.normal_float import NormalFloatHyperparameter

    return NormalFloatHyperparameter(
        name=self.name,
        mu=self.mu,
        sigma=self.sigma,
        lower=self.lower,
        upper=self.upper,
        default_value=self.default_value,
        log=self.log,
    )

to_uniform #

Convert the hyperparameter to its uniform equivalent.

This will remove any distribution associated with it's vectorized representation.

Source code in src/ConfigSpace/hyperparameters/hyperparameter.py
def to_uniform(self) -> UniformIntegerHyperparameter:
    """Convert the hyperparameter to its uniform equivalent.

    This will remove any distribution associated with it's vectorized
    representation.
    """
    from ConfigSpace.hyperparameters.uniform_integer import (
        UniformIntegerHyperparameter,
    )

    return UniformIntegerHyperparameter(
        name=self.name,
        lower=self.lower,
        upper=self.upper,
        default_value=self.default_value,
        log=self.log,
        meta=self.meta,
    )

to_value #

to_value(
    vector: Number | Array[f64],
) -> ValueT | Array[DType]

Transform a vectorized value to a value in value space.

PARAMETER DESCRIPTION
vector

The vectorized value to transform.

TYPE: Number | Array[f64]

RETURNS DESCRIPTION
ValueT | Array[DType]

The value in value space.

Source code in src/ConfigSpace/hyperparameters/hyperparameter.py
def to_value(
    self,
    vector: Number | Array[f64],
) -> ValueT | Array[DType]:
    """Transform a vectorized value to a value in value space.

    Args:
        vector:
            The vectorized value to transform.

    Returns:
        The value in value space.
    """
    if isinstance(vector, np.ndarray):
        return self._transformer.to_value(vector)

    value: DType = self._transformer.to_value(np.array([vector]))[0]
    if self._value_cast is not None:
        return self._value_cast(value)

    return value  # type: ignore

to_vector #

to_vector(
    value: (
        ValueT
        | DType
        | Sequence[ValueT | DType]
        | Array[Any]
    ),
) -> f64 | Array[f64]

Transform a value to a vectorized value.

PARAMETER DESCRIPTION
value

The value to transform.

TYPE: ValueT | DType | Sequence[ValueT | DType] | Array[Any]

RETURNS DESCRIPTION
f64 | Array[f64]

The vectorized value.

Source code in src/ConfigSpace/hyperparameters/hyperparameter.py
def to_vector(
    self,
    value: ValueT | DType | Sequence[ValueT | DType] | Array[Any],
) -> f64 | Array[f64]:
    """Transform a value to a vectorized value.

    Args:
        value:
            The value to transform.

    Returns:
        The vectorized value.
    """
    if isinstance(value, np.ndarray):
        return self._transformer.to_vector(value)

    if isinstance(value, Sequence) and not isinstance(value, str):
        return self._transformer.to_vector(np.asarray(value))

    return self._transformer.to_vector(np.array([value]))[0]  # type: ignore