Skip to content

Commit 1acf0d6

Browse files
Revert "DEPR: make_block (#56422)" (#56481)
This reverts commit b0ffccd.
1 parent 752dede commit 1acf0d6

File tree

6 files changed

+12
-35
lines changed

6 files changed

+12
-35
lines changed

doc/source/whatsnew/v2.2.0.rst

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 10 deletions
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

Lines changed: 1 addition & 3 deletions
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

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1377,11 +1377,9 @@ def test_validate_ndim():
13771377
values = np.array([1.0, 2.0])
13781378
placement = BlockPlacement(slice(2))
13791379
msg = r"Wrong number of dimensions. values.ndim != ndim \[1 != 2\]"
1380-
depr_msg = "make_block is deprecated"
13811380

13821381
with pytest.raises(ValueError, match=msg):
1383-
with tm.assert_produces_warning(DeprecationWarning, match=depr_msg):
1384-
make_block(values, placement, ndim=2)
1382+
make_block(values, placement, ndim=2)
13851383

13861384

13871385
def test_block_shape():
@@ -1396,29 +1394,23 @@ def test_make_block_no_pandas_array(block_maker):
13961394
# https://github.com/pandas-dev/pandas/pull/24866
13971395
arr = pd.arrays.NumpyExtensionArray(np.array([1, 2]))
13981396

1399-
warn = None if block_maker is not make_block else DeprecationWarning
1400-
msg = "make_block is deprecated and will be removed in a future version"
1401-
14021397
# NumpyExtensionArray, no dtype
1403-
with tm.assert_produces_warning(warn, match=msg):
1404-
result = block_maker(arr, BlockPlacement(slice(len(arr))), ndim=arr.ndim)
1398+
result = block_maker(arr, BlockPlacement(slice(len(arr))), ndim=arr.ndim)
14051399
assert result.dtype.kind in ["i", "u"]
14061400

14071401
if block_maker is make_block:
14081402
# new_block requires caller to unwrap NumpyExtensionArray
14091403
assert result.is_extension is False
14101404

14111405
# NumpyExtensionArray, NumpyEADtype
1412-
with tm.assert_produces_warning(warn, match=msg):
1413-
result = block_maker(arr, slice(len(arr)), dtype=arr.dtype, ndim=arr.ndim)
1406+
result = block_maker(arr, slice(len(arr)), dtype=arr.dtype, ndim=arr.ndim)
14141407
assert result.dtype.kind in ["i", "u"]
14151408
assert result.is_extension is False
14161409

14171410
# new_block no longer taked dtype keyword
14181411
# ndarray, NumpyEADtype
1419-
with tm.assert_produces_warning(warn, match=msg):
1420-
result = block_maker(
1421-
arr.to_numpy(), slice(len(arr)), dtype=arr.dtype, ndim=arr.ndim
1422-
)
1412+
result = block_maker(
1413+
arr.to_numpy(), slice(len(arr)), dtype=arr.dtype, ndim=arr.ndim
1414+
)
14231415
assert result.dtype.kind in ["i", "u"]
14241416
assert result.is_extension is False

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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 3 additions & 6 deletions
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)