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?
#5
(Jul-22-2019, 11:19 AM)DeaD_EyE Wrote: You have to do this after the calculation.

I think I did:
import numpy as np
np.savetxt("result.txt", np.divide(np.loadtxt("1.txt"), np.loadtxt("2.txt")))
m1, m2 = np.loadtxt("1.txt"), np.loadtxt("2.txt")
result = np.divide(m1, m2)
result[np.isinf(result)] = 0.0
maybe sth else is wrong? I'm not a coder just need this to work so that you for your patience
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 1,566 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 1,119 Mar-14-2020, 09:19 AM
Last Post: scidam
  dividing by list not possible? SchroedingersLion 5 2,029 Oct-11-2018, 10:00 AM
Last Post: volcano63
  Checking the elements of a matrix with an elements of a list juniorcoder 11 3,524 Sep-17-2018, 03:02 PM
Last Post: gruntfutuk
  linspace not dividing equal intervals sheel 0 1,658 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