MCPcopy Index your code
hub / github.com/RustPython/RustPython / canonical

Method canonical

Lib/_pydecimal.py:4152–4163  ·  view source on GitHub ↗

Returns the same Decimal object. As we do not have different encodings for the same number, the received object already is in its canonical form. >>> ExtendedContext.canonical(Decimal('2.50')) Decimal('2.50')

(self, a)

Source from the content-addressed store, hash-verified

4150 return str(a._fix(self))
4151
4152 def canonical(self, a):
4153 """Returns the same Decimal object.
4154
4155 As we do not have different encodings for the same number, the
4156 received object already is in its canonical form.
4157
4158 >>> ExtendedContext.canonical(Decimal('2.50'))
4159 Decimal('2.50')
4160 """
4161 if not isinstance(a, Decimal):
4162 raise TypeError("canonical requires a Decimal as an argument.")
4163 return a.canonical()
4164
4165 def compare(self, a, b):
4166 """Compares values numerically.

Callers

nothing calls this directly

Calls 2

isinstanceFunction · 0.85
canonicalMethod · 0.45

Tested by

no test coverage detected