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

Blosc throws floating point exception when encoding NumPy array with zero-itemsize dtype #516

Open
li-dan opened this issue Mar 21, 2024 · 0 comments
Labels

Comments

@li-dan
Copy link

li-dan commented Mar 21, 2024

Minimal, reproducible code sample, a copy-pastable example if possible

import numcodecs, numpy; numcodecs.Blosc().encode(numpy.zeros((5,), dtype=[('foo', int, (0,))]))

Problem description

This throws a floating point exception:

$ python -c "import numcodecs, numpy; numcodecs.Blosc().encode(numpy.zeros((5,), dtype=[('foo', int, (0,))]))"
Floating point exception (core dumped)

The expected output is that the array is encoded without an exception.

The array has ndarray.nbytes=0 and ndarray.dtype.itemsize=0. NumCodecs passes these into Blosc, and eventually compute_blocksize gets called with typesize=0 and nbytes=0, causing compute_blocksize to return 0. This triggers a floating point exception on this line in initialize_context_compression().

Version and installation information

  • NumCodecs 0.12.1
  • Python 3.11.4
  • Linux
  • NumCodecs was installed using pip into a virtual environment
@dstansby dstansby added the bug label Aug 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants