diff --git a/data_types.py b/data_types.py index 9999408d0acd647616f2d695b91ad74743e8185a..282bb87be12435be5c30e30f966b2c6008a9f4b7 100644 --- a/data_types.py +++ b/data_types.py @@ -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") - else: - 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) - else: - raise TypeError(node, ' is not a supported type (yet)!') diff --git a/transformations/transformations.py b/transformations/transformations.py index bc7a4a742934bd5aeaa2144c428efce0d146d98a..b0d406d78f6576ce6fc311f389b18c1f0a60e3df 100644 --- a/transformations/transformations.py +++ b/transformations/transformations.py @@ -809,50 +809,3 @@ def get_loop_hierarchy(ast_node): if node: result.append(node.coordinateToLoopOver) 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') - else: - raise NotImplemented('Not yet supported: %s %s' % (node, type(node))) - else: - 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) - else: - pass - for arg in node.args: - desympy_ast(arg) - return node