Skip to content

BUG: Fixed block placment from reindex(?) #24149

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

Merged
merged 1 commit into from
Dec 7, 2018

Conversation

TomAugspurger
Copy link
Contributor

Closes #24147

@TomAugspurger TomAugspurger added the Internals Related to non-user accessible pandas implementation label Dec 7, 2018
@TomAugspurger TomAugspurger added this to the 0.24.0 milestone Dec 7, 2018
@pep8speaks
Copy link

Hello @TomAugspurger! Thanks for submitting the PR.

@@ -64,7 +64,8 @@ cdef class BlockPlacement:

return '%s(%r)' % (self.__class__.__name__, v)

__repr__ = __str__
def __repr__(self):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure if this is a cython bug, but I wasn't getting a nice repr. without this change.

Copy link
Contributor

Choose a reason for hiding this comment

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

usually you would just do
__repr__ = __str__

Copy link
Contributor Author

@TomAugspurger TomAugspurger Dec 7, 2018

Choose a reason for hiding this comment

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

Indeed, that's what I deleted. But on master I get this for the repr.

In [1]: import pandas as pd; import numpy as np; import pickle

In [2]: pd.Series([1,2])._data._block.mgr_locs
Out[2]: <pandas._libs.internals.BlockPlacement object at 0x111b65048>

In [10]: x.__repr__
Out[10]: <method-wrapper '__str__' of pandas._libs.internals.BlockPlacement object at 0x10ed26278>

In [11]: repr(x)
Out[11]: '<pandas._libs.internals.BlockPlacement object at 0x10ed26278>'

In [12]: x.__repr__()
Out[12]: 'BlockPlacement(slice(0, 2, 1))'

I assume it's some behavior difference between Cython and Python.

@@ -1887,7 +1887,7 @@ def take_nd(self, indexer, axis=0, new_mgr_locs=None, fill_tuple=None):
allow_fill=True)

# if we are a 1-dim object, then always place at 0
if self.ndim == 1:
if self.ndim == 1 and new_mgr_locs is None:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have no idea if this is going to break things.

Oh and I notice that the comment is out of date now.

@@ -164,6 +164,15 @@ def test_combine_add(self, data_repeated):
orig_data1._from_sequence([a + val for a in list(orig_data1)]))
self.assert_series_equal(result, expected)

@pytest.mark.xfail(reason="GH-24147", strict=True)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a test for the original bug from the issue. Unfortunately, it doesn't run yet since Series.where loses the extension dtype. #24147 is fixing that.

@codecov
Copy link

codecov bot commented Dec 7, 2018

Codecov Report

Merging #24149 into master will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #24149      +/-   ##
==========================================
- Coverage    92.2%    92.2%   -0.01%     
==========================================
  Files         162      162              
  Lines       51700    51700              
==========================================
- Hits        47670    47669       -1     
- Misses       4030     4031       +1
Flag Coverage Δ
#multiple 90.6% <100%> (-0.01%) ⬇️
#single 43.02% <100%> (-0.01%) ⬇️
Impacted Files Coverage Δ
pandas/core/internals/blocks.py 93.65% <100%> (-0.07%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f492be6...3be6e0d. Read the comment docs.

1 similar comment
@codecov
Copy link

codecov bot commented Dec 7, 2018

Codecov Report

Merging #24149 into master will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #24149      +/-   ##
==========================================
- Coverage    92.2%    92.2%   -0.01%     
==========================================
  Files         162      162              
  Lines       51700    51700              
==========================================
- Hits        47670    47669       -1     
- Misses       4030     4031       +1
Flag Coverage Δ
#multiple 90.6% <100%> (-0.01%) ⬇️
#single 43.02% <100%> (-0.01%) ⬇️
Impacted Files Coverage Δ
pandas/core/internals/blocks.py 93.65% <100%> (-0.07%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f492be6...3be6e0d. Read the comment docs.

Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

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

small comment, lgtm otherwise

@@ -64,7 +64,8 @@ cdef class BlockPlacement:

return '%s(%r)' % (self.__class__.__name__, v)

__repr__ = __str__
def __repr__(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

usually you would just do
__repr__ = __str__

@jreback jreback added the Indexing Related to indexing on series/frames, not to indexes themselves label Dec 7, 2018
@TomAugspurger
Copy link
Contributor Author

Going to merge this now, and merge https://github.com/pandas-dev/pandas/pull/24114/files on top of it, which will enable the rest of the tests. I'll fix the stale comment in
https://github.com/pandas-dev/pandas/pull/24149/files/3be6e0dd9e848c90306e82f7333947efb4aa472f#diff-8f51ce8697bdff680b3f71b196c582ee as well.

@TomAugspurger TomAugspurger merged commit fc64ca8 into pandas-dev:master Dec 7, 2018
@TomAugspurger TomAugspurger deleted the internals-fixup branch December 7, 2018 22:05
Pingviinituutti pushed a commit to Pingviinituutti/pandas that referenced this pull request Feb 28, 2019
Pingviinituutti pushed a commit to Pingviinituutti/pandas that referenced this pull request Feb 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Indexing Related to indexing on series/frames, not to indexes themselves Internals Related to non-user accessible pandas implementation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants