test_fixes.py 925 B

1234567891011121314151617181920212223242526272829303132
  1. # Authors: Gael Varoquaux <gael.varoquaux@normalesup.org>
  2. # Justin Vincent
  3. # Lars Buitinck
  4. # License: BSD 3 clause
  5. import numpy as np
  6. import pytest
  7. from sklearn.utils._testing import assert_array_equal
  8. from sklearn.utils.fixes import _object_dtype_isnan, delayed
  9. @pytest.mark.parametrize("dtype, val", ([object, 1], [object, "a"], [float, 1]))
  10. def test_object_dtype_isnan(dtype, val):
  11. X = np.array([[val, np.nan], [np.nan, val]], dtype=dtype)
  12. expected_mask = np.array([[False, True], [True, False]])
  13. mask = _object_dtype_isnan(X)
  14. assert_array_equal(mask, expected_mask)
  15. def test_delayed_deprecation():
  16. """Check that we issue the FutureWarning regarding the deprecation of delayed."""
  17. def func(x):
  18. return x
  19. warn_msg = "The function `delayed` has been moved from `sklearn.utils.fixes`"
  20. with pytest.warns(FutureWarning, match=warn_msg):
  21. delayed(func)