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

Function _extendLine_pretty

numpy/_core/arrayprint.py:827–852  ·  view source on GitHub ↗

Extends line with nicely formatted (possibly multi-line) string ``word``.

(s, line, word, line_width, next_line_prefix, legacy)

Source from the content-addressed store, hash-verified

825
826
827def _extendLine_pretty(s, line, word, line_width, next_line_prefix, legacy):
828 """
829 Extends line with nicely formatted (possibly multi-line) string ``word``.
830 """
831 words = word.splitlines()
832 if len(words) == 1 or legacy <= 113:
833 return _extendLine(s, line, word, line_width, next_line_prefix, legacy)
834
835 max_word_length = max(len(word) for word in words)
836 if (len(line) + max_word_length > line_width and
837 len(line) > len(next_line_prefix)):
838 s += line.rstrip() + '\n'
839 line = next_line_prefix + words[0]
840 indent = next_line_prefix
841 else:
842 indent = len(line) * ' '
843 line += words[0]
844
845 for word in words[1::]:
846 s += line.rstrip() + '\n'
847 line = indent + word
848
849 suffix_length = max_word_length - len(words[-1])
850 line += suffix_length * ' '
851
852 return s, line
853
854def _formatArray(a, format_function, line_width, next_line_prefix,
855 separator, edge_items, summary_insert, legacy):

Callers 1

recurserFunction · 0.85

Calls 4

_extendLineFunction · 0.85
splitlinesMethod · 0.80
rstripMethod · 0.80
maxFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…