Dear CS10-Gitlab-users, on Thursday, Feb 3 there will be maintenance. That will lead to a downtime of the CS10-Gitlab-service including Subversion and Mattermost chat from 09:30. This might take the whole day since we don't know how long it is going to take. We are sorry for the inconvenience! Best regards, CS10-Admin-Team

Commit eda2f772 authored by Stephan Seitz's avatar Stephan Seitz
Browse files

Use default_int_type, default_float_type in collate_types

parent 0460532f
......@@ -4,14 +4,14 @@ from functools import partial
from typing import Tuple
import numpy as np
import sympy as sp
import sympy.codegen.ast
from sympy.core.cache import cacheit
from sympy.logic.boolalg import Boolean
import pystencils
import sympy as sp
import sympy.codegen.ast
from pystencils.cache import memorycache, memorycache_if_hashable
from pystencils.utils import all_equal
from sympy.core.cache import cacheit
from sympy.logic.boolalg import Boolean
import as ir
......@@ -432,7 +432,9 @@ def peel_off_type(dtype, type_to_peel_off):
def collate_types(types,
Takes a sequence of types and returns their "common type" e.g. (float, double, float) -> double
Uses the collation rules from numpy.
......@@ -443,14 +445,14 @@ def collate_types(types,
if not np.issubdtype(t.numpy_dtype, np.complexfloating)
if not types:
return create_type(np.float64)
return create_type(default_float_type)
if forbid_collation_to_float:
types = [
t for t in types if not np.issubdtype(t.numpy_dtype, np.floating)
if not types:
return create_type(np.int32)
return create_type(default_int_type)
# Pointer arithmetic case i.e. pointer + integer is allowed
if any(type(t) is PointerType for t in types):
......@@ -549,7 +551,9 @@ def get_type_of_expression(expr,
return collate_types(
forbid_collation_to_complex=expr.is_real is True,
forbid_collation_to_float=expr.is_integer is True)
forbid_collation_to_float=expr.is_integer is True,
if expr.is_integer:
return create_type(default_int_type)
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