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

Method _format_term

numpy/polynomial/_polybase.py:436–453  ·  view source on GitHub ↗

Format a single term in the expansion

(self, scalar_format: Callable, off: float, scale: float)

Source from the content-addressed store, hash-verified

434 return fr'\text{{{pu.format_float(x, parens=parens)}}}'
435
436 def _format_term(self, scalar_format: Callable, off: float, scale: float):
437 """ Format a single term in the expansion """
438 if off == 0 and scale == 1:
439 term = self.symbol
440 needs_parens = False
441 elif scale == 1:
442 term = f"{scalar_format(off)} + {self.symbol}"
443 needs_parens = True
444 elif off == 0:
445 term = f"{scalar_format(scale)}{self.symbol}"
446 needs_parens = True
447 else:
448 term = (
449 f"{scalar_format(off)} + "
450 f"{scalar_format(scale)}{self.symbol}"
451 )
452 needs_parens = True
453 return term, needs_parens
454
455 def _repr_latex_(self):
456 # get the scaled argument string to the basis functions

Callers 2

_generate_stringMethod · 0.95
_repr_latex_Method · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected