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

Method number_class

Lib/_pydecimal.py:3564–3604  ·  view source on GitHub ↗

Returns an indication of the class of self. The class is one of the following strings: sNaN NaN -Infinity -Normal -Subnormal -Zero +Zero +Subnormal +Normal +Infinity

(self, context=None)

Source from the content-addressed store, hash-verified

3562 return ans
3563
3564 def number_class(self, context=None):
3565 """Returns an indication of the class of self.
3566
3567 The class is one of the following strings:
3568 sNaN
3569 NaN
3570 -Infinity
3571 -Normal
3572 -Subnormal
3573 -Zero
3574 +Zero
3575 +Subnormal
3576 +Normal
3577 +Infinity
3578 """
3579 if self.is_snan():
3580 return "sNaN"
3581 if self.is_qnan():
3582 return "NaN"
3583 inf = self._isinfinity()
3584 if inf == 1:
3585 return "+Infinity"
3586 if inf == -1:
3587 return "-Infinity"
3588 if self.is_zero():
3589 if self._sign:
3590 return "-Zero"
3591 else:
3592 return "+Zero"
3593 if context is None:
3594 context = getcontext()
3595 if self.is_subnormal(context=context):
3596 if self._sign:
3597 return "-Subnormal"
3598 else:
3599 return "+Subnormal"
3600 # just a normal, regular, boring number, :)
3601 if self._sign:
3602 return "-Normal"
3603 else:
3604 return "+Normal"
3605
3606 def radix(self):
3607 """Just returns 10, as this is Decimal, :)"""

Callers 4

test_none_argsMethod · 0.95
number_classMethod · 0.45
test_named_parametersMethod · 0.45
test_implicit_contextMethod · 0.45

Calls 6

is_snanMethod · 0.95
is_qnanMethod · 0.95
_isinfinityMethod · 0.95
is_zeroMethod · 0.95
is_subnormalMethod · 0.95
getcontextFunction · 0.85

Tested by 3

test_none_argsMethod · 0.76
test_named_parametersMethod · 0.36
test_implicit_contextMethod · 0.36