ProjectPythia / pythia-foundations

Jupyterbook source for the Foundations collection
http://foundations.projectpythia.org
Apache License 2.0
59 stars 42 forks source link

Code errors on Xarray pages #343

Closed brian-rose closed 1 year ago

brian-rose commented 1 year ago

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 commented 1 year ago

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

r-ford commented 1 year ago

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

ktyle commented 1 year ago

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 commented 1 year ago

suspect it stems from https://github.com/pydata/xarray/pull/7052

ktyle commented 1 year ago

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

ktyle commented 1 year ago

Looks like this problem will go away with the next release of Xarray, as it's been fixed with https://github.com/pydata/xarray/pull/7276