We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 2c12f33 commit 81c5b64Copy full SHA for 81c5b64
src/flint/flint_base/flint_context.pyx
@@ -6,6 +6,8 @@ from flint.flintlib.types.flint cimport (
6
)
7
from flint.utils.conversion cimport prec_to_dps, dps_to_prec
8
9
+from functools import wraps
10
+
11
cdef class FlintContext:
12
def __init__(self):
13
self.default()
@@ -92,6 +94,24 @@ class PrecisionManager:
92
94
self.eprec = eprec
93
95
self.edps = edps
96
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
115
def __enter__(self):
116
self._oldprec = self.ctx.prec
117
0 commit comments