mv_str for single values, remove undue assert

This commit is contained in:
Stefan Holst committed 2023-07-03 12:40:02 +09:00
1 parent 153442a10a
commit 7afb13b33b
2 files changed
+1 -1

No files matched your search

-1
View File
@@ -81,7 +81,6 @@ def hr_time(seconds):
def batchrange(nitems, maxsize):
assert nitems >= maxsize
for offset in range(0, nitems, maxsize):
yield offset, min(nitems-offset, maxsize)
+1
View File
@@ -115,6 +115,7 @@ def mv_str(mva, delim='\n'):
"""Renders a given multi-valued array into a string.
"""
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)
return delim.join([''.join(c) for c in sa.swapaxes(-1,-2)])