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
e398b411
Commit
e398b411
authored
5 years ago
by
Stephan Seitz
Browse files
Options
Downloads
Patches
Plain Diff
Add Field.itemsize (yields Field.dtype.numpy_dtype.itemsize)
parent
f056dbd2
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!82
Add Field.itemsize (yields Field.dtype.numpy_dtype.itemsize)
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
pystencils/field.py
+4
-0
4 additions, 0 deletions
pystencils/field.py
pystencils_tests/test_field.py
+12
-2
12 additions, 2 deletions
pystencils_tests/test_field.py
with
16 additions
and
2 deletions
pystencils/field.py
+
4
−
0
View file @
e398b411
...
@@ -357,6 +357,10 @@ class Field(AbstractField):
...
@@ -357,6 +357,10 @@ class Field(AbstractField):
def
dtype
(
self
):
def
dtype
(
self
):
return
self
.
_dtype
return
self
.
_dtype
@property
def
itemsize
(
self
):
return
self
.
dtype
.
numpy_dtype
.
itemsize
def
__repr__
(
self
):
def
__repr__
(
self
):
return
self
.
_field_name
return
self
.
_field_name
...
...
This diff is collapsed.
Click to expand it.
pystencils_tests/test_field.py
+
12
−
2
View file @
e398b411
...
@@ -3,8 +3,7 @@ import pytest
...
@@ -3,8 +3,7 @@ import pytest
import
sympy
as
sp
import
sympy
as
sp
import
pystencils
as
ps
import
pystencils
as
ps
from
pystencils.field
import
Field
,
FieldType
from
pystencils.field
import
Field
,
FieldType
,
layout_string_to_tuple
from
pystencils.field
import
layout_string_to_tuple
def
test_field_basic
():
def
test_field_basic
():
...
@@ -117,3 +116,14 @@ def test_string_creation():
...
@@ -117,3 +116,14 @@ def test_string_creation():
assert
x
.
index_shape
==
(
4
,)
assert
x
.
index_shape
==
(
4
,)
assert
y
.
index_shape
==
(
3
,
5
)
assert
y
.
index_shape
==
(
3
,
5
)
assert
z
.
spatial_shape
==
(
3
,
47
)
assert
z
.
spatial_shape
==
(
3
,
47
)
def
test_itemsize
():
x
=
ps
.
fields
(
'
x: float32[1d]
'
)
y
=
ps
.
fields
(
'
y: float64[2d]
'
)
i
=
ps
.
fields
(
'
i: int16[1d]
'
)
assert
x
.
itemsize
==
4
assert
y
.
itemsize
==
8
assert
i
.
itemsize
==
2
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