Python Forum
When dividing elements of matrix i would like the result 0 instead of inf?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
When dividing elements of matrix i would like the result 0 instead of inf?
#2
It is normal that division by zero yields infinity, i.e. inf (floating point).
However, you can change all infs to zeros, e.g.
result[np.isinf(result)] = 0.0
Reply


Messages In This Thread
RE: 0 instead of inf - by scidam - Jul-22-2019, 09:41 AM
RE: 0 instead of inf - by Koczkodan - Jul-22-2019, 10:21 AM
RE: 0 instead of inf - by DeaD_EyE - Jul-22-2019, 11:19 AM
RE: 0 instead of inf - by Koczkodan - Jul-22-2019, 11:40 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Formula with elements of list - If-condition regarding the lists elements lewielewis 2 2,702 May-08-2020, 01:41 PM
Last Post: nnk
Question Dividing a single column of dataframe into multiple columns based on char length darpInd 2 2,413 Mar-14-2020, 09:19 AM
Last Post: scidam
  dividing by list not possible? SchroedingersLion 5 3,762 Oct-11-2018, 10:00 AM
Last Post: volcano63
  Checking the elements of a matrix with an elements of a list juniorcoder 11 5,754 Sep-17-2018, 03:02 PM
Last Post: gruntfutuk
  linspace not dividing equal intervals sheel 0 2,366 Jan-16-2018, 04:28 PM
Last Post: sheel

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020