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
1d4c3bf6
Commit
1d4c3bf6
authored
3 years ago
by
Frederik Hennig
Committed by
Markus Holzer
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Fixed test for sliced iteration with buffer to use dynamic field sizes
parent
5152e4e8
No related branches found
No related tags found
1 merge request
!292
Rebase of pystencils Type System
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pystencils_tests/test_buffer.py
+11
-7
11 additions, 7 deletions
pystencils_tests/test_buffer.py
with
11 additions
and
7 deletions
pystencils_tests/test_buffer.py
+
11
−
7
View file @
1d4c3bf6
...
...
@@ -20,7 +20,7 @@ def _generate_fields(dt=np.uint64, num_directions=1, layout='numpy'):
fields
=
[]
for
size
in
field_sizes
:
field_layout
=
layout_string_to_tuple
(
layout
,
len
(
size
))
src_arr
=
create_numpy_array_with_layout
(
size
,
field_layout
)
src_arr
=
create_numpy_array_with_layout
(
size
,
field_layout
,
dtype
=
dt
)
array_data
=
np
.
reshape
(
np
.
arange
(
1
,
int
(
np
.
prod
(
size
)
+
1
)),
size
)
# Use flat iterator to input data into the array
...
...
@@ -193,10 +193,14 @@ def test_field_layouts():
def
test_iteration_slices
():
num_cell_values
=
19
fields
=
_generate_fields
(
num_directions
=
num_cell_values
)
dt
=
np
.
uint64
fields
=
_generate_fields
(
dt
=
dt
,
num_directions
=
num_cell_values
)
for
(
src_arr
,
dst_arr
,
bufferArr
)
in
fields
:
src_field
=
Field
.
create_from_numpy_array
(
"
src_field
"
,
src_arr
,
index_dimensions
=
1
)
dst_field
=
Field
.
create_from_numpy_array
(
"
dst_field
"
,
dst_arr
,
index_dimensions
=
1
)
spatial_dimensions
=
len
(
src_arr
.
shape
)
-
1
# src_field = Field.create_from_numpy_array("src_field", src_arr, index_dimensions=1)
# dst_field = Field.create_from_numpy_array("dst_field", dst_arr, index_dimensions=1)
src_field
=
Field
.
create_generic
(
"
src_field
"
,
spatial_dimensions
,
index_shape
=
(
num_cell_values
,),
dtype
=
dt
)
dst_field
=
Field
.
create_generic
(
"
dst_field
"
,
spatial_dimensions
,
index_shape
=
(
num_cell_values
,),
dtype
=
dt
)
buffer
=
Field
.
create_generic
(
"
buffer
"
,
spatial_dimensions
=
1
,
index_dimensions
=
1
,
field_type
=
FieldType
.
BUFFER
,
dtype
=
src_arr
.
dtype
)
...
...
@@ -214,7 +218,7 @@ def test_iteration_slices():
# Fill the entire array with data
src_arr
[(
slice
(
None
,
None
,
1
),)
*
dim
]
=
np
.
arange
(
num_cell_values
)
dst_arr
.
fill
(
0
.0
)
dst_arr
.
fill
(
0
)
pack_code
=
create_kernel
(
pack_eqs
,
iteration_slice
=
pack_slice
,
data_type
=
{
'
src_field
'
:
src_arr
.
dtype
,
'
buffer
'
:
buffer
.
dtype
})
pack_kernel
=
pack_code
.
compile
()
...
...
@@ -232,6 +236,6 @@ def test_iteration_slices():
# Check if only every second entry of the leftmost slice has been copied
np
.
testing
.
assert_equal
(
dst_arr
[
pack_slice
],
src_arr
[
pack_slice
])
np
.
testing
.
assert_equal
(
dst_arr
[(
slice
(
1
,
None
,
2
),)
*
(
dim
-
1
)
+
(
0
,)],
0.
0
)
np
.
testing
.
assert_equal
(
dst_arr
[(
slice
(
None
,
None
,
1
),)
*
(
dim
-
1
)
+
(
slice
(
1
,
None
),)],
0.
0
)
np
.
testing
.
assert_equal
(
dst_arr
[(
slice
(
1
,
None
,
2
),)
*
(
dim
-
1
)
+
(
0
,)],
0
)
np
.
testing
.
assert_equal
(
dst_arr
[(
slice
(
None
,
None
,
1
),)
*
(
dim
-
1
)
+
(
slice
(
1
,
None
),)],
0
)
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