diff --git a/src/primitives.py b/src/primitives.py index d8361b4efb107d979b73f9bc1e462cb5536ff42a..851c769e60dda2800a71d3d263ecd81f01df75d6 100644 --- a/src/primitives.py +++ b/src/primitives.py @@ -624,9 +624,18 @@ def quotient(numerator, denominator): # tool functions -------------------------------------------------------------- +global VALID_CONSTANT_CLASSES +global VALID_OPERANDS VALID_CONSTANT_CLASSES = (int, float, complex) VALID_OPERANDS = (Expression,) +try: + import numpy + VALID_CONSTANT_CLASSES += (numpy.number,) +except ImportError: + pass + + def is_constant(value): @@ -639,9 +648,13 @@ def is_valid_operand(value): def register_constant_class(class_): + global VALID_CONSTANT_CLASSES + VALID_CONSTANT_CLASSES += (class_,) def unregister_constant_class(class_): + global VALID_CONSTANT_CLASSES + tmp = list(VALID_CONSTANT_CLASSES) tmp.remove(class_) VALID_CONSTANT_CLASSES = tuple(tmp) @@ -660,6 +673,3 @@ def is_zero(value): - - -