mirror of
https://github.com/fjosw/pyerrors.git
synced 2025-05-14 11:33:42 +02:00
[Fix] More type hint fixing
This commit is contained in:
parent
5376a8ad44
commit
336117c1cf
4 changed files with 12 additions and 10 deletions
|
@ -209,7 +209,7 @@ class Corr:
|
||||||
newcontent = [None if (item is None) else item[i, j] for item in self.content]
|
newcontent = [None if (item is None) else item[i, j] for item in self.content]
|
||||||
return Corr(newcontent)
|
return Corr(newcontent)
|
||||||
|
|
||||||
def plottable(self) -> tuple[list[int], list[float]]:
|
def plottable(self) -> tuple[list, list, list]:
|
||||||
"""Outputs the correlator in a plotable format.
|
"""Outputs the correlator in a plotable format.
|
||||||
|
|
||||||
Outputs three lists containing the timeslice index, the value on each
|
Outputs three lists containing the timeslice index, the value on each
|
||||||
|
@ -1415,7 +1415,7 @@ class Corr:
|
||||||
return Corr(newcontent)
|
return Corr(newcontent)
|
||||||
|
|
||||||
|
|
||||||
def _sort_vectors(vec_set_in: list[Optional[ndarray]], ts: int) -> list[Optional[Union[ndarray, list[ndarray]]]]:
|
def _sort_vectors(vec_set_in: list[Optional[ndarray]], ts: int) -> list[Union[None, ndarray, list[ndarray]]]:
|
||||||
"""Helper function used to find a set of Eigenvectors consistent over all timeslices"""
|
"""Helper function used to find a set of Eigenvectors consistent over all timeslices"""
|
||||||
|
|
||||||
if isinstance(vec_set_in[ts][0][0], Obs):
|
if isinstance(vec_set_in[ts][0][0], Obs):
|
||||||
|
|
|
@ -338,8 +338,8 @@ def read_pobs(fname: str, full_output: bool=False, gz: bool=True, separator_inse
|
||||||
if gz:
|
if gz:
|
||||||
if not fname.endswith('.gz'):
|
if not fname.endswith('.gz'):
|
||||||
fname += '.gz'
|
fname += '.gz'
|
||||||
with gzip.open(fname, 'r') as fin:
|
with gzip.open(fname, 'r') as gin:
|
||||||
content = fin.read()
|
content = gin.read()
|
||||||
else:
|
else:
|
||||||
if fname.endswith('.gz'):
|
if fname.endswith('.gz'):
|
||||||
warnings.warn("Trying to read from %s without unzipping!" % fname, UserWarning)
|
warnings.warn("Trying to read from %s without unzipping!" % fname, UserWarning)
|
||||||
|
@ -721,7 +721,7 @@ def create_dobs_string(obsl: list[Obs], name: str, spec: str='dobs v1.0', origin
|
||||||
symbol = []
|
symbol = []
|
||||||
if enstags is None:
|
if enstags is None:
|
||||||
enstags = {}
|
enstags = {}
|
||||||
od = {}
|
od: dict[str, Any] = {}
|
||||||
r_names = []
|
r_names = []
|
||||||
for o in obsl:
|
for o in obsl:
|
||||||
r_names += [name for name in o.names if name.split('|')[0] in o.mc_names]
|
r_names += [name for name in o.names if name.split('|')[0] in o.mc_names]
|
||||||
|
@ -821,7 +821,7 @@ def create_dobs_string(obsl: list[Obs], name: str, spec: str='dobs v1.0', origin
|
||||||
ed[''].append(ad)
|
ed[''].append(ad)
|
||||||
pd['edata'].append(ed)
|
pd['edata'].append(ed)
|
||||||
|
|
||||||
allcov = {}
|
allcov: dict[str, ndarray] = {}
|
||||||
for o in obsl:
|
for o in obsl:
|
||||||
for cname in o.cov_names:
|
for cname in o.cov_names:
|
||||||
if cname in allcov:
|
if cname in allcov:
|
||||||
|
@ -925,9 +925,10 @@ def write_dobs(obsl: list[Obs], fname: str, name: str, spec: str='dobs v1.0', or
|
||||||
if not fname.endswith('.gz'):
|
if not fname.endswith('.gz'):
|
||||||
fname += '.gz'
|
fname += '.gz'
|
||||||
|
|
||||||
fp = gzip.open(fname, 'wb')
|
gp = gzip.open(fname, 'wb')
|
||||||
fp.write(dobsstring.encode('utf-8'))
|
gp.write(dobsstring.encode('utf-8'))
|
||||||
|
gp.close()
|
||||||
else:
|
else:
|
||||||
fp = open(fname, 'w', encoding='utf-8')
|
fp = open(fname, 'w', encoding='utf-8')
|
||||||
fp.write(dobsstring)
|
fp.write(dobsstring)
|
||||||
fp.close()
|
fp.close()
|
||||||
|
|
|
@ -517,6 +517,7 @@ def _find_correlator(file_name: str, version: str, pattern: str, b2b: bool, sile
|
||||||
else:
|
else:
|
||||||
start_read = content.count('\n', 0, match.start()) + 5 + b2b
|
start_read = content.count('\n', 0, match.start()) + 5 + b2b
|
||||||
end_match = re.search(r'\n\s*\n', content[match.start():])
|
end_match = re.search(r'\n\s*\n', content[match.start():])
|
||||||
|
assert end_match is not None
|
||||||
T = content[match.start():].count('\n', 0, end_match.start()) - 4 - b2b
|
T = content[match.start():].count('\n', 0, end_match.start()) - 4 - b2b
|
||||||
if not T > 0:
|
if not T > 0:
|
||||||
raise ValueError("Correlator with pattern\n" + pattern + "\nis empty!")
|
raise ValueError("Correlator with pattern\n" + pattern + "\nis empty!")
|
||||||
|
|
|
@ -69,7 +69,7 @@ class Obs:
|
||||||
N_sigma_global = 1.0
|
N_sigma_global = 1.0
|
||||||
N_sigma_dict: dict[str, int] = {}
|
N_sigma_dict: dict[str, int] = {}
|
||||||
|
|
||||||
def __init__(self, samples: list[Union[ndarray, list[Any]]], names: list[str], idl: Optional[list[Union[list[int], range]]]=None, **kwargs):
|
def __init__(self, samples: list[Union[ndarray, list[Any]]], names: list[str], idl: Optional[Union[list[list[int]], list[Union[list[int], range]], list[range]]]=None, **kwargs):
|
||||||
""" Initialize Obs object.
|
""" Initialize Obs object.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue