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

Move to python 3.10 in CI and remove python 3.7 #279

Merged
merged 21 commits into from
Aug 9, 2022

Conversation

rhugonnet
Copy link
Member

@rhugonnet rhugonnet commented Aug 9, 2022

Main change in the title.

Also ran into the issue of RuntimeWarning with NaNs of #260 again. I fixed it by using np.full(shape, np.nan) to initialize a NaN array instead of multiplying or adding np.zeros(), np.ones() or np.empty() with np.nan like we have the (now bad?) habit of doing.
The dtype of np.full (previously np.empty) is not set to dem.dtype anymore. This change was triggered by failing doctests with this dtype forcing because, if a DEM is an integer, terrain attributes derived from it would be forced to integers (and some attributes are between 0 and 1). The failure of tests only happened in this PR because the dtype argument works differently if initiated in np.full or if by np.empy later multiplied by NaN. The np.empty multiplied by NaN actually ignored the dtype all along.

Added a point on this in the wiki (https://github.com/GlacioHack/xdem/wiki/Stuck-on-a-mysterious-error-during-CI%3F):

  1. The unexpected: Initialization of np.ndarray full of NaNs could historically be done in many ways: multiplying or summing a np.zeros, np.ones or np.empty with a np.nan. However, recently, RuntimeWarning have started to pop up a bit randomly with these methods, resulting in test failres. We could not track down the exact version change that triggered this (might be unexpected behaviour, so not in the logs), but it does seems to depend on the version of numpy. Solution: use np.full(shape, np.nan, dtype) to initialize those arrays!
values = np.empty((n_bins, unique_indices.shape[0]), dtype=float) * np.nan
E       RuntimeWarning: invalid value encountered in multiply

Resolves #249
Resolves #260

Copy link
Member

@adehecq adehecq left a comment

Choose a reason for hiding this comment

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

Thanks !

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.

Possible update in NumPy triggering warning for NaN addition Test python 3.10 in CI
2 participants