Skip to content
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

adjust to xarray datatree #752

Merged
merged 16 commits into from
Nov 11, 2024
Merged

adjust to xarray datatree #752

merged 16 commits into from
Nov 11, 2024

Conversation

melonora
Copy link
Collaborator

@melonora melonora commented Nov 1, 2024

closes #735
closes #740

Xarray has archived the datatree repository and includes DataTree now directly in xarray. This comes with some changes, most notably the spatialdata repo is affected by the fact that DataTree.from_dict now requires a xr.Dataset instead of xr.DataArray, with the latter being marked as an inappropriate value. This PR fixes that.

Note that the PR in spatial-image/multiscale-spatial-image#94 is still open for now so I did not add a new flag yet in pyproject.toml. This would have to be done prior to merging this PR.

Tests have been performed with the branch of multiscale-spatial-image in the mentioned PR and all pass locally.

@melonora
Copy link
Collaborator Author

melonora commented Nov 4, 2024

I have added a decorator as now with any function mapping over datasets in the DataTree we run into the problem of the root level not containing anything and due to that functions fail. An example is transpose. This method is not directly available anymore on the DataTree level. You would basically have to do datatree.map_over_datasets but this fails because the root level does not have dims (it is an empty set). Given that I could see the usefulness across the repo I added the decorator in this PR so it can be imported in other repos as well.

Copy link

codecov bot commented Nov 11, 2024

Codecov Report

Attention: Patch coverage is 98.76543% with 2 lines in your changes missing coverage. Please review.

Project coverage is 91.85%. Comparing base (e27dbdd) to head (71531ce).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/spatialdata/_core/operations/vectorize.py 75.00% 1 Missing ⚠️
src/spatialdata/_types.py 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #752      +/-   ##
==========================================
- Coverage   91.89%   91.85%   -0.05%     
==========================================
  Files          45       45              
  Lines        6919     6885      -34     
==========================================
- Hits         6358     6324      -34     
  Misses        561      561              
Files with missing lines Coverage Δ
src/spatialdata/_core/_deepcopy.py 98.36% <100.00%> (-0.03%) ⬇️
src/spatialdata/_core/centroids.py 100.00% <100.00%> (ø)
src/spatialdata/_core/concatenate.py 91.59% <100.00%> (ø)
src/spatialdata/_core/data_extent.py 97.91% <100.00%> (-0.02%) ⬇️
src/spatialdata/_core/operations/_utils.py 92.15% <100.00%> (-0.16%) ⬇️
src/spatialdata/_core/operations/aggregate.py 94.35% <100.00%> (-0.04%) ⬇️
src/spatialdata/_core/operations/map.py 97.77% <100.00%> (-0.05%) ⬇️
src/spatialdata/_core/operations/rasterize.py 90.45% <100.00%> (-0.04%) ⬇️
src/spatialdata/_core/operations/rasterize_bins.py 89.88% <100.00%> (ø)
src/spatialdata/_core/operations/transform.py 90.82% <100.00%> (-0.04%) ⬇️
... and 25 more

@melonora melonora merged commit a89d16d into scverse:main Nov 11, 2024
8 checks passed
@melonora melonora deleted the xarray_datatree branch November 22, 2024 05:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant