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
Package registry
Model registry
Operate
Environments
Terraform modules
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
Sebastian Bindgen
pystencils
Commits
e5f4c74d
Commit
e5f4c74d
authored
5 years ago
by
Stephan Seitz
Browse files
Options
Downloads
Patches
Plain Diff
Make add_arrays return fields to arrays
parent
1b4ace3e
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
pystencils/datahandling/datahandling_interface.py
+11
-4
11 additions, 4 deletions
pystencils/datahandling/datahandling_interface.py
pystencils_tests/test_datahandling.py
+3
-1
3 additions, 1 deletion
pystencils_tests/test_datahandling.py
with
14 additions
and
5 deletions
pystencils/datahandling/datahandling_interface.py
+
11
−
4
View file @
e5f4c74d
...
@@ -68,20 +68,27 @@ class DataHandling(ABC):
...
@@ -68,20 +68,27 @@ class DataHandling(ABC):
>>>
from
pystencils.datahandling
import
create_data_handling
>>>
from
pystencils.datahandling
import
create_data_handling
>>>
dh
=
create_data_handling
((
20
,
30
))
>>>
dh
=
create_data_handling
((
20
,
30
))
>>>
dh
.
add_arrays
(
'
x, y(9)
'
)
>>>
x
,
y
=
dh
.
add_arrays
(
'
x, y(9)
'
)
>>>
print
(
dh
.
fields
)
>>>
print
(
dh
.
fields
)
{
'
x
'
:
x
:
double
[
20
,
30
],
'
y
'
:
y
(
9
):
double
[
20
,
30
]}
{
'
x
'
:
x
:
double
[
22
,
32
],
'
y
'
:
y
(
9
):
double
[
22
,
32
]}
>>>
assert
dh
.
fields
[
'
x
'
].
shape
=
(
20
,
30
)
>>>
assert
x
==
dh
.
fields
[
'
x
'
]
>>>
assert
dh
.
fields
[
'
y
'
].
index_shape
=
(
9
,)
>>>
assert
dh
.
fields
[
'
x
'
].
shape
==
(
22
,
32
)
>>>
assert
dh
.
fields
[
'
y
'
].
index_shape
==
(
9
,)
Args:
Args:
description (str): String description of the fields to add
description (str): String description of the fields to add
Returns:
Fields representing the just created arrays
"""
"""
from
pystencils.field
import
_parse_part1
from
pystencils.field
import
_parse_part1
names
=
[]
for
name
,
indices
in
_parse_part1
(
description
):
for
name
,
indices
in
_parse_part1
(
description
):
names
.
append
(
name
)
self
.
add_array
(
name
,
values_per_cell
=
indices
)
self
.
add_array
(
name
,
values_per_cell
=
indices
)
return
(
self
.
fields
[
n
]
for
n
in
names
)
@abstractmethod
@abstractmethod
def
has_data
(
self
,
name
):
def
has_data
(
self
,
name
):
"""
Returns true if a field or custom data element with this name was added.
"""
"""
Returns true if a field or custom data element with this name was added.
"""
...
...
This diff is collapsed.
Click to expand it.
pystencils_tests/test_datahandling.py
+
3
−
1
View file @
e5f4c74d
...
@@ -233,9 +233,11 @@ def test_add_arrays():
...
@@ -233,9 +233,11 @@ def test_add_arrays():
field_description
=
'
x, y(9)
'
field_description
=
'
x, y(9)
'
dh
=
create_data_handling
(
domain_size
=
domain_shape
,
default_ghost_layers
=
0
,
default_layout
=
'
numpy
'
)
dh
=
create_data_handling
(
domain_size
=
domain_shape
,
default_ghost_layers
=
0
,
default_layout
=
'
numpy
'
)
dh
.
add_arrays
(
field_description
)
x_
,
y_
=
dh
.
add_arrays
(
field_description
)
x
,
y
=
ps
.
fields
(
field_description
+
'
: [3,4,5]
'
)
x
,
y
=
ps
.
fields
(
field_description
+
'
: [3,4,5]
'
)
assert
x_
==
x
assert
y_
==
y
assert
x
==
dh
.
fields
[
'
x
'
]
assert
x
==
dh
.
fields
[
'
x
'
]
assert
y
==
dh
.
fields
[
'
y
'
]
assert
y
==
dh
.
fields
[
'
y
'
]
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