Skip to content

Instantly share code, notes, and snippets.

@AayushSameerShah
Created September 2, 2021 11:25
Show Gist options
  • Save AayushSameerShah/a872cb897d45edd8638ae11010572d4d to your computer and use it in GitHub Desktop.
Save AayushSameerShah/a872cb897d45edd8638ae11010572d4d to your computer and use it in GitHub Desktop.
This will successfully divide by zero and will return zero
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