Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Tom Harke
pystencils
Commits
e398b411
Commit
e398b411
authored
Oct 29, 2019
by
Stephan Seitz
Browse files
Add Field.itemsize (yields Field.dtype.numpy_dtype.itemsize)
parent
f056dbd2
Changes
2
Hide whitespace changes
Inline
Side-by-side
pystencils/field.py
View file @
e398b411
...
...
@@ -357,6 +357,10 @@ class Field(AbstractField):
def
dtype
(
self
):
return
self
.
_dtype
@
property
def
itemsize
(
self
):
return
self
.
dtype
.
numpy_dtype
.
itemsize
def
__repr__
(
self
):
return
self
.
_field_name
...
...
pystencils_tests/test_field.py
View file @
e398b411
...
...
@@ -3,8 +3,7 @@ import pytest
import
sympy
as
sp
import
pystencils
as
ps
from
pystencils.field
import
Field
,
FieldType
from
pystencils.field
import
layout_string_to_tuple
from
pystencils.field
import
Field
,
FieldType
,
layout_string_to_tuple
def
test_field_basic
():
...
...
@@ -117,3 +116,14 @@ def test_string_creation():
assert
x
.
index_shape
==
(
4
,)
assert
y
.
index_shape
==
(
3
,
5
)
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
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment