summaryrefslogtreecommitdiff
path: root/pint/util.py
diff options
context:
space:
mode:
Diffstat (limited to 'pint/util.py')
-rw-r--r--pint/util.py21
1 files changed, 11 insertions, 10 deletions
diff --git a/pint/util.py b/pint/util.py
index e250b0e..09aed5f 100644
--- a/pint/util.py
+++ b/pint/util.py
@@ -28,6 +28,7 @@ from typing import (
Callable,
TypeVar,
Any,
+ Optional,
)
from collections.abc import Hashable, Generator
@@ -63,8 +64,8 @@ def _noop(x: T) -> T:
def matrix_to_string(
matrix: ItMatrix,
- row_headers: Iterable[str] | None = None,
- col_headers: Iterable[str] | None = None,
+ row_headers: Optional[Iterable[str]] = None,
+ col_headers: Optional[Iterable[str]] = None,
fmtfun: Callable[
[
Scalar,
@@ -231,7 +232,7 @@ def column_echelon_form(
return _transpose(ech_matrix), _transpose(id_matrix), swapped
-def pi_theorem(quantities: dict[str, Any], registry: UnitRegistry | None = None):
+def pi_theorem(quantities: dict[str, Any], registry: Optional[UnitRegistry] = None):
"""Builds dimensionless quantities using the Buckingham π theorem
Parameters
@@ -347,7 +348,7 @@ def solve_dependencies(
def find_shortest_path(
- graph: dict[TH, set[TH]], start: TH, end: TH, path: list[TH] | None = None
+ graph: dict[TH, set[TH]], start: TH, end: TH, path: Optional[list[TH]] = None
):
"""Find shortest path between two nodes within a graph.
@@ -389,8 +390,8 @@ def find_shortest_path(
def find_connected_nodes(
- graph: dict[TH, set[TH]], start: TH, visited: set[TH] | None = None
-) -> set[TH] | None:
+ graph: dict[TH, set[TH]], start: TH, visited: Optional[set[TH]] = None
+) -> Optional[set[TH]]:
"""Find all nodes connected to a start node within a graph.
Parameters
@@ -449,12 +450,12 @@ class UnitsContainer(Mapping[str, Scalar]):
__slots__ = ("_d", "_hash", "_one", "_non_int_type")
_d: udict
- _hash: int | None
+ _hash: Optional[int]
_one: Scalar
_non_int_type: type
def __init__(
- self, *args: Any, non_int_type: type | None = None, **kwargs: Any
+ self, *args: Any, non_int_type: Optional[type] = None, **kwargs: Any
) -> None:
if args and isinstance(args[0], UnitsContainer):
default_non_int_type = args[0]._non_int_type
@@ -1013,7 +1014,7 @@ class PrettyIPython:
def to_units_container(
- unit_like: QuantityOrUnitLike, registry: UnitRegistry | None = None
+ unit_like: QuantityOrUnitLike, registry: Optional[UnitRegistry] = None
) -> UnitsContainer:
"""Convert a unit compatible type to a UnitsContainer.
@@ -1048,7 +1049,7 @@ def to_units_container(
def infer_base_unit(
- unit_like: QuantityOrUnitLike, registry: UnitRegistry | None = None
+ unit_like: QuantityOrUnitLike, registry: Optional[UnitRegistry] = None
) -> UnitsContainer:
"""
Given a Quantity or UnitLike, give the UnitsContainer for it's plain units.