MCPcopy Create free account
hub / github.com/NVIDIA/DALI / _join_string

Function _join_string

dali/python/nvidia/dali/_tensor_formatting.py:25–52  ·  view source on GitHub ↗

Join strings with optional cropping for summarization. Parameters ---------- data : list List of strings to join. edgeitems : int or None, optional If specified, crops the list to show only the first and last `edgeitems` elements with "..." in between. If Non

(data, edgeitems=None, sep=", ", force_ellipsis=False)

Source from the content-addressed store, hash-verified

23
24
25def _join_string(data, edgeitems=None, sep=", ", force_ellipsis=False):
26 """Join strings with optional cropping for summarization.
27
28 Parameters
29 ----------
30 data : list
31 List of strings to join.
32 edgeitems : int or None, optional
33 If specified, crops the list to show only the first and last `edgeitems` elements
34 with "..." in between. If None, shows all elements. Default: None.
35 sep : str, optional
36 Separator to use when joining strings. Default: ", ".
37 force_ellipsis : bool, optional
38 If True and edgeitems is not None, forces ellipsis insertion at position edgeitems
39 regardless of list length. Useful when data is pre-cropped. Default: False.
40
41 Returns
42 -------
43 str
44 Joined string, optionally with summarization.
45 """
46 if edgeitems is not None and force_ellipsis:
47 # Force ellipsis at edgeitems position for pre-cropped data
48 data = data[:edgeitems] + ["..."] + data[edgeitems:]
49 elif edgeitems is not None and len(data) > 2 * edgeitems + 1:
50 # Crop and insert ellipsis
51 data = data[:edgeitems] + ["..."] + data[-edgeitems:]
52 return sep.join(data)
53
54
55class TensorAdapter(Protocol):

Callers 2

format_tensorFunction · 0.85
format_batchFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected