Skip to content

Commit

Permalink
overload digits
Browse files Browse the repository at this point in the history
  • Loading branch information
zoomlogo committed Feb 20, 2024
1 parent ea38a45 commit fe8b5f8
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions flax/funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,12 @@ def diagonals(x, antidiagonals=False):

def digits(x):
"""digits: turn x into a list of digits"""
return [
-int(i) if x < 0 else int(i) for i in str(x)[1 if x < 0 else 0 :] if i != "."
]
if type2strn(x) == "mpc":
return [mpc(i[0], i[1]) for i in transpose([digits(x.real)[::-1], digits(x.imag)[::-1]], filler=0)[::-1]][:-1]
else:
return [
-int(i) if x < 0 else int(i) for i in str(x)[1 if x < 0 else 0 :] if i != "."
]


def digits_i(x):
Expand Down

0 comments on commit fe8b5f8

Please sign in to comment.