Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
pystencils
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jonas Plewinski
pystencils
Commits
eda2f772
Commit
eda2f772
authored
5 years ago
by
Stephan Seitz
Browse files
Options
Downloads
Patches
Plain Diff
Use default_int_type, default_float_type in collate_types
parent
0460532f
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pystencils/data_types.py
+12
-8
12 additions, 8 deletions
pystencils/data_types.py
with
12 additions
and
8 deletions
pystencils/data_types.py
+
12
−
8
View file @
eda2f772
...
...
@@ -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
try
:
import
llvmlite.ir
as
ir
...
...
@@ -432,7 +432,9 @@ def peel_off_type(dtype, type_to_peel_off):
def
collate_types
(
types
,
forbid_collation_to_complex
=
False
,
forbid_collation_to_float
=
False
):
forbid_collation_to_float
=
False
,
default_float_type
=
'
float64
'
,
default_int_type
=
'
int64
'
):
"""
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
(
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
,
default_float_type
=
default_float_type
,
default_int_type
=
default_int_type
)
else
:
if
expr
.
is_integer
:
return
create_type
(
default_int_type
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment