You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
does not import nc_time_axis. Further down, the variable gets checked and if False an error is raised, but if the package still is not imported if True.
Thanks for the find :)
That indeed is a bug.
Always difficult to keep track of such packages that are not actively used but need to be imported to register things in matplotlib.
I took the freedom to use your example as a new test.
What happened?
With xarray 2022.11.0, plotting a DataArray with a
cftime
time axis fails.It fails with a matplotlib error :
TypeError: float() argument must be a string or a real number, not 'cftime._cftime.DatetimeNoLeap'
What did you expect to happen?
With previous versions of xarray, the
nc_time_axis
package was imported by xarray and these errors were avoided.Minimal Complete Verifiable Example
MVCE confirmation
Relevant log output
Anything else we need to know?
I suspect #7179.
This line:
xarray/xarray/plot/utils.py
Line 27 in cc7e09a
does not import
nc_time_axis
. Further down, the variable gets checked and ifFalse
an error is raised, but if the package still is not imported ifTrue
.Previously we had:
xarray/xarray/plot/utils.py
Lines 27 to 32 in fc9026b
where the package is always imported.
Maybe there's a way to import
nc_time_axis
only when needed?Environment
INSTALLED VERSIONS
commit: None
python: 3.10.6 | packaged by conda-forge | (main, Aug 22 2022, 20:36:39) [GCC 10.4.0]
python-bits: 64
OS: Linux
OS-release: 6.0.5-200.fc36.x86_64
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: fr_CA.UTF-8
LOCALE: ('fr_CA', 'UTF-8')
libhdf5: 1.12.2
libnetcdf: 4.8.1
xarray: 2022.11.0
pandas: 1.5.1
numpy: 1.23.4
scipy: 1.8.1
netCDF4: 1.6.1
pydap: None
h5netcdf: None
h5py: None
Nio: None
zarr: None
cftime: 1.6.2
nc_time_axis: 1.4.1
PseudoNetCDF: None
rasterio: None
cfgrib: None
iris: None
bottleneck: 1.3.5
dask: 2022.10.2
distributed: 2022.10.2
matplotlib: 3.6.2
cartopy: None
seaborn: None
numbagg: None
fsspec: 2022.10.0
cupy: None
pint: 0.20.1
sparse: None
flox: None
numpy_groupies: None
setuptools: 65.5.1
pip: 22.3.1
conda: None
pytest: 7.2.0
IPython: 8.6.0
sphinx: 5.3.0
The text was updated successfully, but these errors were encountered: