Comments (3)
Looks like the whole serialize/deserialize pathway doesn't quite work with Datasets. That's an issue since .compute()
now relies on temporarily converting to a DataTree to compute everything at once. I'll try to look at getting this properly supported in the next few days. In the meantime your example works fine on the DataArray:
t2m = xr.tutorial.open_dataset("air_temperature")
# fails
xe.models.EOF(n_modes=10).fit(t2m, "time").compute()
# succeeds
xe.models.EOF(n_modes=10).fit(t2m.air, "time").compute()
from xeofs.
Hey, thanks a lot for the kind words @malmans2 , and sorry for the late reply, these past few days have been pretty hectic.
I really like the idea of automatically synchronizing the documentation and the code! I've tried to integrate both suggestions, but I'm stuck with the implementation.
Notebook & nbstripout
[to the PR]
Cleaning the notebook output with nbstripout using a pre-commit hook works. However, I don't understand how to instruct ReadTheDocs to execute the notebook itself. It seems that ReadTheDocs doesn't do this automatically and thus fails when building the documentation. @malmans2 do you have any experience with this or know the relevant part in the ReadTheDocs documentation?
README & doctest
[to the PR]
I've started rewriting the README for doctest. Strangely, the examples for Varimax Rotation fail
Error Message
=================================== FAILURES ===================================
_____________________________ [doctest] README.md ______________________________
072 >>> scores = eof.scores() # PCs (temporal patterns)
073
074 ```
075
076 **Varimax-rotated EOF analysis**
077 Initiate and fit an `EOFRotator` class to the model to obtain a varimax-rotated EOF analysis
078
079 ```python
080 >>> rotator = xe.models.EOFRotator(n_modes=3)
081 >>> rotator.fit(eof) # doctest: +ELLIPSIS
UNEXPECTED EXCEPTION: KeyError('Could not find node at mean_')
Traceback (most recent call last):
File "/opt/hostedtoolcache/Python/3.10.13/x64/lib/python3.10/doctest.py", line 1350, in __run
exec(compile(example.source, filename, "single",
File "<doctest README.md[10]>", line 1, in <module>
File "/home/runner/work/xeofs/xeofs/xeofs/models/eof_rotator.py", line 116, in fit
self.compute()
File "/home/runner/work/xeofs/xeofs/xeofs/models/_base_model.py", line 380, in compute
self._deserialize_attrs(dt)
File "/home/runner/work/xeofs/xeofs/xeofs/models/_base_model.py", line 456, in _deserialize_attrs
deserialized_obj = getattr(self, key).deserialize(dt[key])
File "/home/runner/work/xeofs/xeofs/xeofs/preprocessing/preprocessor.py", line 412, in deserialize
deserialized = preprocessor.transformer_types()[name].deserialize(
File "/home/runner/work/xeofs/xeofs/xeofs/preprocessing/transformer.py", line 162, in deserialize
return cls._deserialize(dt)
File "/home/runner/work/xeofs/xeofs/xeofs/preprocessing/transformer.py", line 177, in _deserialize
data = transformer._deserialize_data_node(key, dt[key])
File "/home/runner/work/xeofs/xeofs/.venv/lib/python3.10/site-packages/datatree/datatree.py", line 876, in __getitem__
return self._get_item(path)
File "/home/runner/work/xeofs/xeofs/.venv/lib/python3.10/site-packages/datatree/treenode.py", line 448, in _get_item
raise KeyError(f"Could not find node at {path}")
KeyError: 'Could not find node at mean_'
/home/runner/work/xeofs/xeofs/README.md:81: UnexpectedException
@slevang, as a budding xarray-datatree expert, any idea why doctest is hitting a snag here, even though pytest runs through without a hitch?
Alternatively, I think we could also omit the Quickstart in the README and directly refer to Documentation > Quickstart, since both are essentially redundant.
xeofs
themselves, not the actual code.
from xeofs.
Thanks again for the quick fix @slevang.
Closing, fixed by #135 and #136
from xeofs.
Related Issues (20)
- ModuleNotFound Error datatree HOT 5
- `scores()` don't match `transform()` with dask data HOT 4
- Improving release process
- Add dependencies section in the documentation HOT 1
- numpy and pandas dependency question
- numpy and pandas dependencies HOT 3
- Migrating repository to xarray-contrib HOT 2
- why the explained_variance_ratio of CCA so small HOT 4
- Serialization fails with `xarray>=2024.1.0` HOT 2
- Single mode data reconstruction fails with normalized scores HOT 9
- Support for complex input data
- MCA incorrect coords alignment in transform method HOT 3
- Is the reconstruction of unseen data possible using EOF? HOT 5
- Model cannot fit DataArray without coordiantes
- Add option `n_modes="all"` to perform the full decomposition HOT 2
- Trouble creating the eof object HOT 8
- TypeError: __init__() missing 1 required positional argument: 'X' HOT 1
- Data with Nan values HOT 5
- Questions to the REOF power parameter in the examples HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from xeofs.