Skip to content

Commit

Permalink
Do not assume all numpy installations have all types
Browse files Browse the repository at this point in the history
`float128` is not available on some Windows platforms. Not sure if there are others.

Fixes #12.
  • Loading branch information
posita committed Jun 23, 2022
1 parent 97030cd commit bad0fe8
Showing 1 changed file with 37 additions and 28 deletions.
65 changes: 37 additions & 28 deletions numerary/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -1691,40 +1691,49 @@ def denominator(operand: SupportsNumeratorDenominatorMixedU):
)
logging.getLogger(__name__).debug(traceback.format_exc())
else:
t: Type

for t in (
numpy.uint8,
numpy.uint16,
numpy.uint32,
numpy.uint64,
numpy.int8,
numpy.int16,
numpy.int32,
numpy.int64,
t: Optional[Type]

for t_name in (
"uint8",
"uint16",
"uint32",
"uint64",
"int8",
"int16",
"int32",
"int64",
):
SupportsFloorCeil.includes(t)
t = getattr(numpy, t_name, None)

for t in (
numpy.float16,
numpy.float32,
numpy.float64,
numpy.float128,
if t is not None:
SupportsFloorCeil.includes(t)

for t_name in (
"float16",
"float32",
"float64",
"float128",
):
SupportsFloorCeil.includes(t)
SupportsIntegralOps.excludes(t)
SupportsIntegralPow.excludes(t)
t = getattr(numpy, t_name, None)

if t is not None:
SupportsFloorCeil.includes(t)
SupportsIntegralOps.excludes(t)
SupportsIntegralPow.excludes(t)

# numpy complex types define these methods, but only to raise exceptions
for t in (
numpy.csingle,
numpy.cdouble,
numpy.clongdouble,
for t_name in (
"csingle",
"cdouble",
"clongdouble",
):
SupportsDivmod.excludes(t)
SupportsRealOps.excludes(t)
SupportsIntegralOps.excludes(t)
SupportsIntegralPow.excludes(t)
t = getattr(numpy, t_name, None)

if t is not None:
SupportsDivmod.excludes(t)
SupportsRealOps.excludes(t)
SupportsIntegralOps.excludes(t)
SupportsIntegralPow.excludes(t)

try:
# Register known sympy exceptions
Expand Down

0 comments on commit bad0fe8

Please sign in to comment.