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
Markus Holzer
pystencils
Commits
2a95e87e
Commit
2a95e87e
authored
1 year ago
by
Markus Holzer
Browse files
Options
Downloads
Patches
Plain Diff
Implement test case
parent
6c462e3d
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_tests/test_printing.py
+52
-0
52 additions, 0 deletions
pystencils_tests/test_printing.py
with
52 additions
and
0 deletions
pystencils_tests/test_print
_infinity
.py
→
pystencils_tests/test_print
ing
.py
+
52
−
0
View file @
2a95e87e
import
pytest
import
sympy
as
sp
import
pystencils
from
sympy
import
oo
from
pystencils.backends.cbackend
import
CBackend
class
UnsupportedNode
(
pystencils
.
astnodes
.
Node
):
def
__init__
(
self
):
super
().
__init__
()
@pytest.mark.parametrize
(
'
type
'
,
(
'
float32
'
,
'
float64
'
,
'
int64
'
))
...
...
@@ -12,9 +19,9 @@ def test_print_infinity(type, negative, target):
x
=
pystencils
.
fields
(
f
'
x:
{
type
}
[1d]
'
)
if
negative
:
assignment
=
pystencils
.
Assignment
(
x
.
center
,
-
oo
)
assignment
=
pystencils
.
Assignment
(
x
.
center
,
-
sp
.
oo
)
else
:
assignment
=
pystencils
.
Assignment
(
x
.
center
,
oo
)
assignment
=
pystencils
.
Assignment
(
x
.
center
,
sp
.
oo
)
ast
=
pystencils
.
create_kernel
(
assignment
,
data_type
=
type
,
target
=
target
)
if
target
==
pystencils
.
Target
.
GPU
:
...
...
@@ -23,3 +30,23 @@ def test_print_infinity(type, negative, target):
ast
.
compile
()
print
(
ast
.
compile
().
code
)
def
test_print_unsupported_node
():
with
pytest
.
raises
(
NotImplementedError
,
match
=
'
CBackend does not support node of type UnsupportedNode
'
):
CBackend
()(
UnsupportedNode
())
def
test_print_subtraction
():
a
,
b
=
sp
.
symbols
(
"
a b
"
)
x
=
pystencils
.
fields
(
f
'
x: double[3d]
'
)
y
=
pystencils
.
fields
(
f
'
y: double[3d]
'
)
config
=
pystencils
.
CreateKernelConfig
(
target
=
pystencils
.
Target
.
CPU
)
update
=
pystencils
.
Assignment
(
x
.
center
,
y
.
center
-
b
)
ast
=
pystencils
.
create_kernel
(
update
,
config
=
config
)
code
=
pystencils
.
get_code_str
(
ast
)
assert
"
-1.0
"
not
in
code
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