Skip to content

BUG: fix construction of NonConsolidatableBlock with inconsistent ndim #27786

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
Aug 7, 2019

Conversation

jorisvandenbossche
Copy link
Member

@jorisvandenbossche jorisvandenbossche commented Aug 6, 2019

@jorisvandenbossche
Copy link
Member Author

cc @jbrockmendel

@@ -273,6 +273,8 @@ def make_block_same_class(self, values, placement=None, ndim=None, dtype=None):
)
if placement is None:
placement = self.mgr_locs
if ndim is None:
ndim = self.ndim
Copy link
Member Author

Choose a reason for hiding this comment

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

Alternative option is to pass self.ndim to the make_block_same_class call in Block.take_nd, but this might be more general for other locations where make_block_same_class is called without specifying ndim. I don't directly can think of a case where you don't want to preserve the ndim unless it was specified.

And eg make_block just above always uses self.ndim

Copy link
Member

Choose a reason for hiding this comment

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

This seems reasonable to me

@jorisvandenbossche jorisvandenbossche added Bug ExtensionArray Extending pandas with custom dtypes or arrays. labels Aug 6, 2019
@jorisvandenbossche jorisvandenbossche added this to the 0.25.1 milestone Aug 6, 2019
@jbrockmendel
Copy link
Member

I tried once to require that ndim be passed and found that some of the downstream tests failed because e.g. pyarrow uses make_block directly

@jorisvandenbossche
Copy link
Member Author

I tried once to require that ndim be passed

That's indeed another option to pass self.ndim to all calls to self.make_block_same_class (there are not too many of them I think), if you prefer.

e.g. pyarrow uses make_block directly

But this is self.make_block_same_class which is probably OK to do?

@jbrockmendel
Copy link
Member

But this is self.make_block_same_class which is probably OK to do?

Yah, looks like pyarrow is only calling the make_block function, not the methods.

@jreback jreback merged commit 38d2372 into pandas-dev:master Aug 7, 2019
@jreback
Copy link
Contributor

jreback commented Aug 7, 2019

thanks @jorisvandenbossche

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug ExtensionArray Extending pandas with custom dtypes or arrays.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: NonConsolidatebleBlock with ndim 1 'take_nd' with len 1 gives wrong ndim
3 participants