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

dlu.nandiv fails on float inputs #269

Open
LouisDesdoigts opened this issue Jun 5, 2024 · 0 comments
Open

dlu.nandiv fails on float inputs #269

LouisDesdoigts opened this issue Jun 5, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request low-priority Low-priority issue that isn't likely to adressed soon

Comments

@LouisDesdoigts
Copy link
Owner

dlu.nandiv(1.0, 0.0, -1)

ZeroDivisionError Traceback (most recent call last)
Cell In[173], line 1
----> 1 dlu.nandiv(1.0, 0.0, -1)

File ~/mambaforge/envs/amigo/lib/python3.11/site-packages/dLux/utils/math.py:77, in nandiv(a, b, fill)
59 def nandiv(a: Array, b: Array, fill: Any = np.inf) -> Array:
60 """
61 Divides two arrays, replacing any NaNs with a fill value.
62
(...)
75 The result of the division.
76 """
---> 77 return np.where(b == 0, fill, a / b)

ZeroDivisionError: float division by zero


whereas

dlu.nandiv(1., np.array(0.), -1)

Array(-1., dtype=float64, weak_type=True)


It should also probably be called safe_div

@LouisDesdoigts LouisDesdoigts self-assigned this Jun 5, 2024
@LouisDesdoigts LouisDesdoigts added enhancement New feature or request low-priority Low-priority issue that isn't likely to adressed soon labels Jun 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request low-priority Low-priority issue that isn't likely to adressed soon
Projects
None yet
Development

No branches or pull requests

1 participant