Commit 9ed5c20b authored by Martin Bauer's avatar Martin Bauer
Browse files

Removed dead code

parent bcc92b60
......@@ -309,27 +309,6 @@ class Type(sp.Basic):
def __new__(cls, *args, **kwargs):
return sp.Basic.__new__(cls)
def __lt__(self, other): # deprecated
# Needed for sorting the types inside an expression
if isinstance(self, BasicType):
if isinstance(other, BasicType):
return self.numpy_dtype > other.numpy_dtype # TODO const
elif isinstance(other, PointerType):
return False
else: # isinstance(other, StructType):
raise NotImplementedError("Struct type comparison is not yet implemented")
elif isinstance(self, PointerType):
if isinstance(other, BasicType):
return True
elif isinstance(other, PointerType):
return self.base_type > other.base_type # TODO const, restrict
else: # isinstance(other, StructType):
raise NotImplementedError("Struct type comparison is not yet implemented")
elif isinstance(self, StructType):
raise NotImplementedError("Struct type comparison is not yet implemented")
raise NotImplementedError
def _sympystr(self, *args, **kwargs):
return str(self)
......@@ -540,36 +519,3 @@ class StructType(object):
def __hash__(self):
return hash((self.numpy_dtype, self.const))
# TODO this should not work at all!!!
def __gt__(self, other):
if self.ptr and not other.ptr:
return True
if self.dtype > other.dtype:
return True
def get_type_from_sympy(node):
Creates a Type object from a Sympy object
:param node: Sympy object
:return: Type object
# Rational, NumberSymbol?
# Zero, One, NegativeOne )= Integer
# Half )= Rational
# NAN, Infinity, Negative Inifinity,
# Exp1, Imaginary Unit, Pi, EulerGamma, Catalan, Golden Ratio
# Pow, Mul, Add, Mod, Relational
if not isinstance(node, sp.Number):
raise TypeError(node, 'is not a sp.Number')
if isinstance(node, sp.Float) or isinstance(node, sp.RealNumber):
return create_type('double'), float(node)
elif isinstance(node, sp.Integer):
return create_type('int'), int(node)
elif isinstance(node, sp.Rational):
# TODO is it always float?
return create_type('double'), float(node.p / node.q)
raise TypeError(node, ' is not a supported type (yet)!')
......@@ -809,50 +809,3 @@ def get_loop_hierarchy(ast_node):
if node:
return reversed(result)
def get_type(node):
if isinstance(node, ast.Indexed):
return node.args[0].dtype
elif isinstance(node, ast.Node):
return node.dtype
# TODO sp.NumberSymbol
elif isinstance(node, sp.Number):
if isinstance(node, sp.Float):
return create_type('double')
elif isinstance(node, sp.Integer):
return create_type('int')
raise NotImplemented('Not yet supported: %s %s' % (node, type(node)))
raise NotImplemented('Not yet supported: %s %s' % (node, type(node)))
def desympy_ast(node):
Remove Sympy Expressions, which have more then one argument.
This is necessary for further changes in the tree.
:param node: ast which should be traversed. Only node's children will be modified.
:return: (modified) node
if node.args is None:
return node
for i in range(len(node.args)):
arg = node.args[i]
if isinstance(arg, sp.Add):
node.replace(arg, ast.Add(arg.args, node))
elif isinstance(arg, sp.Number):
node.replace(arg, ast.Number(arg, node))
elif isinstance(arg, sp.Mul):
node.replace(arg, ast.Mul(arg.args, node))
elif isinstance(arg, sp.Pow):
node.replace(arg, ast.Pow(arg.args, node))
elif isinstance(arg, sp.tensor.Indexed) or isinstance(arg, sp.tensor.indexed.Indexed):
node.replace(arg, ast.Indexed(arg.args, arg.base, node))
elif isinstance(arg, sp.tensor.IndexedBase):
node.replace(arg, arg.label)
for arg in node.args:
return node
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment