-
-
Notifications
You must be signed in to change notification settings - Fork 19.4k
DEPR: ArrayManager #55044
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DEPR: ArrayManager #55044
Changes from 9 commits
3dfd215
4741ec6
0f547ee
c183aee
ce37c9b
9fa9062
53afb47
99e1bfd
9992b37
d17d1bb
5618968
24f482c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,12 @@ | ||
| """ | ||
| Testing interaction between the different managers (BlockManager, ArrayManager) | ||
| """ | ||
| import os | ||
| import subprocess | ||
| import sys | ||
|
|
||
| import pytest | ||
|
|
||
| from pandas.core.dtypes.missing import array_equivalent | ||
|
|
||
| import pandas as pd | ||
|
|
@@ -14,12 +20,19 @@ | |
|
|
||
|
|
||
| def test_dataframe_creation(): | ||
| with pd.option_context("mode.data_manager", "block"): | ||
| df_block = pd.DataFrame({"a": [1, 2, 3], "b": [0.1, 0.2, 0.3], "c": [4, 5, 6]}) | ||
| msg = "data_manager option is deprecated" | ||
| with tm.assert_produces_warning(FutureWarning, match=msg): | ||
| with pd.option_context("mode.data_manager", "block"): | ||
| df_block = pd.DataFrame( | ||
| {"a": [1, 2, 3], "b": [0.1, 0.2, 0.3], "c": [4, 5, 6]} | ||
| ) | ||
| assert isinstance(df_block._mgr, BlockManager) | ||
|
|
||
| with pd.option_context("mode.data_manager", "array"): | ||
| df_array = pd.DataFrame({"a": [1, 2, 3], "b": [0.1, 0.2, 0.3], "c": [4, 5, 6]}) | ||
| with tm.assert_produces_warning(FutureWarning, match=msg): | ||
| with pd.option_context("mode.data_manager", "array"): | ||
| df_array = pd.DataFrame( | ||
| {"a": [1, 2, 3], "b": [0.1, 0.2, 0.3], "c": [4, 5, 6]} | ||
| ) | ||
| assert isinstance(df_array._mgr, ArrayManager) | ||
|
|
||
| # also ensure both are seen as equal | ||
|
|
@@ -45,12 +58,15 @@ def test_dataframe_creation(): | |
|
|
||
|
|
||
| def test_series_creation(): | ||
| with pd.option_context("mode.data_manager", "block"): | ||
| s_block = pd.Series([1, 2, 3], name="A", index=["a", "b", "c"]) | ||
| msg = "data_manager option is deprecated" | ||
| with tm.assert_produces_warning(FutureWarning, match=msg): | ||
| with pd.option_context("mode.data_manager", "block"): | ||
| s_block = pd.Series([1, 2, 3], name="A", index=["a", "b", "c"]) | ||
| assert isinstance(s_block._mgr, SingleBlockManager) | ||
|
|
||
| with pd.option_context("mode.data_manager", "array"): | ||
| s_array = pd.Series([1, 2, 3], name="A", index=["a", "b", "c"]) | ||
| with tm.assert_produces_warning(FutureWarning, match=msg): | ||
| with pd.option_context("mode.data_manager", "array"): | ||
| s_array = pd.Series([1, 2, 3], name="A", index=["a", "b", "c"]) | ||
| assert isinstance(s_array._mgr, SingleArrayManager) | ||
|
|
||
| # also ensure both are seen as equal | ||
|
|
@@ -68,3 +84,22 @@ def test_series_creation(): | |
| result = s_array._as_manager("block") | ||
| assert isinstance(result._mgr, SingleBlockManager) | ||
| tm.assert_series_equal(result, s_array) | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("manager", ["block", "array"]) | ||
| def test_array_manager_depr_env_var(manager): | ||
mroeschke marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| # GH#55043 | ||
| test_env = os.environ.copy() | ||
| test_env["PANDAS_DATA_MANAGER"] = manager | ||
| response = subprocess.run( | ||
| [sys.executable, "-c", "import pandas"], | ||
| capture_output=True, | ||
| env=test_env, | ||
| check=True, | ||
| ) | ||
| msg = "<string>:1: FutureWarning: Using ArrayManger through the environment" | ||
|
||
| stderr_msg = response.stderr.decode("utf-8") | ||
| if manager == "block": | ||
| assert msg not in stderr_msg, stderr_msg | ||
|
||
| else: | ||
| assert msg in stderr_msg, stderr_msg | ||
Uh oh!
There was an error while loading. Please reload this page.