Skip to content
Snippets Groups Projects

Add DataHandling.add_arrays

Merged Stephan Seitz requested to merge seitz/pystencils:Datahandling.add_arrays into master
2 files
+ 13
4
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -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['x'].shape = (22, 32)
>>> assert dh.fields['y'].index_shape = (9,)
>>> 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."""
Loading