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

Class Context

Lib/_pydecimal.py:3847–5590  ·  view source on GitHub ↗

Contains the context for a Decimal instance. Contains: prec - precision (for use in rounding, division, square roots..) rounding - rounding type (how you round) traps - If traps[exception] = 1, then the exception is raised when it is caused. Otherwise, a value i

Source from the content-addressed store, hash-verified

3845 setcontext(self.saved_context)
3846
3847class Context(object):
3848 """Contains the context for a Decimal instance.
3849
3850 Contains:
3851 prec - precision (for use in rounding, division, square roots..)
3852 rounding - rounding type (how you round)
3853 traps - If traps[exception] = 1, then the exception is
3854 raised when it is caused. Otherwise, a value is
3855 substituted in.
3856 flags - When an exception is caused, flags[exception] is set.
3857 (Whether or not the trap_enabler is set)
3858 Should be reset by user of Decimal instance.
3859 Emin - Minimum exponent
3860 Emax - Maximum exponent
3861 capitals - If 1, 1*10^1 is printed as 1E+1.
3862 If 0, printed as 1e1
3863 clamp - If 1, change exponents if too high (Default 0)
3864 """
3865
3866 def __init__(self, prec=None, rounding=None, Emin=None, Emax=None,
3867 capitals=None, clamp=None, flags=None, traps=None,
3868 _ignored_flags=None):
3869 # Set defaults; for everything except flags and _ignored_flags,
3870 # inherit from DefaultContext.
3871 try:
3872 dc = DefaultContext
3873 except NameError:
3874 pass
3875
3876 self.prec = prec if prec is not None else dc.prec
3877 self.rounding = rounding if rounding is not None else dc.rounding
3878 self.Emin = Emin if Emin is not None else dc.Emin
3879 self.Emax = Emax if Emax is not None else dc.Emax
3880 self.capitals = capitals if capitals is not None else dc.capitals
3881 self.clamp = clamp if clamp is not None else dc.clamp
3882
3883 if _ignored_flags is None:
3884 self._ignored_flags = []
3885 else:
3886 self._ignored_flags = _ignored_flags
3887
3888 if traps is None:
3889 self.traps = dc.traps.copy()
3890 elif not isinstance(traps, dict):
3891 self.traps = dict((s, int(s in traps)) for s in _signals + traps)
3892 else:
3893 self.traps = traps
3894
3895 if flags is None:
3896 self.flags = dict.fromkeys(_signals, 0)
3897 elif not isinstance(flags, dict):
3898 self.flags = dict((s, int(s in flags)) for s in _signals + flags)
3899 else:
3900 self.flags = flags
3901
3902 def _set_integer_check(self, name, value, vmin, vmax):
3903 if not isinstance(value, int):
3904 raise TypeError("%s must be an integer" % name)

Callers 5

getcontextFunction · 0.70
IEEEContextFunction · 0.70
_shallow_copyMethod · 0.70
copyMethod · 0.70
_pydecimal.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected