Due to a key rollover of our WebSSO provider there might be a short downtime of this Gitlab server on Friday 2.

Commit e398b411 authored by Stephan Seitz's avatar Stephan Seitz

Add Field.itemsize (yields Field.dtype.numpy_dtype.itemsize)

parent f056dbd2
......@@ -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
......
......@@ -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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment