8000 Move test_get_adapter_from_container to test_set_output.py · patrickkwang/scikit-learn@b66a38d · GitHub
[go: up one dir, main page]

Skip to content

Commit b66a38d

Browse files
committed
Move test_get_adapter_from_container to test_set_output.py
1 parent e7c9890 commit b66a38d

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

sklearn/preprocessing/tests/test_function_transformer.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
from sklearn.pipeline import make_pipeline
77
from sklearn.preprocessing import FunctionTransformer, StandardScaler
8-
from sklearn.preprocessing._function_transformer import _get_adapter_from_container
98
from sklearn.utils._testing import (
109
_convert_container,
1110
assert_allclose_dense_sparse,
@@ -14,17 +13,6 @@
1413
from sklearn.utils.fixes import CSC_CONTAINERS, CSR_CONTAINERS
1514

1615

17-
def test_get_adapter_from_container():
18-
"""Check the behavior fo `_get_adapter_from_container`."""
19-
pd = pytest.importorskip("pandas")
20-
X = pd.DataFrame({"a": [1, 2, 3], "b": [10, 20, 100]})
21-
adapter = _get_adapter_from_container(X)
22-
assert adapter.container_lib == "pandas"
23-
err_msg = "The container does not have a registered adapter in scikit-learn."
24-
with pytest.raises(ValueError, match=err_msg):
25-
_get_adapter_from_container(X.to_numpy())
26-
27-
2816
def _make_func(args_store, kwargs_store, func=lambda X, *a, **k: X):
2917
def _func(X, *args, **kwargs):
3018
args_store.append(X)

sklearn/utils/tests/test_set_output.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from sklearn.utils._set_output import (
1111
ADAPTERS_MANAGER,
1212
ContainerAdapterProtocol,
13 8000 +
_get_adapter_from_container,
1314
_get_output_config,
1415
_safe_set_output,
1516
_SetOutputMixin,
@@ -450,3 +451,14 @@ def patched_import_module(name):
450451
msg = "Setting output container to 'pandas' requires"
451452
with pytest.raises(ImportError, match=msg):
452453
check_library_installed("pandas")
454+
455+
456+
def test_get_adapter_from_container():
457+
"""Check the behavior fo `_get_adapter_from_container`."""
458+
pd = pytest.importorskip("pandas")
459+
X = pd.DataFrame({"a": [1, 2, 3], "b": [10, 20, 100]})
460+
adapter = _get_adapter_from_container(X)
461+
assert adapter.container_lib == "pandas"
462+
err_msg = "The container does not have a registered adapter in scikit-learn."
463+
with pytest.raises(ValueError, match=err_msg):
464+
_get_adapter_from_container(X.to_numpy())

0 commit comments

Comments
 (0)
0