Skip to content

Code errors on Xarray pages #343

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
brian-rose opened this issue Nov 23, 2022 · 6 comments · Fixed by #346
Closed

Code errors on Xarray pages #343

brian-rose opened this issue Nov 23, 2022 · 6 comments · Fixed by #346
Labels
content Content related issue

Comments

@brian-rose
Copy link
Member

The latest builds have code errors in several places in our Xarray tutorials, e.g.
https://foundations.projectpythia.org/core/xarray/computation-masking.html#groupby-split-apply-combine
and
https://foundations.projectpythia.org/core/xarray/computation-masking.html#compute-anomaly
and
https://foundations.projectpythia.org/core/xarray/enso-xarray.html#visualize-the-computed-nino-3-4-index

Several of these throw an error

TypeError: float() argument must be a string or a number, not 'cftime._cftime.DatetimeNoLeap'

I don't know when this started. These types of Python code errors don't get flagged by our CI tests. Is it due to version changes in Xarray or one of its dependencies?

@brian-rose brian-rose added content Content related issue high priority labels Nov 23, 2022
@brian-rose
Copy link
Member Author

I'm taking the liberty of labeling this as "high priority" because we should not have ugly errors in our featured tutorials!

@r-ford
Copy link
Member

r-ford commented Nov 23, 2022

The nightly build for the CMIP6 Cookbook is also failing with the same error.

@ktyle
Copy link
Contributor

ktyle commented Nov 23, 2022

I did some Xarray version testing. It looks like this behavior begins with the most recent (2022.11.0) xarray release. The immediate predecessor (2022.10.0) works without error.

I can put together a PR with an environment.yml that specifies xarray<2022.11.0 as a quick fix, although it would be worth digging deeper to see if this is a bug in Xarray or if the lines that are throwing the error need to be rewritten.

@ktyle
Copy link
Contributor

ktyle commented Nov 24, 2022

suspect it stems from pydata/xarray#7052

@ktyle
Copy link
Contributor

ktyle commented Nov 24, 2022

And it looks like the error goes away if we add
import nc_time_axis

@ktyle
Copy link
Contributor

ktyle commented Nov 24, 2022

Looks like this problem will go away with the next release of Xarray, as it's been fixed with pydata/xarray#7276

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
content Content related issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants