Created
September 2, 2021 11:25
-
-
Save AayushSameerShah/a872cb897d45edd8638ae11010572d4d to your computer and use it in GitHub Desktop.
This will successfully divide by zero and will return zero
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a = [1, 2, 3] | |
b = [0, 1, 0] # Arr with Zeros | |
c = np.divide(a, b, | |
out=np.zeros_like(a), where=b!=0) | |
'''Simply replace a and b with your variables''' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
From here: https://stackoverflow.com/questions/26248654/how-to-return-0-with-divide-by-zero