-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Can't select time with str after converting the calendar to noleap #9138
Comments
Thanks for opening your first issue here at xarray! Be sure to follow the issue template! |
Thanks for the well-written report @juliettelavoie—a git bisect suggests this issue was introduced in #9002. I'll try and dig into it more when I get a chance. |
@hmaarrfk do you have time to take a look here? |
I think this is maybe the crux of the issue.
It does seem maybe a bit surprising that this worked before. A workaround within
Or maybe clearer in this context would be to explicitly cast the index after the drop as a
|
sorry. i didn't reply i'll try to take a look (sometimes github mentions explode) |
my first feeling is that given the quality of the reproducer (as in it is very high) one could conceive of including it as a test and removing the offending optimization in #9002. While it does hurt me, I understand that this is likely the right thing to do avoid larger breakages. |
Thanks @hmaarrfk looks like your PR may have only uncovered some implicit assumptions in the code base |
See discussion in pydata#9138 This commit and pull request mostly serves as a staging group for a potential fix. Test with: ``` pytest xarray/tests/test_cftimeindex.py::test_cftime_noleap_with_str ```
See discussion in pydata#9138 This commit and pull request mostly serves as a staging group for a potential fix. Test with: ``` pytest xarray/tests/test_cftimeindex.py::test_cftime_noleap_with_str ```
See discussion in pydata#9138 This commit and pull request mostly serves as a staging group for a potential fix. Test with: ``` pytest xarray/tests/test_cftimeindex.py::test_cftime_noleap_with_str ```
* MRC -- Selecting with string for cftime See discussion in #9138 This commit and pull request mostly serves as a staging group for a potential fix. Test with: ``` pytest xarray/tests/test_cftimeindex.py::test_cftime_noleap_with_str ``` * effectively remove fastpath * Add docstring * Revert "effectively remove fastpath" This reverts commit 0f1a5a2. * Fix by reassigning coordinate * Update what's new entry * Simplify if condition --------- Co-authored-by: Spencer Clark <spencerkclark@gmail.com>
What happened?
I am trying to select a time period after converting the calendar to
noleap
and I receive the following error:TypeError: '<' not supported between instances of 'cftime._cftime.DatetimeNoLeap' and 'str'
What did you expect to happen?
I expected the slicing to work as normal.
Minimal Complete Verifiable Example
MVCE confirmation
Relevant log output
Anything else we need to know?
It was working with version 2024.05.0
Environment
INSTALLED VERSIONS
commit: None
python: 3.11.5 | packaged by conda-forge | (main, Aug 27 2023, 03:34:09) [GCC 12.3.0]
python-bits: 64
OS: Linux
OS-release: 3.10.0-1160.105.1.el7.x86_64
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_CA.UTF-8
LOCALE: ('fr_CA', 'UTF-8')
libhdf5: 1.14.1
libnetcdf: 4.9.2
xarray: 2024.6.0
pandas: 2.2.1
numpy: 1.24.4
scipy: 1.11.2
netCDF4: 1.6.4
pydap: None
h5netcdf: 1.2.0
h5py: 3.9.0
zarr: 2.16.1
cftime: 1.6.3
nc_time_axis: 1.4.1
iris: None
bottleneck: 1.3.7
dask: 2023.9.2
distributed: 2023.9.2
matplotlib: 3.8.0
cartopy: 0.22.0
seaborn: 0.13.1
numbagg: None
fsspec: 2023.9.2
cupy: None
pint: 0.22
sparse: 0.14.0
flox: 0.7.2
numpy_groupies: 0.10.1
setuptools: 68.2.2
pip: 23.2.1
conda: installed
pytest: 7.4.2
mypy: None
IPython: 8.15.0
sphinx: 7.2.6
The text was updated successfully, but these errors were encountered: