Skip to content

Upstream test for NumPy arrays to inlined Kerchunk references fails #492

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

Closed
maxrjones opened this issue Mar 20, 2025 · 3 comments · Fixed by #496
Closed

Upstream test for NumPy arrays to inlined Kerchunk references fails #492

maxrjones opened this issue Mar 20, 2025 · 3 comments · Fixed by #496
Labels
bug Something isn't working

Comments

@maxrjones
Copy link
Member

Full error available in https://github.com/zarr-developers/VirtualiZarr/actions/runs/13959203618/job/39077253124

@TomNicholas TomNicholas added the bug Something isn't working label Mar 20, 2025
@TomNicholas
Copy link
Member

Oh cool that's 2 fewer tests that are my fault in #477 haha

@maxrjones
Copy link
Member Author

The relevant update is in pydata/xarray#9498, which changes the return dtype from np_arr = CFDatetimeCoder().encode(var.copy(), name=var_name).values float32 to float64 in our tests. Since the original dtype was datetime64[ns], the new behavior seems like an improvement to me at first glance. I'll look into what would need to be changed in Kerchunk to match Xarray's new behavior.

@maxrjones
Copy link
Member Author

maxrjones commented Mar 21, 2025

Well Kerchunk's also not wrong to keep it as float32 since that's how it's stored on disk 😕 Not sure the correct solution since there's no np.datetime32 to work with when decoding times. I think we're probably popping the necessary dtype encoding somewhere, still looking 👀

from netCDF4 import Dataset
import xarray as xr

file = "test_numpy_arrays_to_inlined.nc"
ds = xr.tutorial.open_dataset("air_temperature")

ds.to_netcdf(file, format="NETCDF4")

nc_file = Dataset(file, 'r')


for var_name, var in nc_file.variables.items():
    print(f"Variable: {var_name}, Data type: {var.datatype}")
Variable: lat, Data type: float32
Variable: air, Data type: int16
Variable: lon, Data type: float32
Variable: time, Data type: float32

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants