mirror of
https://github.com/fjosw/pyerrors.git
synced 2025-03-15 14:50:25 +01:00
Fix Obs in f-strings without specifier (#190)
* fix: Conversion of an array with ndim > 0 to a scalar deprecation fixed. * fix: adjusted maximal value for rho in test_gamma_method_irregular. * fix: obs in f-strings now work again when no specifier is provided.
This commit is contained in:
parent
ca70c7571b
commit
bb43a8afb7
2 changed files with 13 additions and 1 deletions
|
@ -694,8 +694,12 @@ class Obs:
|
|||
return _format_uncertainty(self.value, self._dvalue)
|
||||
|
||||
def __format__(self, format_type):
|
||||
if format_type == "":
|
||||
significance = 2
|
||||
else:
|
||||
significance = int(float(format_type.replace("+", "").replace("-", "")))
|
||||
my_str = _format_uncertainty(self.value, self._dvalue,
|
||||
significance=int(float(format_type.replace("+", "").replace("-", ""))))
|
||||
significance=significance)
|
||||
for char in ["+", " "]:
|
||||
if format_type.startswith(char):
|
||||
if my_str[0] != "-":
|
||||
|
|
|
@ -1274,3 +1274,11 @@ def test_format():
|
|||
assert o1.__format__("+3") == '+0.3480(123)'
|
||||
assert o1.__format__("+2") == '+0.348(12)'
|
||||
assert o1.__format__(" 2") == ' 0.348(12)'
|
||||
|
||||
def test_f_string_obs():
|
||||
o1 = pe.pseudo_Obs(0.348, 0.0123, "test")
|
||||
print(f"{o1}")
|
||||
print(f"{o1:3}")
|
||||
print(f"{o1:+3}")
|
||||
print(f"{o1:-1}")
|
||||
print(f"{o1: 8}")
|
||||
|
|
Loading…
Add table
Reference in a new issue