Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jan 29, 2024
1 parent f6f517f commit 2ed5cb0
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 70 deletions.
6 changes: 2 additions & 4 deletions src/barril/curve/curve.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,10 @@ def __eq__(self, other: Any) -> bool:
return self.GetImage() == other.GetImage() and self.GetDomain() == other.GetDomain()

@overload
def __getitem__(self, index: int) -> Tuple[float, float]:
...
def __getitem__(self, index: int) -> Tuple[float, float]: ...

@overload
def __getitem__(self, index: slice) -> Tuple[ValuesType, ValuesType]:
...
def __getitem__(self, index: slice) -> Tuple[ValuesType, ValuesType]: ...

def __getitem__(self, index: Union[int, slice]) -> Tuple[Any, Any]:
d = self.GetDomain().GetValues()[index] # type:ignore[index]
Expand Down
6 changes: 2 additions & 4 deletions src/barril/curve/curve_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,10 @@ def GetDomain(self) -> Array: # type:ignore[empty-body]
"""

@overload
def __getitem__(self, index: int) -> Tuple[float, float]:
...
def __getitem__(self, index: int) -> Tuple[float, float]: ...

@overload
def __getitem__(self, index: slice) -> Tuple[ValuesType, ValuesType]:
...
def __getitem__(self, index: slice) -> Tuple[ValuesType, ValuesType]: ...

def __getitem__(self, index: Union[int, slice]) -> Any:
"""
Expand Down
18 changes: 6 additions & 12 deletions src/barril/units/_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,20 +72,16 @@ def compute(inputs: Array[np.ndarray[np.float64]]) -> Array[np.ndarray[np.float6
"""

@overload
def __init__(self, category: Union[str, Quantity]):
...
def __init__(self, category: Union[str, Quantity]): ...

@overload
def __init__(self, values: ValuesType, unit: str, category: Optional[str] = None):
...
def __init__(self, values: ValuesType, unit: str, category: Optional[str] = None): ...

@overload
def __init__(self, category: str, values: ValuesType, unit: str):
...
def __init__(self, category: str, values: ValuesType, unit: str): ...

@overload
def __init__(self, category: Quantity, values: ValuesType):
...
def __init__(self, category: Quantity, values: ValuesType): ...

def __init__( # type:ignore[misc]
self, category: str, values: Any = None, unit: Any = None
Expand Down Expand Up @@ -343,12 +339,10 @@ def __len__(self) -> int:
return len(self.values)

@overload
def __getitem__(self, index: int) -> Any:
...
def __getitem__(self, index: int) -> Any: ...

@overload
def __getitem__(self, index: slice) -> ValuesType:
...
def __getitem__(self, index: slice) -> ValuesType: ...

def __getitem__(self, index: Any) -> Any:
return self.values[index]
Expand Down
15 changes: 5 additions & 10 deletions src/barril/units/_fixedarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,24 +39,19 @@ class FixedArray(Array, Generic[ValuesType]):
_dimension: Any = None

@overload
def __init__(self, dimension: int, category: Union[str, "Quantity"]):
...
def __init__(self, dimension: int, category: Union[str, "Quantity"]): ...

@overload
def __init__(self, dimension: int, values: ValuesType, unit: str):
...
def __init__(self, dimension: int, values: ValuesType, unit: str): ...

@overload
def __init__(self, dimension: int, category: str, values: ValuesType, unit: str):
...
def __init__(self, dimension: int, category: str, values: ValuesType, unit: str): ...

@overload
def __init__(self, dimension: int, category: str, unit: str):
...
def __init__(self, dimension: int, category: str, unit: str): ...

@overload
def __init__(self, dimension: int, category: "Quantity", values: ValuesType):
...
def __init__(self, dimension: int, category: "Quantity", values: ValuesType): ...

def __init__( # type:ignore[misc]
self, dimension: int, category: str, values: Any = None, unit: Any = None
Expand Down
15 changes: 5 additions & 10 deletions src/barril/units/_fraction_scalar.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,21 @@ class FractionScalar(AbstractValueWithQuantityObject):
"""

@overload
def __init__(self, quantity: str):
...
def __init__(self, quantity: str): ...

@overload
def __init__(self, quantity: str, value: Union[FractionValue, float], unit: str):
...
def __init__(self, quantity: str, value: Union[FractionValue, float], unit: str): ...

@overload
def __init__(self, quantity: "IQuantity", value: Union[FractionValue, float]):
...
def __init__(self, quantity: "IQuantity", value: Union[FractionValue, float]): ...

@overload
def __init__(self, quantity: str, unit: str):
...
def __init__(self, quantity: str, unit: str): ...

@overload
def __init__(
self, value: Union[FractionValue, float], unit: str, category: Optional[str] = None
):
...
): ...

def __init__(self, *args: Any, **kwargs: Any) -> None:
super().__init__(*args, **kwargs)
Expand Down
9 changes: 3 additions & 6 deletions src/barril/units/_quantity.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,25 +37,22 @@ def ObtainQuantity(
unit: str,
category: Optional[str] = None,
unknown_unit_caption: Optional[str] = None,
) -> "Quantity":
...
) -> "Quantity": ...


@overload
def ObtainQuantity(
unit: str,
category: Union[Tuple[str, ...], str],
) -> "Quantity":
...
) -> "Quantity": ...


@overload
def ObtainQuantity(
unit: Union[None, List[UnitExponentTuple], Dict[str, Sequence[Union[str, int]]]],
category: Optional[str] = None,
unknown_unit_caption: Optional[str] = None,
) -> "Quantity":
...
) -> "Quantity": ...


def ObtainQuantity(
Expand Down
14 changes: 6 additions & 8 deletions src/barril/units/_scalar.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,20 +75,18 @@ def Compute(x, y):
"""

@overload
def __init__(self, category: Quantity, value: Optional[float] = None) -> None:
...
def __init__(self, category: Quantity, value: Optional[float] = None) -> None: ...

@overload
def __init__(self, category: str, value: Optional[float] = None, unit: Optional[str] = None):
...
def __init__(
self, category: str, value: Optional[float] = None, unit: Optional[str] = None
): ...

@overload
def __init__(self, value: float, unit: str, category: Optional[str] = None):
...
def __init__(self, value: float, unit: str, category: Optional[str] = None): ...

@overload
def __init__(self, value_and_unit: Tuple[float, str]):
...
def __init__(self, value_and_unit: Tuple[float, str]): ...

def __init__( # type:ignore[misc]
self, category: Any, value: Any = None, unit: Any = None
Expand Down
12 changes: 6 additions & 6 deletions src/barril/units/_tests/test_unit_rich_text_representations.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@ def testUnitRichTextRepresentations() -> None:
new_unit = "new_unit"
new_unit_representation = "new<sup>unit</sup>"

UnitRichTextRepresentations.DEFAULT_UNITS_RICH_TEXT_REPRESENTATIONS[
new_unit
] = new_unit_representation
UnitRichTextRepresentations.DEFAULT_UNITS_RICH_TEXT_REPRESENTATIONS[new_unit] = (
new_unit_representation
)
AssertRTFCaption(
UnitRichTextRepresentations.GetUnitHtmlRepresentation(new_unit), new_unit_representation
)

# But the user should be able to overwrite the default values with a custom representation
new_cubic_meter_representation = "m<sub>3</sub>"
cubic_meter_caption = "m3"
UnitRichTextRepresentations.DEFAULT_UNITS_RICH_TEXT_REPRESENTATIONS[
cubic_meter_caption
] = new_cubic_meter_representation
UnitRichTextRepresentations.DEFAULT_UNITS_RICH_TEXT_REPRESENTATIONS[cubic_meter_caption] = (
new_cubic_meter_representation
)

AssertRTFCaption(
UnitRichTextRepresentations.GetUnitHtmlRepresentation(cubic_meter_caption),
Expand Down
15 changes: 5 additions & 10 deletions src/barril/units/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,19 +261,14 @@ class MinimalSequence(Protocol[ValueType]):
``numpy`` doesn't implement.
"""

def __iter__(self) -> Iterator[ValueType]:
...
def __iter__(self) -> Iterator[ValueType]: ...

def __len__(self) -> int:
...
def __len__(self) -> int: ...

@overload
def __getitem__(self, item: int) -> ValueType:
...
def __getitem__(self, item: int) -> ValueType: ...

@overload
def __getitem__(self, item: slice) -> "MinimalSequence[ValueType]":
...
def __getitem__(self, item: slice) -> "MinimalSequence[ValueType]": ...

def __getitem__(self, item: Any) -> Any:
...
def __getitem__(self, item: Any) -> Any: ...

0 comments on commit 2ed5cb0

Please sign in to comment.