MCPcopy Create free account
hub / github.com/numpy/numpy / inject_str

Method inject_str

numpy/core/tests/test_multiarray.py:576–582  ·  view source on GitHub ↗

replace ndarray.__str__ temporarily

(s)

Source from the content-addressed store, hash-verified

574
575 @contextmanager
576 def inject_str(s):
577 """ replace ndarray.__str__ temporarily """
578 set_string_function(lambda x: s, repr=False)
579 try:
580 yield
581 finally:
582 set_string_function(None, repr=False)
583
584 a1d = np.array(['test'])
585 a0d = np.array('done')

Callers

nothing calls this directly

Calls 1

set_string_functionFunction · 0.85

Tested by

no test coverage detected