Skip to content

Commit 356a396

Browse files
committed
[Chore] Simplify flaot typehints
1 parent ac7e98d commit 356a396

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

pyerrors/obs.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,11 @@ def __init__(self, samples: list[Union[ndarray, list[Any]]], names: list[str], i
159159
self.tag = None
160160

161161
@property
162-
def value(self) -> Union[float, int64, float64, int]:
162+
def value(self) -> float:
163163
return self._value
164164

165165
@property
166-
def dvalue(self) -> Union[float, float64]:
166+
def dvalue(self) -> float:
167167
return self._dvalue
168168

169169
@property
@@ -481,7 +481,7 @@ def reweight(self, weight: "Obs") -> "Obs":
481481
"""
482482
return reweight(weight, [self])[0]
483483

484-
def is_zero_within_error(self, sigma: Union[float, int]=1) -> Union[bool, bool]:
484+
def is_zero_within_error(self, sigma: float=1) -> bool:
485485
"""Checks whether the observable is zero within 'sigma' standard errors.
486486
487487
Parameters
@@ -493,7 +493,7 @@ def is_zero_within_error(self, sigma: Union[float, int]=1) -> Union[bool, bool]:
493493
"""
494494
return self.is_zero() or np.abs(self.value) <= sigma * self._dvalue
495495

496-
def is_zero(self, atol: float=1e-10) -> Union[bool, bool]:
496+
def is_zero(self, atol: float=1e-10) -> bool:
497497
"""Checks whether the observable is zero within a given tolerance.
498498
499499
Parameters
@@ -867,7 +867,7 @@ def __truediv__(self, y: Any) -> Union[Obs, NotImplementedType, ndarray]:
867867
else:
868868
return derived_observable(lambda x, **kwargs: x[0] / y, [self], man_grad=[1 / y])
869869

870-
def __rtruediv__(self, y: Union[float, int]) -> Obs:
870+
def __rtruediv__(self, y: float) -> Obs:
871871
if isinstance(y, Obs):
872872
return derived_observable(lambda x, **kwargs: x[0] / x[1], [y, self], man_grad=[1 / self.value, - y.value / self.value ** 2])
873873
else:
@@ -878,13 +878,13 @@ def __rtruediv__(self, y: Union[float, int]) -> Obs:
878878
else:
879879
return derived_observable(lambda x, **kwargs: y / x[0], [self], man_grad=[-y / self.value ** 2])
880880

881-
def __pow__(self, y: Union[Obs, float, int]) -> Obs:
881+
def __pow__(self, y: Union[Obs, float]) -> Obs:
882882
if isinstance(y, Obs):
883883
return derived_observable(lambda x, **kwargs: x[0] ** x[1], [self, y], man_grad=[y.value * self.value ** (y.value - 1), self.value ** y.value * np.log(self.value)])
884884
else:
885885
return derived_observable(lambda x, **kwargs: x[0] ** y, [self], man_grad=[y * self.value ** (y - 1)])
886886

887-
def __rpow__(self, y: Union[float, int]) -> Obs:
887+
def __rpow__(self, y: float) -> Obs:
888888
return derived_observable(lambda x, **kwargs: y ** x[0], [self], man_grad=[y ** self.value * np.log(y)])
889889

890890
def __abs__(self) -> Obs:
@@ -941,7 +941,7 @@ class CObs:
941941
"""Class for a complex valued observable."""
942942
__slots__ = ['_real', '_imag', 'tag']
943943

944-
def __init__(self, real: Obs, imag: Union[Obs, float, int]=0.0):
944+
def __init__(self, real: Obs, imag: Union[Obs, float]=0.0):
945945
self._real = real
946946
self._imag = imag
947947
self.tag = None
@@ -951,7 +951,7 @@ def real(self) -> Obs:
951951
return self._real
952952

953953
@property
954-
def imag(self) -> Union[Obs, float, int]:
954+
def imag(self) -> Union[Obs, float]:
955955
return self._imag
956956

957957
def gamma_method(self, **kwargs):
@@ -979,7 +979,7 @@ def __add__(self, other: Any) -> Union[CObs, ndarray]:
979979
else:
980980
return CObs(self.real + other, self.imag)
981981

982-
def __radd__(self, y: Union[complex, float, Obs, int]) -> "CObs":
982+
def __radd__(self, y: Union[complex, Obs]) -> "CObs":
983983
return self + y
984984

985985
def __sub__(self, other: Any) -> Union[CObs, ndarray]:
@@ -990,7 +990,7 @@ def __sub__(self, other: Any) -> Union[CObs, ndarray]:
990990
else:
991991
return CObs(self.real - other, self.imag)
992992

993-
def __rsub__(self, other: Union[complex, float, Obs, int]) -> "CObs":
993+
def __rsub__(self, other: Union[complex, Obs]) -> "CObs":
994994
return -1 * (self - other)
995995

996996
def __mul__(self, other: Any) -> Union[CObs, ndarray]:
@@ -1012,7 +1012,7 @@ def __mul__(self, other: Any) -> Union[CObs, ndarray]:
10121012
else:
10131013
return CObs(self.real * other, self.imag * other)
10141014

1015-
def __rmul__(self, other: Union[complex, Obs, CObs, float, int]) -> "CObs":
1015+
def __rmul__(self, other: Union[complex, Obs, CObs]) -> "CObs":
10161016
return self * other
10171017

10181018
def __truediv__(self, other: Any) -> Union[CObs, ndarray]:
@@ -1024,7 +1024,7 @@ def __truediv__(self, other: Any) -> Union[CObs, ndarray]:
10241024
else:
10251025
return CObs(self.real / other, self.imag / other)
10261026

1027-
def __rtruediv__(self, other: Union[complex, float, Obs, CObs, int]) -> CObs:
1027+
def __rtruediv__(self, other: Union[complex, Obs, CObs]) -> CObs:
10281028
r = self.real ** 2 + self.imag ** 2
10291029
if hasattr(other, 'real') and hasattr(other, 'imag'):
10301030
return CObs((self.real * other.real + self.imag * other.imag) / r, (self.real * other.imag - self.imag * other.real) / r)
@@ -1164,7 +1164,7 @@ def _intersection_idx(idl: list[Union[range, list[int]]]) -> Union[range, list[i
11641164
return idinter
11651165

11661166

1167-
def _expand_deltas_for_merge(deltas: ndarray, idx: Union[range, list[int]], shape: int, new_idx: Union[range, list[int]], scalefactor: Union[float, int]) -> ndarray:
1167+
def _expand_deltas_for_merge(deltas: ndarray, idx: Union[range, list[int]], shape: int, new_idx: Union[range, list[int]], scalefactor: float) -> ndarray:
11681168
"""Expand deltas defined on idx to the list of configs that is defined by new_idx.
11691169
New, empty entries are filled by 0. If idx and new_idx are of type range, the smallest
11701170
common divisor of the step sizes is used as new step size.

0 commit comments

Comments
 (0)