Skip to content

check_weighter_default_constructible

yohou.testing.check_weighter_default_constructible(weighter)

Check the weighter class is constructible with no arguments.

Parameters

Name Type Description Default
weighter BaseWeighter

Weighter instance (used for its type).

required

Raises

Type Description
AssertionError

If type(weighter)() raises.

Source Code

Source code in src/yohou/testing/weighter.py
def check_weighter_default_constructible(weighter) -> None:
    """Check the weighter class is constructible with no arguments.

    Parameters
    ----------
    weighter : BaseWeighter
        Weighter instance (used for its type).

    Raises
    ------
    AssertionError
        If ``type(weighter)()`` raises.

    """
    cls = type(weighter)
    try:
        cls()
    except Exception as e:  # noqa: BLE001
        raise AssertionError(f"{cls.__name__} is not default-constructible: {type(e).__name__}: {e}") from e