Traktor/myenv/Lib/site-packages/sklearn/utils/tests/test_missing.py
2024-05-23 01:57:24 +02:00

28 lines
709 B
Python

import numpy as np
import pytest
from sklearn.utils._missing import is_scalar_nan
@pytest.mark.parametrize(
"value, result",
[
(float("nan"), True),
(np.nan, True),
(float(np.nan), True),
(np.float32(np.nan), True),
(np.float64(np.nan), True),
(0, False),
(0.0, False),
(None, False),
("", False),
("nan", False),
([np.nan], False),
(9867966753463435747313673, False), # Python int that overflows with C type
],
)
def test_is_scalar_nan(value, result):
assert is_scalar_nan(value) is result
# make sure that we are returning a Python bool
assert isinstance(is_scalar_nan(value), bool)