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

Function _raise_power

numpy/lib/polynomial.py:1050–1074  ·  view source on GitHub ↗
(astr, wrap=70)

Source from the content-addressed store, hash-verified

1048
1049_poly_mat = re.compile(r"\*\*([0-9]*)")
1050def _raise_power(astr, wrap=70):
1051 n = 0
1052 line1 = ''
1053 line2 = ''
1054 output = ' '
1055 while True:
1056 mat = _poly_mat.search(astr, n)
1057 if mat is None:
1058 break
1059 span = mat.span()
1060 power = mat.groups()[0]
1061 partstr = astr[n:span[0]]
1062 n = span[1]
1063 toadd2 = partstr + ' '*(len(power)-1)
1064 toadd1 = ' '*(len(partstr)-1) + power
1065 if ((len(line2) + len(toadd2) > wrap) or
1066 (len(line1) + len(toadd1) > wrap)):
1067 output += line1 + "\n" + line2 + "\n "
1068 line1 = toadd1
1069 line2 = toadd2
1070 else:
1071 line2 += partstr + ' '*(len(power)-1)
1072 line1 += ' '*(len(partstr)-1) + power
1073 output += line1 + "\n" + line2
1074 return output + astr[n:]
1075
1076
1077@set_module('numpy')

Callers 1

__str__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected