Skip to content

Commit

Permalink
Merge branch 'master' into cumproduct
Browse files Browse the repository at this point in the history
  • Loading branch information
keewis committed Mar 13, 2024
2 parents 4cc3e93 + ba5fb65 commit 326d89a
Show file tree
Hide file tree
Showing 20 changed files with 921 additions and 544 deletions.
53 changes: 27 additions & 26 deletions pint/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,11 @@
from decimal import Decimal
from importlib import import_module
from numbers import Number
from typing import Any, NoReturn

try:
from uncertainties import UFloat, ufloat
from uncertainties import unumpy as unp

HAS_UNCERTAINTIES = True
except ImportError:
UFloat = ufloat = unp = None
HAS_UNCERTAINTIES = False


from typing import TypeAlias # noqa

from typing import (
Any,
NoReturn,
TypeAlias, # noqa
)

if sys.version_info >= (3, 11):
from typing import Self # noqa
Expand Down Expand Up @@ -78,6 +69,17 @@ class BehaviorChangeWarning(UserWarning):
pass


try:
from uncertainties import UFloat, ufloat
from uncertainties import unumpy as unp

HAS_UNCERTAINTIES = True
except ImportError:
UFloat = ufloat = unp = None

HAS_UNCERTAINTIES = False


try:
import numpy as np
from numpy import datetime64 as np_datetime64
Expand Down Expand Up @@ -172,6 +174,9 @@ def _to_magnitude(value, force_ndarray=False, force_ndarray_like=False):
except ImportError:
HAS_BABEL = False

babel_parse = missing_dependency("Babel") # noqa: F811 # type:ignore
babel_units = babel_parse

try:
import mip

Expand All @@ -186,6 +191,14 @@ def _to_magnitude(value, force_ndarray=False, force_ndarray_like=False):
except ImportError:
HAS_MIP = False

mip_missing = missing_dependency("mip")
mip_model = mip_missing
mip_Model = mip_missing
mip_INF = mip_missing
mip_INTEGER = mip_missing
mip_xsum = mip_missing
mip_OptimizationStatus = mip_missing

# Defines Logarithm and Exponential for Logarithmic Converter
if HAS_NUMPY:
from numpy import (
Expand All @@ -198,18 +211,6 @@ def _to_magnitude(value, force_ndarray=False, force_ndarray_like=False):
log, # noqa: F401
)

if not HAS_BABEL:
babel_parse = missing_dependency("Babel") # noqa: F811
babel_units = babel_parse

if not HAS_MIP:
mip_missing = missing_dependency("mip")
mip_model = mip_missing
mip_Model = mip_missing
mip_INF = mip_missing
mip_INTEGER = mip_missing
mip_xsum = mip_missing
mip_OptimizationStatus = mip_missing

# Define location of pint.Quantity in NEP-13 type cast hierarchy by defining upcast
# types using guarded imports
Expand Down
Loading

0 comments on commit 326d89a

Please sign in to comment.