Skip to content

Commit b36732d

Browse files
committed
Add fix for precision noise
1 parent 57620f1 commit b36732d

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

control/xferfcn.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,11 @@ def to_zpk(self, var=None):
502502

503503
polygain = np.prod(num_roots) / np.prod(den_roots)
504504

505+
# Round imaginary part down to zero for values close to
506+
# precision to prevent small errors to mess up things.
507+
polygain = complex(polygain.real,
508+
round(polygain.imag, 12))
509+
505510
if abs(polygain) == 0 and abs(dcgain) == 0:
506511
k = 1
507512
else:

0 commit comments

Comments
 (0)