File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,8 @@ from flint.flintlib.types.flint cimport (
66)
77from flint.utils.conversion cimport prec_to_dps, dps_to_prec
88
9+ from functools import wraps
10+
911cdef class FlintContext:
1012 def __init__ (self ):
1113 self .default()
@@ -92,6 +94,24 @@ class PrecisionManager:
9294 self .eprec = eprec
9395 self .edps = edps
9496
97+ def __call__ (self , func ):
98+ @ wraps (func)
99+ def wrapped (*args , **kwargs ):
100+ _oldprec = self .ctx.prec
101+
102+ try :
103+ if self .eprec is not None :
104+ self .ctx.prec = self .eprec
105+
106+ if self .edps is not None :
107+ self .ctx.dps = self .edps
108+
109+ return func(* args, ** kwargs)
110+ finally :
111+ self .ctx.prec = _oldprec
112+
113+ return wrapped
114+
95115 def __enter__ (self ):
96116 self ._oldprec = self .ctx.prec
97117
You can’t perform that action at this time.
0 commit comments