Skip to content

Instantly share code, notes, and snippets.

@eltjpm
Created July 19, 2013 18:24
Show Gist options
  • Save eltjpm/6041279 to your computer and use it in GitHub Desktop.
Save eltjpm/6041279 to your computer and use it in GitHub Desktop.
Index: numba/codegen/translate.py
===================================================================
--- numba/codegen/translate.py (revision 80237)
+++ numba/codegen/translate.py (revision 80238)
@@ -1039,6 +1039,15 @@
# ____________________________________________________________
# Compare
+ _cmp_op_map = {
+ ast.Gt : '>',
+ ast.Lt : '<',
+ ast.GtE : '>=',
+ ast.LtE : '<=',
+ ast.Eq : '==',
+ ast.NotEq : '!=',
+ }
+
def visit_Compare(self, node):
op = node.ops[0]
@@ -1048,17 +1057,8 @@
lhs_lvalue = self.visit(lhs)
rhs_lvalue = self.visit(rhs)
- op_map = {
- ast.Gt : '>',
- ast.Lt : '<',
- ast.GtE : '>=',
- ast.LtE : '<=',
- ast.Eq : '==',
- ast.NotEq : '!=',
- }
+ op = self._cmp_op_map[type(op)]
- op = op_map[type(op)]
-
if lhs.type.is_float and rhs.type.is_float:
lfunc = self.builder.fcmp
lop = _compare_mapping_float[op]
@@ -1072,8 +1072,8 @@
else:
# These errors should be issued by the type inferencer or a
# separate error checking pass
- raise error.NumbaError(node, "Comparisons of type %s not yet "
- "supported" % lhs.type)
+ raise error.NumbaError(node, "Comparisons of types %s and %s are not yet "
+ "supported" % (lhs.type, rhs.type))
return lfunc(lop, lhs_lvalue, rhs_lvalue)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment