CoolFace
Apppublic

Aluode/PerceptionLabPortable

sourceHugging Faceupdated 9mo agoView on Hugging Face
0likes
_optional_dependencies.py47 linesDownload Raw Back to utils
1# Authors: The scikit-learn developers
2# SPDX-License-Identifier: BSD-3-Clause
3
4
5def check_matplotlib_support(caller_name):
6    """Raise ImportError with detailed error message if mpl is not installed.
7
8    Plot utilities like any of the Display's plotting functions should lazily import
9    matplotlib and call this helper before any computation.
10
11    Parameters
12    ----------
13    caller_name : str
14        The name of the caller that requires matplotlib.
15    """
16    try:
17        import matplotlib  # noqa: F401
18    except ImportError as e:
19        raise ImportError(
20            "{} requires matplotlib. You can install matplotlib with "
21            "`pip install matplotlib`".format(caller_name)
22        ) from e
23
24
25def check_pandas_support(caller_name):
26    """Raise ImportError with detailed error message if pandas is not installed.
27
28    Plot utilities like :func:`fetch_openml` should lazily import
29    pandas and call this helper before any computation.
30
31    Parameters
32    ----------
33    caller_name : str
34        The name of the caller that requires pandas.
35
36    Returns
37    -------
38    pandas
39        The pandas package.
40    """
41    try:
42        import pandas
43
44        return pandas
45    except ImportError as e:
46        raise ImportError("{} requires pandas.".format(caller_name)) from e
47 
Aluode/PerceptionLabPortable · CoolFace