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

Class ComplexFloatingFormat

numpy/core/arrayprint.py:1245–1275  ·  view source on GitHub ↗

Formatter for subtypes of np.complexfloating

Source from the content-addressed store, hash-verified

1243
1244
1245class ComplexFloatingFormat:
1246 """ Formatter for subtypes of np.complexfloating """
1247 def __init__(self, x, precision, floatmode, suppress_small,
1248 sign=False, *, legacy=None):
1249 # for backcompatibility, accept bools
1250 if isinstance(sign, bool):
1251 sign = '+' if sign else '-'
1252
1253 floatmode_real = floatmode_imag = floatmode
1254 if legacy <= 113:
1255 floatmode_real = 'maxprec_equal'
1256 floatmode_imag = 'maxprec'
1257
1258 self.real_format = FloatingFormat(
1259 x.real, precision, floatmode_real, suppress_small,
1260 sign=sign, legacy=legacy
1261 )
1262 self.imag_format = FloatingFormat(
1263 x.imag, precision, floatmode_imag, suppress_small,
1264 sign='+', legacy=legacy
1265 )
1266
1267 def __call__(self, x):
1268 r = self.real_format(x.real)
1269 i = self.imag_format(x.imag)
1270
1271 # add the 'j' before the terminal whitespace in i
1272 sp = len(i.rstrip())
1273 i = i[:sp] + 'j' + i[sp:]
1274
1275 return r + i
1276
1277
1278class _TimelikeFormat:

Callers 1

_get_formatdictFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected