Merge branch 'develop' into documentation

This commit is contained in:
fjosw 2023-07-14 12:38:38 +00:00
commit 328869f300
3 changed files with 19 additions and 3 deletions

View file

@ -998,8 +998,6 @@ class Corr:
content_string += "Description: " + self.tag + "\n"
if self.N != 1:
return content_string
if isinstance(self[0], CObs):
return content_string
if print_range[1]:
print_range[1] += 1
@ -1010,7 +1008,7 @@ class Corr:
else:
content_string += str(i + print_range[0])
for element in sub_corr:
content_string += '\t' + ' ' * int(element >= 0) + str(element)
content_string += f"\t{element:+2}"
content_string += '\n'
return content_string

View file

@ -1023,6 +1023,14 @@ class CObs:
def __repr__(self):
return 'CObs[' + str(self) + ']'
def __format__(self, format_type):
if format_type == "":
significance = 2
format_type = "2"
else:
significance = int(float(format_type.replace("+", "").replace("-", "")))
return f"({self.real:{format_type}}{self.imag:+{significance}}j)"
def _format_uncertainty(value, dvalue, significance=2):
"""Creates a string of a value and its error in paranthesis notation, e.g., 13.02(45)"""

View file

@ -1297,6 +1297,16 @@ def test_f_string_obs():
print(f"{o1:-1}")
print(f"{o1: 8}")
def test_f_string_cobs():
o_real = pe.pseudo_Obs(0.348, 0.0123, "test")
o_imag = pe.pseudo_Obs(0.348, 0.0123, "test")
o1 = pe.CObs(o_real, o_imag)
print(f"{o1}")
print(f"{o1:3}")
print(f"{o1:+3}")
print(f"{o1:-1}")
print(f"{o1: 8}")
def test_compute_drho_fails():
obs = pe.input.json.load_json("tests/data/compute_drho_fails.json.gz")
obs.gm()