Skip to content

Fix DEM casting to Mask by removing from_array overloading #741

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

Merged
merged 1 commit into from
May 28, 2025

Conversation

rhugonnet
Copy link
Member

@rhugonnet rhugonnet commented May 28, 2025

Replaces #740

This is an easier fix than #740: Simply an if statement depending on the output of Raster.from_array.

Another way to do this for a future re-work (if we want users to more easily subclass Raster, for example) would be to separate Raster.from_array() into a non-public function that does the casting under-the-hood for all arithmetic ops (Raster._from_array(), which wouldn't be overloaded by DEM.from_array()) and a public function that works only for building a Raster as intended (refuses a boolean input).
Actually, we might have to already do this for the Xarray accessors, for consistency in the behaviour.

Resolves #739

@rhugonnet
Copy link
Member Author

As the fix is just 2 lines, should be good to merge.

@rhugonnet rhugonnet merged commit e510fac into GlacioHack:main May 28, 2025
24 checks passed
@rhugonnet rhugonnet deleted the fix_mask_casting_v2 branch May 28, 2025 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Automatic casting to Mask does not work with DEM instances
1 participant