Skip to content

Commit 25938e8

Browse files
authored
adjust eps to reasonable value (#193)
1 parent 80f5d58 commit 25938e8

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

pypulseq/__init__.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,13 @@ def round_half_up(n, decimals=0):
1414

1515

1616
# =========
17-
# NP.FLOAT EPSILON
17+
# EPSILON (Precision of floating point numbers)
1818
# =========
19-
eps = np.finfo(np.float64).eps
19+
20+
# Instead of np.finfo(np.float64).eps, which was used before, we now try to estimate our precision based on the largest
21+
# expected value for times, amplitudes etc (we choose 1E6) and consider another factor 10 for compounding of rounding errors.
22+
# We then round the value to the closest power of 10.
23+
eps = 10 ** np.floor(np.log10(np.spacing(1e6) * 10)) # this is 1e-9 for np.float64
2024

2125
# =========
2226
# PACKAGE-LEVEL IMPORTS

0 commit comments

Comments
 (0)