MCPcopy Index your code
hub / github.com/python/cpython / number_class

Method number_class

Lib/_pydecimal.py:3567–3607  ·  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

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

Callers 5

test_none_argsMethod · 0.95
number_classMethod · 0.45
test_named_parametersMethod · 0.45
test_implicit_contextMethod · 0.45
verifyFunction · 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