Skip to content

Commit

Permalink
fix import loop
Browse files Browse the repository at this point in the history
  • Loading branch information
cometbeetle committed Nov 10, 2024
1 parent 0b89037 commit 05b369a
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions auto_uncertainties/uncertainty/uncertainty_containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import locale
import math
import operator
from typing import Any, Generic, Literal, TypeVar
from typing import TYPE_CHECKING, Any, Generic, Literal, TypeVar
import warnings

import joblib
Expand All @@ -24,10 +24,9 @@
ignore_runtime_warnings,
)

try:
if TYPE_CHECKING:
from auto_uncertainties.pint import UncertaintyQuantity
except ImportError:
UncertaintyQuantity = None


ERROR_ON_DOWNCAST = False
COMPARE_RTOL = 1e-9
Expand Down Expand Up @@ -256,7 +255,7 @@ def from_string(cls, string: str) -> Uncertainty:
return cls(float(u1), float(u2))

@classmethod
def from_quantities(cls, value, err) -> UncertaintyQuantity | Uncertainty:
def from_quantities(cls, value, err) -> UncertaintyQuantity:
"""
Create an `Uncertainty` object from one or more `pint.Quantity` objects.
Expand Down Expand Up @@ -284,6 +283,8 @@ def from_quantities(cls, value, err) -> UncertaintyQuantity | Uncertainty:
value_, err_, units = _check_units(value, err)
inst = cls(value_, err_)

from auto_uncertainties.pint import UncertaintyQuantity

if units is not None:
if UncertaintyQuantity is None:
msg = "Failed to load Pint extensions (Pint is not currently installed). Run 'pip install pint' to install it."
Expand Down

0 comments on commit 05b369a

Please sign in to comment.