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

coreg.BiasCorr warns for all-nans but doesn't fail #112

Closed
erikmannerfelt opened this issue May 6, 2021 · 0 comments · Fixed by #121
Closed

coreg.BiasCorr warns for all-nans but doesn't fail #112

erikmannerfelt opened this issue May 6, 2021 · 0 comments · Fixed by #121
Assignees
Labels
good first issue Good for newcomers invalid This doesn't seem right

Comments

@erikmannerfelt
Copy link
Contributor

BiasCorr should arguably fail if it encounters a DEM with only nans. Right now, a numpy warning occurs which is not very useful in identifying the problem.

Minimal example:

In [1]: import xdem

In [2]: import numpy as np

In [3]: biascorr = xdem.coreg.BiasCorr()

In [4]: dem1 = np.ones((50, 50))

In [5]: dem2 = np.ones((50, 50)) + np.nan

In [6]: biascorr.fit(dem1, dem2, transform=None)
/home/erik/.local/share/conda/xdem/lib/python3.8/site-packages/numpy/lib/function_base.py:380: RuntimeWarning: Mean of empty slice.
  avg = a.mean(axis)
/home/erik/.local/share/conda/xdem/lib/python3.8/site-packages/numpy/core/_methods.py:188: RuntimeWarning: invalid value encountered in double_scalars
  ret = ret.dtype.type(ret / rcount)

A sanity check should be added to make sure that the function fails instead of giving quite useless warnings!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers invalid This doesn't seem right
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant