Skip to content

Commit bb6ceb4

Browse files
committed
Merge branch 'master' into bugfix/380061-removing-dependencies
2 parents 05a3567 + c149d4c commit bb6ceb4

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

wolframclient/deserializers/wxf/wxfconsumer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def consume_bigint(self, current_token, tokens, **kwargs):
154154
except ValueError:
155155
raise WolframParserException("Invalid big integer value: %s" % current_token.data)
156156

157-
BIGREAL_RE = re.compile(r"([^`]+)(`[0-9.]+){0,1}(\*\^[0-9]+){0,1}")
157+
BIGREAL_RE = re.compile(r"([^`]+)(`[0-9.]+){0,1}(\*\^){0,1}(-?[0-9]+){0,1}")
158158

159159
def consume_bigreal(self, current_token, tokens, **kwargs):
160160
"""Parse a WXF big real as a WXF serializable big real.
@@ -169,10 +169,10 @@ def consume_bigreal(self, current_token, tokens, **kwargs):
169169

170170
if match:
171171

172-
num, prec, exp = match.groups()
172+
num, _, _, exp = match.groups()
173173

174174
if exp:
175-
return decimal.Decimal("%se%s" % (num, exp[2:]))
175+
return decimal.Decimal("%se%s" % (num, exp))
176176

177177
return decimal.Decimal(num)
178178

wolframclient/tests/deserializers/wxf_deserialize.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,11 @@ def test_bigreal_precision_exponent(self):
147147
res = binary_deserialize(wxf, consumer=WXFConsumer())
148148
self.assertEqual(res, decimal.Decimal("9.999999999999996843873323328588479844E+999"))
149149

150+
def test_bigreal_precision_negexponent(self):
151+
wxf = b'8:RC4.590261537982443550699999999999999999999281`19.66183743091127*^-16'
152+
res = binary_deserialize(wxf, consumer=WXFConsumer())
153+
self.assertEqual(res, decimal.Decimal('4.590261537982443550699999999999999999999281E-16'))
154+
150155
def test_empty_lists(self):
151156
value = ((), ((),), (1, ()), ())
152157
self.wxf_assert_roundtrip(value)

0 commit comments

Comments
 (0)