Skip to content

Commit c3014ab

Browse files
authored
DEPR: Enforce deprecation of ArrayManager (#57118)
* DEPR: Enforce deprecation of ArrayManager * cleanups * More removals * whatsnew * Cleanups * More removals and whatsnew * cleanup
1 parent c3f7fee commit c3014ab

35 files changed

+103
-1929
lines changed

asv_bench/benchmarks/frame_methods.py

-2
Original file line numberDiff line numberDiff line change
@@ -593,8 +593,6 @@ def setup(self):
593593
N = 10000
594594
# this is the worst case, where every column has NaNs.
595595
arr = np.random.randn(N, 100)
596-
# NB: we need to set values in array, not in df.values, otherwise
597-
# the benchmark will be misleading for ArrayManager
598596
arr[::2] = np.nan
599597

600598
self.df = DataFrame(arr)

doc/source/whatsnew/v3.0.0.rst

+2
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ Removal of prior version deprecations/changes
104104
- Removed :meth:`DataFrameGroupby.fillna` and :meth:`SeriesGroupBy.fillna` (:issue:`55719`)
105105
- Removed ``axis`` argument from all groupby operations (:issue:`50405`)
106106
- Removed deprecated argument ``obj`` in :meth:`.DataFrameGroupBy.get_group` and :meth:`.SeriesGroupBy.get_group` (:issue:`53545`)
107+
- Removed the ``ArrayManager`` (:issue:`55043`)
108+
-
107109

108110
.. ---------------------------------------------------------------------------
109111
.. _whatsnew_300.performance:

pandas/__init__.py

+1-12
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from __future__ import annotations
22

3-
import os
43
import warnings
54

65
__docformat__ = "restructuredtext"
@@ -193,16 +192,6 @@
193192
__git_version__ = v.get("full-revisionid")
194193
del get_versions, v
195194

196-
# GH#55043 - deprecation of the data_manager option
197-
if "PANDAS_DATA_MANAGER" in os.environ:
198-
warnings.warn(
199-
"The env variable PANDAS_DATA_MANAGER is set. The data_manager option is "
200-
"deprecated and will be removed in a future version. Only the BlockManager "
201-
"will be available. Unset this environment variable to silence this warning.",
202-
FutureWarning,
203-
stacklevel=2,
204-
)
205-
206195
# DeprecationWarning for missing pyarrow
207196
from pandas.compat.pyarrow import pa_version_under10p1, pa_not_found
208197

@@ -232,7 +221,7 @@
232221
del VERSIONS, pa_msg
233222

234223
# Delete all unnecessary imported modules
235-
del pa_version_under10p1, pa_not_found, warnings, os
224+
del pa_version_under10p1, pa_not_found, warnings
236225

237226
# module level doc-string
238227
__doc__ = """

pandas/_config/__init__.py

+2-8
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,12 @@
3333

3434
def using_copy_on_write() -> bool:
3535
_mode_options = _global_config["mode"]
36-
return (
37-
_mode_options["copy_on_write"] is True
38-
and _mode_options["data_manager"] == "block"
39-
)
36+
return _mode_options["copy_on_write"] is True
4037

4138

4239
def warn_copy_on_write() -> bool:
4340
_mode_options = _global_config["mode"]
44-
return (
45-
_mode_options["copy_on_write"] == "warn"
46-
and _mode_options["data_manager"] == "block"
47-
)
41+
return _mode_options["copy_on_write"] == "warn"
4842

4943

5044
def using_nullable_dtypes() -> bool:

pandas/_typing.py

+1-7
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,7 @@
6161
)
6262
from pandas.core.indexes.base import Index
6363
from pandas.core.internals import (
64-
ArrayManager,
6564
BlockManager,
66-
SingleArrayManager,
6765
SingleBlockManager,
6866
)
6967
from pandas.core.resample import Resampler
@@ -382,11 +380,7 @@ def closed(self) -> bool:
382380
]
383381

384382
# internals
385-
Manager = Union[
386-
"ArrayManager", "SingleArrayManager", "BlockManager", "SingleBlockManager"
387-
]
388-
SingleManager = Union["SingleArrayManager", "SingleBlockManager"]
389-
Manager2D = Union["ArrayManager", "BlockManager"]
383+
Manager = Union["BlockManager", "SingleBlockManager"]
390384

391385
# indexing
392386
# PositionalIndexer -> valid 1D positional indexer, e.g. can pass

pandas/conftest.py

+2-10
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@
4848
utc,
4949
)
5050

51-
from pandas._config.config import _get_option
52-
5351
import pandas.util._test_decorators as td
5452

5553
from pandas.core.dtypes.dtypes import (
@@ -1965,21 +1963,15 @@ def using_copy_on_write() -> bool:
19651963
"""
19661964
Fixture to check if Copy-on-Write is enabled.
19671965
"""
1968-
return (
1969-
pd.options.mode.copy_on_write is True
1970-
and _get_option("mode.data_manager", silent=True) == "block"
1971-
)
1966+
return pd.options.mode.copy_on_write is True
19721967

19731968

19741969
@pytest.fixture
19751970
def warn_copy_on_write() -> bool:
19761971
"""
19771972
Fixture to check if Copy-on-Write is in warning mode.
19781973
"""
1979-
return (
1980-
pd.options.mode.copy_on_write == "warn"
1981-
and _get_option("mode.data_manager", silent=True) == "block"
1982-
)
1974+
return pd.options.mode.copy_on_write == "warn"
19831975

19841976

19851977
@pytest.fixture

pandas/core/apply.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1256,7 +1256,7 @@ def series_generator(self) -> Generator[Series, None, None]:
12561256
ser = self.obj._ixs(0, axis=0)
12571257
mgr = ser._mgr
12581258

1259-
is_view = mgr.blocks[0].refs.has_reference() # type: ignore[union-attr]
1259+
is_view = mgr.blocks[0].refs.has_reference()
12601260

12611261
if isinstance(ser.dtype, ExtensionDtype):
12621262
# values will be incorrect for this block
@@ -1278,7 +1278,7 @@ def series_generator(self) -> Generator[Series, None, None]:
12781278
# -> if that happened and `ser` is already a copy, then we reset
12791279
# the refs here to avoid triggering a unnecessary CoW inside the
12801280
# applied function (https://github.com/pandas-dev/pandas/pull/56212)
1281-
mgr.blocks[0].refs = BlockValuesRefs(mgr.blocks[0]) # type: ignore[union-attr]
1281+
mgr.blocks[0].refs = BlockValuesRefs(mgr.blocks[0])
12821282
yield ser
12831283

12841284
@staticmethod

pandas/core/arraylike.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -263,10 +263,7 @@ def array_ufunc(self, ufunc: np.ufunc, method: str, *inputs: Any, **kwargs: Any)
263263
Series,
264264
)
265265
from pandas.core.generic import NDFrame
266-
from pandas.core.internals import (
267-
ArrayManager,
268-
BlockManager,
269-
)
266+
from pandas.core.internals import BlockManager
270267

271268
cls = type(self)
272269

@@ -350,7 +347,7 @@ def _reconstruct(result):
350347
if method == "outer":
351348
raise NotImplementedError
352349
return result
353-
if isinstance(result, (BlockManager, ArrayManager)):
350+
if isinstance(result, BlockManager):
354351
# we went through BlockManager.apply e.g. np.sqrt
355352
result = self._constructor_from_mgr(result, axes=result.axes)
356353
else:

pandas/core/config_init.py

-26
Original file line numberDiff line numberDiff line change
@@ -436,32 +436,6 @@ def use_inf_as_na_cb(key) -> None:
436436
"version. Convert inf values to NaN before operating instead.",
437437
)
438438

439-
data_manager_doc = """
440-
: string
441-
Internal data manager type; can be "block" or "array". Defaults to "block",
442-
unless overridden by the 'PANDAS_DATA_MANAGER' environment variable (needs
443-
to be set before pandas is imported).
444-
"""
445-
446-
447-
with cf.config_prefix("mode"):
448-
cf.register_option(
449-
"data_manager",
450-
# Get the default from an environment variable, if set, otherwise defaults
451-
# to "block". This environment variable can be set for testing.
452-
os.environ.get("PANDAS_DATA_MANAGER", "block"),
453-
data_manager_doc,
454-
validator=is_one_of_factory(["block", "array"]),
455-
)
456-
457-
cf.deprecate_option(
458-
# GH#55043
459-
"mode.data_manager",
460-
"data_manager option is deprecated and will be removed in a future "
461-
"version. Only the BlockManager will be available.",
462-
)
463-
464-
465439
# TODO better name?
466440
copy_on_write_doc = """
467441
: bool

0 commit comments

Comments
 (0)