HEX
Server: Apache/2.4.46 (Win64) OpenSSL/1.1.1j PHP/8.4.25
System: Windows NT DESKTOP-4TAV2RJ 10.0 build 19045 (Windows 10) AMD64
User: fred (0)
PHP: 8.4.25
Disabled: NONE
Upload Files
File: C:/Users/fred/anaconda3/Lib/site-packages/imblearn/exceptions.py
"""
The :mod:`imblearn.exceptions` module includes all custom warnings and error
classes and functions used across imbalanced-learn.
"""

# Authors: Guillaume Lemaitre <[email protected]>
# License: MIT


def raise_isinstance_error(variable_name, possible_type, variable):
    """Raise consistent error message for isinstance() function.

    Parameters
    ----------
    variable_name : str
        The name of the variable.

    possible_type : type
        The possible type of the variable.

    variable : object
        The variable to check.

    Raises
    ------
    ValueError
        If the instance is not of the possible type.
    """
    raise ValueError(
        f"{variable_name} has to be one of {possible_type}. "
        f"Got {type(variable)} instead."
    )