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

Flaky test / buggy handling of large datetimes #2119

Closed
TomAugspurger opened this issue Aug 25, 2024 · 0 comments · Fixed by #2118
Closed

Flaky test / buggy handling of large datetimes #2119

TomAugspurger opened this issue Aug 25, 2024 · 0 comments · Fixed by #2118
Labels
bug Potential issues with the zarr-python library

Comments

@TomAugspurger
Copy link
Contributor

Zarr version

v3

Numcodecs version

n/a

Python Version

n/a

Operating System

n/a

Installation

n/a

Description

Curious failure at https://github.com/zarr-developers/zarr-python/actions/runs/10549325420/job/29224231309?pr=2118 in #2118.

Steps to reproduce

I can reproduce locally, but I'm not too sure what's going on. With this diff:

diff --git a/tests/v3/test_properties.py b/tests/v3/test_properties.py
index 9204cdc5..5d2404b6 100644
--- a/tests/v3/test_properties.py
+++ b/tests/v3/test_properties.py
@@ -6,11 +6,12 @@ pytest.importorskip("hypothesis")
 
 import hypothesis.extra.numpy as npst  # noqa
 import hypothesis.strategies as st  # noqa
-from hypothesis import given, settings  # noqa
+from hypothesis import given, reproduce_failure, settings  # noqa
 from zarr.testing.strategies import arrays, np_arrays, basic_indices  # noqa
 
 
 @given(st.data())
+@reproduce_failure('6.111.2', b'AXicY2VgYmSAAhiDEcQAAADwAAw=')
 def test_roundtrip(data):
     nparray = data.draw(np_arrays)
     zarray = data.draw(arrays(arrays=st.just(nparray)))

I can get

(Pdb) pp nparray
array(['770652312998-01-12'], dtype='datetime64[D]')
(Pdb) pp zarray[:]
array(['1970-01-01'], dtype='datetime64[D]')

It seems like for large enough values, NumPy's datetime64[D] dtype is behaving strangely:

(Pdb) pp np.array(281474976710656, dtype='datetime64[D]').item()
281474976710656
(Pdb) pp np.array(0, dtype='datetime64[D]').item()
datetime.date(1970, 1, 1)

Additional output

Ahh, I think this is numpy/numpy#7619 (again). Python's datatime.date has limited precision, and so np.array(3000000, dtype='datetime64[D]') can't be represented as a date time. I'm pretty confused about what that test is doing, but presumably something inside Zarr isn't handling that edge case.

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

Successfully merging a pull request may close this issue.

1 participant