Skip to content

Commit fcf3bec

Browse files
committed
Revert 849e185 and (partially) f4cef9c (same for with field)
While python/cpython#130662 being discussed, lets keep previous (more strict) formatting specification.
1 parent 4e6f678 commit fcf3bec

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

mpmath/libmp/libmpf.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1397,10 +1397,10 @@ def from_str(x, prec=0, rnd=round_fast, base=0):
13971397
(?P<sign>[-+ ]?)
13981398
(?P<no_neg_0>z)?
13991399
(?P<alternate>\#)?
1400-
(?P<zeropad>0(?=0*[1-9]))?
1401-
(?P<width>[0-9]+)?
1400+
(?P<zeropad>0(?=[0-9]))?
1401+
(?P<width>0|[1-9][0-9]*)?
14021402
(?P<thousands_separators>[,_])?
1403-
(?:\.(?P<precision>[0-9]+)(?P<frac_separators>[,_])?)?
1403+
(?:\.(?P<precision>0|[1-9][0-9]*)(?P<frac_separators>[,_])?)?
14041404
(?P<rounding>[UDYZN])?
14051405
(?P<type>[aAbeEfFgG%])?
14061406
""", re.DOTALL | re.VERBOSE).fullmatch

mpmath/tests/test_format.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,18 +54,15 @@ def fmt_str(draw, types='fFeE', for_complex=False):
5454
skip_thousand_separators = True
5555

5656
# Width
57-
res += draw(st.sampled_from(['']*7 + list(map(str, range(1, 40)))
58-
+ ([] if for_complex else ['0' + str(_)
59-
for _ in range(40)])))
57+
res += draw(st.sampled_from(['']*7 + list(map(str, range(1, 40)))))
6058

6159
# grouping character (thousand_separators)
6260
gchar = draw(st.sampled_from([''] + list(',_')))
6361
if gchar and not skip_thousand_separators:
6462
res += gchar
6563

6664
# Precision
67-
prec = draw(st.sampled_from(['']*7 + list(map(str, range(40)))
68-
+ ['0' + str(_) for _ in range(40)]))
65+
prec = draw(st.sampled_from(['']*7 + list(map(str, range(40)))))
6966
if prec:
7067
res += '.' + prec
7168
# if sys.version_info >= (3, 14):
@@ -477,8 +474,6 @@ def test_mpf_fmt_cpython():
477474
allow_infinity=True,
478475
allow_subnormal=True))
479476
@example(fmt='.0g', x=9.995074823339339e-05) # issue 880
480-
@example(fmt='.016f', x=0.1) # issue 915
481-
@example(fmt='0030f', x=0.3)
482477
@example(fmt='0=13,f', x=1.1) # issue 917
483478
@example(fmt='013,f', x=1.1)
484479
@example(fmt='013,.0%', x=1.1)

0 commit comments

Comments
 (0)