Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
usm_ndarray_repr inserts commas
user defined nanstr and infstr implemented
  • Loading branch information
ndgrigorian committed Dec 8, 2022
commit e02c6cb96d0edb2a45f4d1a3f28574791e5e17a7
20 changes: 5 additions & 15 deletions dpctl/tensor/_print.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,23 +183,12 @@ def usm_ndarray_str(
if x.size > threshold:
# need edge_items + 1 elements for np.array2string to abbreviate
data = dpt.asnumpy(_nd_corners(x, edge_items + 1))
forward_threshold = 0
options["threshold"] = 0
else:
data = dpt.asnumpy(x)
forward_threshold = threshold
return np.array2string(
data,
max_line_width=options["linewidth"],
edgeitems=options["edgeitems"],
threshold=forward_threshold,
precision=options["precision"],
floatmode=options["floatmode"],
suppress_small=options["suppress"],
sign=options["sign"],
separator=separator,
prefix=prefix,
suffix=suffix,
)
with np.printoptions(**options):
s = np.array2string(data, separator=separator, prefix=prefix, suffix=suffix)
return s


def usm_ndarray_repr(x, line_width=None, precision=None, suppress=None):
Expand All @@ -224,6 +213,7 @@ def usm_ndarray_repr(x, line_width=None, precision=None, suppress=None):
line_width=line_width,
precision=precision,
suppress=suppress,
separator=", ",
prefix=prefix,
suffix=suffix,
)
Expand Down