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()
@@ -91,6 +93,24 @@ class PrecisionManager:
9193 self .eprec = eprec
9294 self .edps = edps
9395
96+ def __call__ (self , func ):
97+ @ wraps (func)
98+ def wrapped (*args , **kwargs ):
99+ _oldprec = self .ctx.prec
100+
101+ try :
102+ if self .eprec is not None :
103+ self .ctx.prec = self .eprec
104+
105+ if self .edps is not None :
106+ self .ctx.dps = self .edps
107+
108+ return func(* args, ** kwargs)
109+ finally :
110+ self .ctx.prec = _oldprec
111+
112+ return wrapped
113+
94114 def __enter__ (self ):
95115 self ._oldprec = self .ctx.prec
96116
You can’t perform that action at this time.
0 commit comments