Skip to content
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

CLN: enforce the deprecation of exposing blocks in core.internals #58467

Merged
41 changes: 0 additions & 41 deletions pandas/core/internals/__init__.py
Expand Up @@ -18,46 +18,5 @@

def __getattr__(name: str):
# GH#55139
import warnings
twoertwein marked this conversation as resolved.
Show resolved Hide resolved

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,
# https://github.com/pandas-dev/pandas/pull/55139#pullrequestreview-1720690758
# on hard-coding stacklevel
stacklevel=2,
)
from pandas.core.internals.managers import create_block_manager_from_blocks

return create_block_manager_from_blocks

if name in [
"Block",
"ExtensionBlock",
"DatetimeTZBlock",
]:
warnings.warn(
f"{name} is deprecated and will be removed in a future version. "
"Use public APIs instead.",
DeprecationWarning,
# https://github.com/pandas-dev/pandas/pull/55139#pullrequestreview-1720690758
# on hard-coding stacklevel
stacklevel=2,
)
if name == "DatetimeTZBlock":
from pandas.core.internals.blocks import DatetimeTZBlock

return DatetimeTZBlock
elif name == "ExtensionBlock":
from pandas.core.internals.blocks import ExtensionBlock

return ExtensionBlock
else:
from pandas.core.internals.blocks import Block

return Block

raise AttributeError(f"module 'pandas.core.internals' has no attribute '{name}'")
27 changes: 0 additions & 27 deletions pandas/tests/internals/test_api.py
Expand Up @@ -41,21 +41,6 @@ def test_namespace():
assert set(result) == set(expected + modules)


@pytest.mark.parametrize(
"name",
[
"Block",
"ExtensionBlock",
"DatetimeTZBlock",
],
)
def test_deprecations(name):
# GH#55139
msg = f"{name} is deprecated.* Use public APIs instead"
with tm.assert_produces_warning(DeprecationWarning, match=msg):
getattr(internals, name)


def test_make_block_2d_with_dti():
# GH#41168
dti = pd.date_range("2012", periods=3, tz="UTC")
Expand All @@ -65,18 +50,6 @@ def test_make_block_2d_with_dti():
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


def test_create_dataframe_from_blocks(float_frame):
block = float_frame._mgr.blocks[0]
index = float_frame.index.copy()
Expand Down