Skip to content

Commit

Permalink
DEPR: create_block_manager_from_blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
jbrockmendel committed Oct 2, 2023
1 parent 6f0cd8d commit af43a60
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
13 changes: 12 additions & 1 deletion pandas/core/internals/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
from pandas.core.internals.managers import (
BlockManager,
SingleBlockManager,
create_block_manager_from_blocks,
)

__all__ = [
Expand All @@ -41,6 +40,18 @@ def __getattr__(name: str):

from pandas.util._exceptions import find_stack_level

if name == "create_block_manager_from_blocks":
# GH#33892
warnings.warn(
f"{name} is deprecated and will be removed in a future version. "
"Use public APIs instead.",
DeprecationWarning,
stacklevel=find_stack_level(),
)
from pandas.core.internals.managers import create_block_manager_from_blocks

return create_block_manager_from_blocks

if name in ["NumericBlock", "ObjectBlock"]:
warnings.warn(
f"{name} is deprecated and will be removed in a future version. "
Expand Down
14 changes: 13 additions & 1 deletion pandas/tests/internals/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"""

import pandas as pd
import pandas._testing as tm
from pandas.core import internals
from pandas.core.internals import api

Expand Down Expand Up @@ -37,7 +38,6 @@ def test_namespace():
"SingleBlockManager",
"SingleArrayManager",
"concatenate_managers",
"create_block_manager_from_blocks",
]

result = [x for x in dir(internals) if not x.startswith("__")]
Expand All @@ -51,3 +51,15 @@ def test_make_block_2d_with_dti():

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


def test_create_block_manager_from_blocks_deprecated():
# GH#33892
# If they must, downstream packages should get this from internals.api,
# not internals.
msg = (
"create_block_manager_from_blocks is deprecated and will be "
"removed in a future version. Use public APIs instead"
)
with tm.assert_produces_warning(DeprecationWarning, match=msg):
internals.create_block_manager_from_blocks

0 comments on commit af43a60

Please sign in to comment.