(
    dist_old: BaseDistribution, dist_new: BaseDistribution
)
A function to check compatibility of two distributions.

    Note that this method is not supposed to be called by library users.

    Args:
        dist_old: A distribution previously recorded in storage.
        dist_new: A distribution newly added to storage.

    Raises:
        ValueError:
            If different distribution kinds are set to ``dist_old`` and ``dist_new``,
            or ``dist_old.choices`` doesn't match ``dist_new.choices``
            for :class:`~optuna.distributions.CategoricalDistribution`.
A function to check compatibility of two distributions.
A function to check compatibility of two distributions .
def check_distribution_compatibility(
    dist_old: BaseDistribution, dist_new: BaseDistribution
) -> None:
    """A function to check compatibility of two distributions.

    Note that this method is not supposed to be called by library users.

    Args:
        dist_old: A distribution previously recorded in storage.
        dist_new: A distribution newly added to storage.

    Raises:
        ValueError:
            If different distribution kinds are set to ``dist_old`` and ``dist_new``,
            or ``dist_old.choices`` doesn't match ``dist_new.choices``
            for :class:`~optuna.distributions.CategoricalDistribution`.
    """

    if dist_old.__class__ != dist_new.__class__:
        raise ValueError("Cannot set different distribution kind to the same parameter name.")

    if not isinstance(dist_old, CategoricalDistribution):
        return
    if not isinstance(dist_new, CategoricalDistribution):
        return
    if dist_old.choices != dist_new.choices:
        raise ValueError(
            CategoricalDistribution.__name__ + " does not support dynamic value space."
        )
def check_distribution_compatibility ( dist_old : BaseDistribution , dist_new : BaseDistribution ) -> None : if dist_old . __class__ != dist_new . __class__ : raise ValueError ( "Cannot set different distribution kind to the same parameter name." ) if not isinstance ( dist_old , CategoricalDistribution ) : return if not isinstance ( dist_new , CategoricalDistribution ) : return if dist_old . choices != dist_new . choices : raise ValueError ( CategoricalDistribution . __name__ + " does not support dynamic value space." )