Skip to content

Commit

Permalink
Allow long type in addition to int and float for built-in math predic…
Browse files Browse the repository at this point in the history
…ates
  • Loading branch information
William Waites committed Aug 1, 2015
1 parent aeaf433 commit 29b6d7b
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions lib/Rete/BuiltinPredicates.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,15 @@ def MathEqualTo(subject, object_):
if not isinstance(term, Variable):
assert isinstance(term, Literal), \
"math:equalTo can only be used with Literals (%s)" % term
assert isinstance(term.toPython(), (int, float)), \
assert isinstance(term.toPython(), (int, long, float)), \
"math:equalTo can only be used " + \
"with Numeric Literals (%s)" % term

def func(s, o):
for term in [s, o]:
assert isinstance(term, Literal), \
"math:equalTo can only be used with Literals (%s)" % term
assert isinstance(term.toPython(), (int, float)), \
assert isinstance(term.toPython(), (int, long, float)), \
"math:equalTo can only be used with " + \
"Numeric Literals (%s)" % term
return s.toPython() == o.toPython()
Expand All @@ -114,15 +114,15 @@ def MathGreaterThan(subject, object_):
if not isinstance(term, Variable):
assert isinstance(term, Literal), \
"math:lessThan can only be used with Literals (%s)" % term
assert isinstance(term.toPython(), (int, float)), \
assert isinstance(term.toPython(), (int, long, float)), \
"math:lessThan can only be used with " + \
"Numeric Literals (%s)" % term

def greaterThanF(s, o):
for term in [s, o]:
assert isinstance(term, Literal), \
"math:greaterThan can only be used with Literals (%s)" % term
assert isinstance(term.toPython(), (int, float)), \
assert isinstance(term.toPython(), (int, long, float)), \
"math:greaterThan can only be used " + \
"with Numeric Literals (%s)" % term
return s.toPython() > o.toPython()
Expand All @@ -134,15 +134,15 @@ def MathLessThan(subject, object_):
if not isinstance(term, Variable):
assert isinstance(term, Literal), \
"math:lessThan can only be used with Literals (%s)" % term
assert isinstance(term.toPython(), (int, float)), \
assert isinstance(term.toPython(), (int, long, float)), \
"math:lessThan can only be used with " + \
"Numeric Literals. (%s)" % term

def lessThanF(s, o):
for term in [s, o]:
assert isinstance(term, Literal), \
"math:lessThan can only be used with Literals (%s)" % term
assert isinstance(term.toPython(), (int, float)), \
assert isinstance(term.toPython(), (int, long, float)), \
"math:lessThan can only be used with " + \
"Numeric Literals (%s)" % term
return s.toPython() < o.toPython()
Expand All @@ -154,15 +154,15 @@ def MathNotLessThan(subject, object_):
if not isinstance(term, Variable):
assert isinstance(term, Literal), \
"math:notLessThan can only be used with Literals (%s)" % term
assert isinstance(term.toPython(), (int, float)), \
assert isinstance(term.toPython(), (int, long, float)), \
"math:lessThan can only be used with " + \
"Numeric Literals (%s)" % term

def nLessThanF(s, o):
for term in [s, o]:
assert isinstance(term, Literal), \
"math:notLessThan can only be used with Literals"
assert isinstance(term.toPython(), (int, float)), \
assert isinstance(term.toPython(), (int, long, float)), \
"math:lessThan can only be used with " + \
"Numeric Literals (%s)" % term
return not(s.toPython() < o.toPython())
Expand Down

0 comments on commit 29b6d7b

Please sign in to comment.