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

BUG: fix packbits and unpackbits to correctly handle empty arrays #8336

Merged
merged 1 commit into from
Dec 3, 2016

Conversation

charris
Copy link
Member

@charris charris commented Dec 3, 2016

This small PR addresses several problems of numpy.packbits pointed out in Issue #8324.

As discussed in Issue #8324, numpy.packbits have problems with regard to empty input arrays. Specifically:

  • the output does not necessarily always have uint8 dtype,
  • the shape of the returned array is inconsistent when axis is specified, and
  • there is a leak of an object (new).

The fundamental reason for these problems is common: function pack_bits in compiled_base.c handles empty arrays separately, in a rough manner. I could not figure out a good reason why we should handle empty arrays separately. Rather, I found that this part is indeed unnecessary, i.e., without this, pack_bits can handle empty arrays correctly, as confirmed in my new tests. So, I propose to remove that part to fix these problems.

@charris charris added this to the 1.12.0 release milestone Dec 3, 2016
@charris charris merged commit a481e8e into numpy:maintenance/1.12.x Dec 3, 2016
@charris charris deleted the backport-8327 branch December 3, 2016 22:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants