MCPcopy Index your code
hub / github.com/numpy/numpy / SubArrayFormat

Class SubArrayFormat

numpy/_core/arrayprint.py:1438–1461  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1436
1437
1438class SubArrayFormat:
1439 def __init__(self, format_function, **options):
1440 self.format_function = format_function
1441 self.threshold = options['threshold']
1442 self.edge_items = options['edgeitems']
1443
1444 def __call__(self, a):
1445 self.summary_insert = "..." if a.size > self.threshold else ""
1446 return self.format_array(a)
1447
1448 def format_array(self, a):
1449 if np.ndim(a) == 0:
1450 return self.format_function(a)
1451
1452 if self.summary_insert and a.shape[0] > 2 * self.edge_items:
1453 formatted = (
1454 [self.format_array(a_) for a_ in a[:self.edge_items]]
1455 + [self.summary_insert]
1456 + [self.format_array(a_) for a_ in a[-self.edge_items:]]
1457 )
1458 else:
1459 formatted = [self.format_array(a_) for a_ in a]
1460
1461 return "[" + ", ".join(formatted) + "]"
1462
1463
1464class StructuredVoidFormat:

Callers 1

from_dataMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…