Skip to content

Commit

Permalink
release 1.4.3 complex output fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Xanonymous-GitHub committed Jun 11, 2020
1 parent 0afb6b0 commit ba46dc4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setup(
name="xmatrix",
version="1.4.4",
version="1.4.5",
author="Xanonymous",
author_email="[email protected]",
description="Help you calculate matrix.",
Expand Down
7 changes: 6 additions & 1 deletion xmatrix/matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,12 @@ def __pretty(self, r) -> str:
for i, x in enumerate(r):
for j, y in enumerate(x):
# try to turn the data to integer.
if not isinstance(r[i][j], complex) and abs(r[i][j] - int(r[i][j])) < 10 ** -4:
if isinstance(r[i][j], complex):
if abs(r[i][j].real - int(r[i][j].real)) < 10 ** -4:
r[i][j] = int(r[i][j].real) + r[i][j].imag * 1j
if abs(r[i][j].imag - int(r[i][j].imag)) < 10 ** -4:
r[i][j] = r[i][j].real + int(r[i][j].imag) * 1j
elif abs(r[i][j] - int(r[i][j])) < 10 ** -4:
r[i][j] = int(r[i][j])
# the max floating point length in python is 16 so we use 15 to calculate.
if isinstance(r[i][j], float):
Expand Down

0 comments on commit ba46dc4

Please sign in to comment.