Skip to content

Commit fc3d938

Browse files
jorisvandenbosschemeeseeksmachine
authored andcommitted
Backport PR pandas-dev#56481: Revert "DEPR: make_block (pandas-dev#56422)"
1 parent 922a671 commit fc3d938

File tree

6 files changed

+12
-35
lines changed

6 files changed

+12
-35
lines changed

doc/source/whatsnew/v2.2.0.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,6 @@ Other Deprecations
662662
- Changed :meth:`Timedelta.resolution_string` to return ``h``, ``min``, ``s``, ``ms``, ``us``, and ``ns`` instead of ``H``, ``T``, ``S``, ``L``, ``U``, and ``N``, for compatibility with respective deprecations in frequency aliases (:issue:`52536`)
663663
- Deprecated :attr:`offsets.Day.delta`, :attr:`offsets.Hour.delta`, :attr:`offsets.Minute.delta`, :attr:`offsets.Second.delta`, :attr:`offsets.Milli.delta`, :attr:`offsets.Micro.delta`, :attr:`offsets.Nano.delta`, use ``pd.Timedelta(obj)`` instead (:issue:`55498`)
664664
- Deprecated :func:`pandas.api.types.is_interval` and :func:`pandas.api.types.is_period`, use ``isinstance(obj, pd.Interval)`` and ``isinstance(obj, pd.Period)`` instead (:issue:`55264`)
665-
- Deprecated :func:`pd.core.internals.api.make_block`, use public APIs instead (:issue:`40226`)
666665
- Deprecated :func:`read_gbq` and :meth:`DataFrame.to_gbq`. Use ``pandas_gbq.read_gbq`` and ``pandas_gbq.to_gbq`` instead https://pandas-gbq.readthedocs.io/en/latest/api.html (:issue:`55525`)
667666
- Deprecated :meth:`.DataFrameGroupBy.fillna` and :meth:`.SeriesGroupBy.fillna`; use :meth:`.DataFrameGroupBy.ffill`, :meth:`.DataFrameGroupBy.bfill` for forward and backward filling or :meth:`.DataFrame.fillna` to fill with a single value (or the Series equivalents) (:issue:`55718`)
668667
- Deprecated :meth:`DateOffset.is_anchored`, use ``obj.n == 1`` for non-Tick subclasses (for Tick this was always False) (:issue:`55388`)
@@ -722,6 +721,7 @@ Other Deprecations
722721
- Deprecated the extension test classes ``BaseNoReduceTests``, ``BaseBooleanReduceTests``, and ``BaseNumericReduceTests``, use ``BaseReduceTests`` instead (:issue:`54663`)
723722
- Deprecated the option ``mode.data_manager`` and the ``ArrayManager``; only the ``BlockManager`` will be available in future versions (:issue:`55043`)
724723
- Deprecated the previous implementation of :class:`DataFrame.stack`; specify ``future_stack=True`` to adopt the future version (:issue:`53515`)
724+
-
725725

726726
.. ---------------------------------------------------------------------------
727727
.. _whatsnew_220.performance:

pandas/core/internals/api.py

+1-10
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,10 @@
99
from __future__ import annotations
1010

1111
from typing import TYPE_CHECKING
12-
import warnings
1312

1413
import numpy as np
1514

1615
from pandas._libs.internals import BlockPlacement
17-
from pandas.util._exceptions import find_stack_level
1816

1917
from pandas.core.dtypes.common import pandas_dtype
2018
from pandas.core.dtypes.dtypes import (
@@ -52,14 +50,6 @@ def make_block(
5250
- Block.make_block_same_class
5351
- Block.__init__
5452
"""
55-
warnings.warn(
56-
# GH#40226
57-
"make_block is deprecated and will be removed in a future version. "
58-
"Use public APIs instead.",
59-
DeprecationWarning,
60-
stacklevel=find_stack_level(),
61-
)
62-
6353
if dtype is not None:
6454
dtype = pandas_dtype(dtype)
6555

@@ -123,6 +113,7 @@ def maybe_infer_ndim(values, placement: BlockPlacement, ndim: int | None) -> int
123113

124114
def __getattr__(name: str):
125115
# GH#55139
116+
import warnings
126117

127118
if name in [
128119
"Block",

pandas/tests/internals/test_api.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,7 @@ def test_deprecations(name):
6868
def test_make_block_2d_with_dti():
6969
# GH#41168
7070
dti = pd.date_range("2012", periods=3, tz="UTC")
71-
msg = "make_block is deprecated"
72-
with tm.assert_produces_warning(DeprecationWarning, match=msg):
73-
blk = api.make_block(dti, placement=[0])
71+
blk = api.make_block(dti, placement=[0])
7472

7573
assert blk.shape == (1, 3)
7674
assert blk.values.shape == (1, 3)

pandas/tests/internals/test_internals.py

+6-14
Original file line numberDiff line numberDiff line change
@@ -1383,11 +1383,9 @@ def test_validate_ndim():
13831383
values = np.array([1.0, 2.0])
13841384
placement = BlockPlacement(slice(2))
13851385
msg = r"Wrong number of dimensions. values.ndim != ndim \[1 != 2\]"
1386-
depr_msg = "make_block is deprecated"
13871386

13881387
with pytest.raises(ValueError, match=msg):
1389-
with tm.assert_produces_warning(DeprecationWarning, match=depr_msg):
1390-
make_block(values, placement, ndim=2)
1388+
make_block(values, placement, ndim=2)
13911389

13921390

13931391
def test_block_shape():
@@ -1402,29 +1400,23 @@ def test_make_block_no_pandas_array(block_maker):
14021400
# https://github.com/pandas-dev/pandas/pull/24866
14031401
arr = pd.arrays.NumpyExtensionArray(np.array([1, 2]))
14041402

1405-
warn = None if block_maker is not make_block else DeprecationWarning
1406-
msg = "make_block is deprecated and will be removed in a future version"
1407-
14081403
# NumpyExtensionArray, no dtype
1409-
with tm.assert_produces_warning(warn, match=msg):
1410-
result = block_maker(arr, BlockPlacement(slice(len(arr))), ndim=arr.ndim)
1404+
result = block_maker(arr, BlockPlacement(slice(len(arr))), ndim=arr.ndim)
14111405
assert result.dtype.kind in ["i", "u"]
14121406

14131407
if block_maker is make_block:
14141408
# new_block requires caller to unwrap NumpyExtensionArray
14151409
assert result.is_extension is False
14161410

14171411
# NumpyExtensionArray, NumpyEADtype
1418-
with tm.assert_produces_warning(warn, match=msg):
1419-
result = block_maker(arr, slice(len(arr)), dtype=arr.dtype, ndim=arr.ndim)
1412+
result = block_maker(arr, slice(len(arr)), dtype=arr.dtype, ndim=arr.ndim)
14201413
assert result.dtype.kind in ["i", "u"]
14211414
assert result.is_extension is False
14221415

14231416
# new_block no longer taked dtype keyword
14241417
# ndarray, NumpyEADtype
1425-
with tm.assert_produces_warning(warn, match=msg):
1426-
result = block_maker(
1427-
arr.to_numpy(), slice(len(arr)), dtype=arr.dtype, ndim=arr.ndim
1428-
)
1418+
result = block_maker(
1419+
arr.to_numpy(), slice(len(arr)), dtype=arr.dtype, ndim=arr.ndim
1420+
)
14291421
assert result.dtype.kind in ["i", "u"]
14301422
assert result.is_extension is False

pandas/tests/io/parser/common/test_chunksize.py

-1
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,6 @@ def test_chunks_have_consistent_numerical_type(all_parsers, monkeypatch):
233233
assert result.a.dtype == float
234234

235235

236-
@pytest.mark.filterwarnings("ignore:make_block is deprecated:FutureWarning")
237236
def test_warn_if_chunks_have_mismatched_type(all_parsers):
238237
warning_type = None
239238
parser = all_parsers

pandas/tests/io/parser/test_parse_dates.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,9 @@
3333

3434
from pandas.io.parsers import read_csv
3535

36-
pytestmark = [
37-
pytest.mark.filterwarnings(
38-
"ignore:Passing a BlockManager to DataFrame:DeprecationWarning"
39-
),
40-
pytest.mark.filterwarnings("ignore:make_block is deprecated:DeprecationWarning"),
41-
]
36+
pytestmark = pytest.mark.filterwarnings(
37+
"ignore:Passing a BlockManager to DataFrame:DeprecationWarning"
38+
)
4239

4340
xfail_pyarrow = pytest.mark.usefixtures("pyarrow_xfail")
4441
skip_pyarrow = pytest.mark.usefixtures("pyarrow_skip")

0 commit comments

Comments
 (0)