Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
3db8eb2
[Feat] Add type hints to pyerrors modules
fjosw Dec 25, 2024
9fe375a
[Feat] Added type hints to input modules
fjosw Dec 25, 2024
8d86295
[Feat] Fixed a few type hints manually
fjosw Dec 25, 2024
2d34b35
[Fix] Fix ruff errors and a few type annotations
fjosw Dec 25, 2024
a9e082c
[Fix] Fix type annotations for first part of obs.py
fjosw Jan 3, 2025
0198256
[Fix] Fixed most type annotations in obs.py
fjosw Jan 3, 2025
9389ad6
[CI] Add typing extension package to pytest run for pytthon 3.9
fjosw Jan 3, 2025
23d4f4c
[Fix] Fix type hints in misc.py and remove strict zips for python 3.9
fjosw Jan 3, 2025
1916de1
[Fix] Start fixing remaining type hints
fjosw Jan 3, 2025
3654635
[Fix] Removed unused imports
fjosw Jan 3, 2025
4f1606d
[CI] Add E252 to flake8 exceptions
fjosw Jan 3, 2025
d45b43e
[Fix] Fixed remaining flake8 errors
fjosw Jan 3, 2025
1c6053e
[Fix] Simplify type hints
fjosw Jan 3, 2025
b8700ef
[Fix] Fix type annotations in json.py
fjosw Jan 3, 2025
6d5a9b9
[Fix] Simplify type annotations in input modules
fjosw Jan 3, 2025
6a990c1
[Fix] Fix ruff
fjosw Jan 3, 2025
9c960ae
[Fix] Correct type hints in fits.py
fjosw Jan 5, 2025
5376a8a
[Fix] Further type fixes in fits and sfcf
fjosw Jan 5, 2025
336117c
[Fix] More type hint fixing
fjosw Jan 5, 2025
dba277f
Merge branch 'develop' into feat/typehints
jkuhl-uni Jan 6, 2025
52b91d8
add typehints for other util functions
jkuhl-uni Jan 9, 2025
cb9d942
make deriv structure like second_deriv
jkuhl-uni Jan 9, 2025
2f40ff8
add typing for read_pbp
jkuhl-uni Jan 9, 2025
bbf0b68
[Fix] Additional typehints
fjosw Jan 7, 2025
7a3a28d
add typehints for check_params
jkuhl-uni Jan 13, 2025
4814675
[Fix] more work on typehints
s-kuberski Feb 17, 2025
f44b19c
clean up sfcf input types
jkuhl-uni Mar 29, 2025
96cdec4
annotate read_ms5_xsf
jkuhl-uni Mar 29, 2025
4cfe863
Merge branch 'feat/typehints' of github.com:fjosw/pyerrors into feat/…
jkuhl-uni Mar 29, 2025
b3b4126
some more quick fixes
jkuhl-uni Mar 29, 2025
6d80efd
Merge branch 'develop' into feat/typehints
fjosw May 5, 2025
f594e06
[Fix] Clean up merge conflict
fjosw May 5, 2025
ab8ca3a
[Fix] Clean up whitespaces
fjosw May 5, 2025
f3e7cde
[Fix] Remove Unpack for compatibility with older python versions.
fjosw May 5, 2025
ac7e98d
simple fix for openQCD in test fails
jkuhl-uni May 7, 2025
356a396
[Chore] Simplify flaot typehints
fjosw Jun 23, 2025
54a8e02
Merge branch 'develop' into feat/typehints
jkuhl-uni Nov 3, 2025
a4525be
correct typo
jkuhl-uni Nov 3, 2025
1a77122
small type corrections
jkuhl-uni Nov 3, 2025
33be7c2
simplify internal method for read_rwms
jkuhl-uni Nov 3, 2025
c822811
fix types for r_start and r_stop, also for postfix
jkuhl-uni Nov 3, 2025
b8ee9ec
lint
jkuhl-uni Nov 3, 2025
eb94260
allow all as tag
jkuhl-uni Nov 3, 2025
5bad13f
simplify read_flow_obs names handling
jkuhl-uni Nov 3, 2025
e2649b3
small renamings
jkuhl-uni Nov 3, 2025
4f09fc7
better steps from kwargs in read flow obs
jkuhl-uni Nov 3, 2025
1e00caf
small switch of lines
jkuhl-uni Nov 3, 2025
4f8567a
lint
jkuhl-uni Nov 3, 2025
fb7ba0c
simplify r_start and r_stop in read_pbp
jkuhl-uni Nov 3, 2025
dddaaa4
renameing in read_hd5 for less confisuion
jkuhl-uni Nov 3, 2025
53192d3
typehints for hadron read functions
jkuhl-uni Nov 3, 2025
9827899
lint
jkuhl-uni Nov 3, 2025
38692d2
add typehints for bdio
jkuhl-uni Nov 3, 2025
dcf6a1f
being a bit more concrete with literals
jkuhl-uni Nov 4, 2025
dd6a2dc
cast epsilon tensors to int
jkuhl-uni Nov 4, 2025
e116e74
undo import change
jkuhl-uni Nov 4, 2025
c9cef8f
add some typecasts
jkuhl-uni Nov 4, 2025
898551d
rename some internal functions
jkuhl-uni Nov 4, 2025
38df833
small renaming for type consistency
jkuhl-uni Nov 4, 2025
51b9d2f
undo signature change in linalg
jkuhl-uni Nov 4, 2025
8d9a136
slight typechange in cov_Obs
jkuhl-uni Nov 4, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/flake8.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ jobs:
- name: flake8 Lint
uses: py-actions/flake8@v2
with:
ignore: "E501,W503"
ignore: "E501,W503,E252"
exclude: "__init__.py, input/__init__.py"
path: "pyerrors"
2 changes: 1 addition & 1 deletion .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
run: |
uv pip install wheel --system
uv pip install . --system
uv pip install pytest pytest-cov pytest-benchmark hypothesis --system
uv pip install pytest pytest-cov pytest-benchmark hypothesis typing_extensions --system
uv pip freeze --system

- name: Run tests with -Werror
Expand Down
202 changes: 97 additions & 105 deletions pyerrors/correlators.py

Large diffs are not rendered by default.

15 changes: 9 additions & 6 deletions pyerrors/covobs.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
from __future__ import annotations
import numpy as np
from numpy import ndarray
from typing import Optional, Union


class Covobs:

def __init__(self, mean, cov, name, pos=None, grad=None):
def __init__(self, mean: Union[float, int], cov: Union[list, ndarray], name: str, pos: Optional[int]=None, grad: Optional[Union[ndarray, list[float]]]=None):
""" Initialize Covobs object.

Parameters
Expand Down Expand Up @@ -39,12 +42,12 @@ def __init__(self, mean, cov, name, pos=None, grad=None):
self._set_grad(grad)
self.value = mean

def errsq(self):
def errsq(self) -> float:
""" Return the variance (= square of the error) of the Covobs
"""
return np.dot(np.transpose(self.grad), np.dot(self.cov, self.grad)).item()

def _set_cov(self, cov):
def _set_cov(self, cov: Union[list, ndarray]):
""" Set the covariance matrix of the covobs

Parameters
Expand Down Expand Up @@ -79,7 +82,7 @@ def _set_cov(self, cov):
if ev < 0:
raise Exception('Covariance matrix is not positive-semidefinite!')

def _set_grad(self, grad):
def _set_grad(self, grad: Union[list[float], ndarray]):
""" Set the gradient of the covobs

Parameters
Expand All @@ -96,9 +99,9 @@ def _set_grad(self, grad):
raise Exception('Invalid dimension of grad!')

@property
def cov(self):
def cov(self) -> ndarray:
return self._cov

@property
def grad(self):
def grad(self) -> ndarray:
return self._grad
12 changes: 7 additions & 5 deletions pyerrors/dirac.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from __future__ import annotations
import numpy as np
from numpy import ndarray


gammaX = np.array(
Expand All @@ -22,7 +24,7 @@
dtype=complex)


def epsilon_tensor(i, j, k):
def epsilon_tensor(i: int, j: int, k: int) -> int:
"""Rank-3 epsilon tensor

Based on https://codegolf.stackexchange.com/a/160375
Expand All @@ -36,10 +38,10 @@ def epsilon_tensor(i, j, k):
if not (test_set <= set((1, 2, 3)) or test_set <= set((0, 1, 2))):
raise ValueError("Unexpected input", i, j, k)

return (i - j) * (j - k) * (k - i) / 2
return int((i - j) * (j - k) * (k - i) / 2)


def epsilon_tensor_rank4(i, j, k, o):
def epsilon_tensor_rank4(i: int, j: int, k: int, o: int) -> int:
"""Rank-4 epsilon tensor

Extension of https://codegolf.stackexchange.com/a/160375
Expand All @@ -54,10 +56,10 @@ def epsilon_tensor_rank4(i, j, k, o):
if not (test_set <= set((1, 2, 3, 4)) or test_set <= set((0, 1, 2, 3))):
raise ValueError("Unexpected input", i, j, k, o)

return (i - j) * (j - k) * (k - i) * (i - o) * (j - o) * (o - k) / 12
return int((i - j) * (j - k) * (k - i) * (i - o) * (j - o) * (o - k) / 12)


def Grid_gamma(gamma_tag):
def Grid_gamma(gamma_tag: str) -> ndarray:
"""Returns gamma matrix in Grid labeling."""
if gamma_tag == 'Identity':
g = identity
Expand Down
Loading
Loading