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

Drop z dimension from ImageStack DataArray before shading #6378

Merged
merged 8 commits into from
Sep 19, 2024

Conversation

philippjfr
Copy link
Member

@philippjfr philippjfr commented Sep 19, 2024

When performing categorical rasterization with only one category the XArrayInterface would convert the 3D DataArray into a Dataset. When this 3D Dataset was then shaded we would convert the singular DataArray variable into a z-dimension, which meant we'd have two categorical variables (with the same value) and datashader would error out because it expects a 2D or 3D array.

Here we do a number of things:

  • Allow the XArrayInterface to hold a DataArray with a singular value dimension
  • Ensure that shade handles non-xarray datasets correctly (by promoting them to xarray)
  • Ensure that it does not needlessly add a z-dimension if we have a singular value dimension
  • Even if we have a 3D array and a multiple z-values we squeeze the DataArray to drop superfluous constant dimensions.
  • Support dask array backed xarrays in shade (by materializing them)

@philippjfr philippjfr added the type: bug Something isn't correct or isn't working label Sep 19, 2024
Copy link

codecov bot commented Sep 19, 2024

Codecov Report

Attention: Patch coverage is 82.75862% with 5 lines in your changes missing coverage. Please review.

Project coverage is 88.49%. Comparing base (88996ed) to head (f108020).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
holoviews/operation/datashader.py 61.53% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6378      +/-   ##
==========================================
- Coverage   88.50%   88.49%   -0.01%     
==========================================
  Files         323      323              
  Lines       68281    68304      +23     
==========================================
+ Hits        60429    60448      +19     
- Misses       7852     7856       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@hoxbro hoxbro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you haven't already maybe also run the hvplot test suite (locally) to verify that this change does not break anything because of the changes in XarrayInterface.

holoviews/core/data/xarray.py Show resolved Hide resolved
holoviews/operation/datashader.py Outdated Show resolved Hide resolved
holoviews/operation/datashader.py Outdated Show resolved Hide resolved
holoviews/operation/datashader.py Show resolved Hide resolved
Co-authored-by: Simon Høxbro Hansen <[email protected]>
@philippjfr
Copy link
Member Author

If you haven't already maybe also run the hvplot test suite (locally) to verify that this change does not break anything because of the changes in XarrayInterface.

Done, it's passing.

@hoxbro hoxbro enabled auto-merge (squash) September 19, 2024 12:06
@hoxbro hoxbro merged commit b729e34 into main Sep 19, 2024
13 checks passed
@hoxbro hoxbro deleted the shade_image_stack_zarray branch September 19, 2024 12:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't correct or isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants