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

Numpy 2.0 has broken some (admittedly malformed) .tif files in decode_fill_value #1981

Open
NewSoupVi opened this issue Jun 18, 2024 · 1 comment
Labels
bug Potential issues with the zarr-python library

Comments

@NewSoupVi
Copy link

NewSoupVi commented Jun 18, 2024

Zarr version

2.18.2

Numcodecs version

0.12.1

Python Version

3.11

Operating System

Windows

Installation

pip venv

Description

I have a .tif file with dtype uint8, that reports a fill_value of -999999999

gdalinfo output for reference:
image

Obviously, this is impossible, meaning the tif file is malformed. But it did "just work" previously.
This line just returned 1, and the program would continue running happily.

Numpy 2.0, which came out yesterday, has made a change, though, that makes that line error with:

Traceback (most recent call last):
  File "D:\enpgt-toolbox\venv\Lib\site-packages\zarr\meta.py", line 127, in decode_array_metadata
    fill_value = cls.decode_fill_value(meta["fill_value"], dtype, object_codec)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\enpgt-toolbox\venv\Lib\site-packages\zarr\meta.py", line 260, in decode_fill_value
    return np.array(v, dtype=dtype)[()]
           ^^^^^^^^^^^^^^^^^^^^^^^^
OverflowError: Python integer -999999999 out of bounds for uint8

I'm not sure whether this is "your problem" necessarily, but it'd be nice if there were some sort of way around this change. I don't actually care about the fill value, I just want to be able to read this .tif normally, without having to make modifications to it. Which may be an "unreasonable goal", but I figured I'd at least ask / bring it up.

Steps to reproduce

These suck a little bit, because the tif file in question is huge and requires a login to download, and this is through a different package

Additional output

No response

@NewSoupVi NewSoupVi added the bug Potential issues with the zarr-python library label Jun 18, 2024
@NewSoupVi
Copy link
Author

Here are some better reproduction steps.

cgohlke/tifffile#260 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Potential issues with the zarr-python library
Projects
None yet
Development

No branches or pull requests

1 participant