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

Method inject_str

numpy/_core/tests/test_multiarray.py:691–697  ·  view source on GitHub ↗

replace ndarray.__str__ temporarily

(s)

Source from the content-addressed store, hash-verified

689
690 @contextmanager
691 def inject_str(s):
692 """ replace ndarray.__str__ temporarily """
693 set_printoptions(formatter={"all": lambda x: s})
694 try:
695 yield
696 finally:
697 set_printoptions()
698
699 a1d = np.array(['test'])
700 a0d = np.array('done')

Callers

nothing calls this directly

Calls 1

set_printoptionsFunction · 0.90

Tested by

no test coverage detected