Skip to content

Flaky test / buggy handling of large datetimes #2119

@TomAugspurger

Description

@TomAugspurger

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugPotential issues with the zarr-python library

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions