Browse Source

mv_str for single values, remove undue assert

devel
Stefan Holst 1 year ago
parent
commit
7afb13b33b
  1. 1
      src/kyupy/__init__.py
  2. 1
      src/kyupy/logic.py

1
src/kyupy/__init__.py

@ -81,7 +81,6 @@ def hr_time(seconds):
def batchrange(nitems, maxsize): def batchrange(nitems, maxsize):
assert nitems >= maxsize
for offset in range(0, nitems, maxsize): for offset in range(0, nitems, maxsize):
yield offset, min(nitems-offset, maxsize) yield offset, min(nitems-offset, maxsize)

1
src/kyupy/logic.py

@ -115,6 +115,7 @@ def mv_str(mva, delim='\n'):
"""Renders a given multi-valued array into a string. """Renders a given multi-valued array into a string.
""" """
sa = np.choose(mva, np.array([*'0X-1PRFN'], dtype=np.unicode_)) sa = np.choose(mva, np.array([*'0X-1PRFN'], dtype=np.unicode_))
if not hasattr(mva, 'ndim') or mva.ndim == 0: return sa
if mva.ndim == 1: return ''.join(sa) if mva.ndim == 1: return ''.join(sa)
return delim.join([''.join(c) for c in sa.swapaxes(-1,-2)]) return delim.join([''.join(c) for c in sa.swapaxes(-1,-2)])

Loading…
Cancel
Save