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

DEPR: enforce deprecations in core.internals #29723

Merged
merged 7 commits into from
Nov 22, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion doc/source/whatsnew/v1.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,8 @@ or ``matplotlib.Axes.plot``. See :ref:`plotting.formatters` for more.
- Removed the previously deprecated ``assert_raises_regex`` function in ``pandas.util.testing`` (:issue:`29174`)
- Removed :meth:`Index.is_lexsorted_for_tuple` (:issue:`29305`)
- Removed support for nexted renaming in :meth:`DataFrame.aggregate`, :meth:`Series.aggregate`, :meth:`DataFrameGroupBy.aggregate`, :meth:`SeriesGroupBy.aggregate`, :meth:`Rolling.aggregate` (:issue:`29608`)
-
- :func:`core.internals.blocks.make_block` no longer accepts the "fastpath" keyword(:issue:`19265`)
- :meth:`Block.make_block_same_class` no longer accepts the "dtype" keyword(:issue:`19434`)

.. _whatsnew_1000.performance:

Expand Down
20 changes: 3 additions & 17 deletions pandas/core/internals/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,21 +251,13 @@ def make_block(self, values, placement=None):

return make_block(values, placement=placement, ndim=self.ndim)

def make_block_same_class(self, values, placement=None, ndim=None, dtype=None):
def make_block_same_class(self, values, placement=None, ndim=None):
""" Wrap given values in a block of same type as self. """
if dtype is not None:
# issue 19431 fastparquet is passing this
warnings.warn(
"dtype argument is deprecated, will be removed in a future release.",
FutureWarning,
)
if placement is None:
placement = self.mgr_locs
if ndim is None:
ndim = self.ndim
return make_block(
values, placement=placement, ndim=ndim, klass=self.__class__, dtype=dtype
)
return make_block(values, placement=placement, ndim=ndim, klass=self.__class__)

def __repr__(self) -> str:
# don't want to print out all of the items here
Expand Down Expand Up @@ -2999,7 +2991,7 @@ def get_block_type(values, dtype=None):
return cls


def make_block(values, placement, klass=None, ndim=None, dtype=None, fastpath=None):
def make_block(values, placement, klass=None, ndim=None, dtype=None):
# Ensure that we don't allow PandasArray / PandasDtype in internals.
# For now, blocks should be backed by ndarrays when possible.
if isinstance(values, ABCPandasArray):
Expand All @@ -3010,12 +3002,6 @@ def make_block(values, placement, klass=None, ndim=None, dtype=None, fastpath=No
if isinstance(dtype, PandasDtype):
dtype = dtype.numpy_dtype

if fastpath is not None:
# GH#19265 pyarrow is passing this
warnings.warn(
"fastpath argument is deprecated, will be removed in a future release.",
FutureWarning,
)
if klass is None:
dtype = dtype or values.dtype
klass = get_block_type(values, dtype)
Expand Down
10 changes: 2 additions & 8 deletions pandas/tests/internals/test_internals.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,8 @@ def test_delete(self):
def test_make_block_same_class(self):
# issue 19431
block = create_block("M8[ns, US/Eastern]", [3])
with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
with pytest.raises(TypeError, match="unexpected keyword"):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we just remove the dtype argument from this test instead of catching this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

without the dtpye kwarg its just a smoke test, at which point id rather just remove this test (which id be completely fine with)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think OK then. As is this isn't testing anything pandas related just the stdlib

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*OK to remove

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

# Deprecation enforced as of GH#????
block.make_block_same_class(block.values, dtype=block.values.dtype)


Expand Down Expand Up @@ -1255,13 +1256,6 @@ def test_holder(typestr, holder):
assert blk._holder is holder


def test_deprecated_fastpath():
# GH#19265
values = np.random.rand(3, 3)
with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
make_block(values, placement=np.arange(3), fastpath=True)


def test_validate_ndim():
values = np.array([1.0, 2.0])
placement = slice(2)
Expand Down