Skip to content

Commit ff84ba7

Browse files
committed
Use a sentinel type instead of type(None) for type placeholders when SymPy/mpmath are not installed
1 parent f7d0058 commit ff84ba7

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

unpythonic/mathseq.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,17 @@
4040
from .it import take, rev
4141
from .gmemo import imemoize, gmemoize
4242

43+
class _NoSuchType:
44+
pass
45+
4346
# stuff to support float, mpf and SymPy expressions transparently
4447
#
4548
from sys import float_info
4649
from math import log as math_log, copysign, trunc, floor, ceil
4750
try:
4851
from mpmath import mpf, almosteq as mpf_almosteq
4952
except ImportError:
50-
mpf = type(None)
53+
mpf = type(_NoSuchType())
5154
mpf_almosteq = None
5255

5356
def _numsign(x):
@@ -69,7 +72,7 @@ def sign(x):
6972
except ImportError:
7073
log = math_log
7174
sign = _numsign
72-
_symExpr = type(None)
75+
_symExpr = type(_NoSuchType())
7376

7477
def almosteq(a, b, tol=1e-8):
7578
"""Almost-equality that supports several formats.

0 commit comments

Comments
 (0)