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
pycodegen
pystencils
Commits
d93c549c
Commit
d93c549c
authored
1 year ago
by
Frederik Hennig
Browse files
Options
Downloads
Patches
Plain Diff
Fix typing of floor/ceil
parent
e24cf411
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!406
Fix typing of floor/ceil
Pipeline
#67656
passed
1 year ago
Stage: pretest
Stage: test
Stage: docs
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/pystencils/typing/leaf_typing.py
+2
-1
2 additions, 1 deletion
src/pystencils/typing/leaf_typing.py
tests/test_math_functions.py
+3
-2
3 additions, 2 deletions
tests/test_math_functions.py
with
5 additions
and
3 deletions
src/pystencils/typing/leaf_typing.py
+
2
−
1
View file @
d93c549c
...
@@ -11,6 +11,7 @@ from sympy.core.relational import Relational
...
@@ -11,6 +11,7 @@ from sympy.core.relational import Relational
from
sympy.functions.elementary.piecewise
import
ExprCondPair
from
sympy.functions.elementary.piecewise
import
ExprCondPair
from
sympy.functions.elementary.trigonometric
import
TrigonometricFunction
,
InverseTrigonometricFunction
from
sympy.functions.elementary.trigonometric
import
TrigonometricFunction
,
InverseTrigonometricFunction
from
sympy.functions.elementary.hyperbolic
import
HyperbolicFunction
from
sympy.functions.elementary.hyperbolic
import
HyperbolicFunction
from
sympy.functions.elementary.integers
import
RoundFunction
from
sympy.logic.boolalg
import
BooleanFunction
from
sympy.logic.boolalg
import
BooleanFunction
from
sympy.logic.boolalg
import
BooleanAtom
from
sympy.logic.boolalg
import
BooleanAtom
...
@@ -213,7 +214,7 @@ class TypeAdder:
...
@@ -213,7 +214,7 @@ class TypeAdder:
new_args
.
append
(
a
)
new_args
.
append
(
a
)
return
expr
.
func
(
*
new_args
)
if
new_args
else
expr
,
collated_type
return
expr
.
func
(
*
new_args
)
if
new_args
else
expr
,
collated_type
elif
isinstance
(
expr
,
(
sp
.
Pow
,
sp
.
exp
,
InverseTrigonometricFunction
,
TrigonometricFunction
,
elif
isinstance
(
expr
,
(
sp
.
Pow
,
sp
.
exp
,
InverseTrigonometricFunction
,
TrigonometricFunction
,
HyperbolicFunction
,
sp
.
log
)):
HyperbolicFunction
,
sp
.
log
,
RoundFunction
)):
args_types
=
[
self
.
figure_out_type
(
arg
)
for
arg
in
expr
.
args
]
args_types
=
[
self
.
figure_out_type
(
arg
)
for
arg
in
expr
.
args
]
collated_type
=
collate_types
([
t
for
_
,
t
in
args_types
])
collated_type
=
collate_types
([
t
for
_
,
t
in
args_types
])
new_args
=
[
a
if
t
.
dtype_eq
(
collated_type
)
else
CastFunc
(
a
,
collated_type
)
for
a
,
t
in
args_types
]
new_args
=
[
a
if
t
.
dtype_eq
(
collated_type
)
else
CastFunc
(
a
,
collated_type
)
for
a
,
t
in
args_types
]
...
...
This diff is collapsed.
Click to expand it.
tests/test_math_functions.py
+
3
−
2
View file @
d93c549c
...
@@ -39,7 +39,7 @@ def test_two_arguments(dtype, func, target):
...
@@ -39,7 +39,7 @@ def test_two_arguments(dtype, func, target):
@pytest.mark.parametrize
(
'
dtype
'
,
[
"
float64
"
,
"
float32
"
])
@pytest.mark.parametrize
(
'
dtype
'
,
[
"
float64
"
,
"
float32
"
])
@pytest.mark.parametrize
(
'
func
'
,
[
sp
.
sin
,
sp
.
cos
,
sp
.
sinh
,
sp
.
cosh
,
sp
.
atan
])
@pytest.mark.parametrize
(
'
func
'
,
[
sp
.
sin
,
sp
.
cos
,
sp
.
sinh
,
sp
.
cosh
,
sp
.
atan
,
sp
.
floor
,
sp
.
ceiling
])
@pytest.mark.parametrize
(
'
target
'
,
[
ps
.
Target
.
CPU
,
ps
.
Target
.
GPU
])
@pytest.mark.parametrize
(
'
target
'
,
[
ps
.
Target
.
CPU
,
ps
.
Target
.
GPU
])
def
test_single_arguments
(
dtype
,
func
,
target
):
def
test_single_arguments
(
dtype
,
func
,
target
):
if
target
==
ps
.
Target
.
GPU
:
if
target
==
ps
.
Target
.
GPU
:
...
@@ -58,7 +58,8 @@ def test_single_arguments(dtype, func, target):
...
@@ -58,7 +58,8 @@ def test_single_arguments(dtype, func, target):
ast
=
ps
.
create_kernel
(
up
,
config
=
config
)
ast
=
ps
.
create_kernel
(
up
,
config
=
config
)
code
=
ps
.
get_code_str
(
ast
)
code
=
ps
.
get_code_str
(
ast
)
if
dtype
==
'
float32
'
:
if
dtype
==
'
float32
'
:
assert
func
.
__name__
.
lower
()
in
code
func_name
=
func
.
__name__
.
lower
()
if
func
is
not
sp
.
ceiling
else
"
ceil
"
assert
func_name
in
code
kernel
=
ast
.
compile
()
kernel
=
ast
.
compile
()
dh
.
all_to_gpu
()
dh
.
all_to_gpu
()
...
...
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