From afc933d922269283fb7baafaca8c09cad2446eb4 Mon Sep 17 00:00:00 2001
From: Martin Bauer <martin.bauer@fau.de>
Date: Fri, 13 Apr 2018 13:17:26 +0200
Subject: [PATCH] lbmpy geometry: documentation and tests

---
 __init__.py                  | 19 ++++++++++---------
 field.py                     | 13 ++++++-------
 sympy_gmpy_bug_workaround.py |  2 ++
 vtk.py                       |  4 ++--
 4 files changed, 20 insertions(+), 18 deletions(-)

diff --git a/__init__.py b/__init__.py
index 3b6abc9dd..05e5ab6ed 100644
--- a/__init__.py
+++ b/__init__.py
@@ -1,12 +1,13 @@
-import pystencils.sympy_gmpy_bug_workaround
-from pystencils.field import Field, FieldType
-from pystencils.data_types import TypedSymbol
-from pystencils.slicing import make_slice
-from pystencils.kernelcreation import create_kernel, create_indexed_kernel
-from pystencils.display_utils import show_code, to_dot
-from pystencils.assignment_collection import AssignmentCollection
-from pystencils.assignment import Assignment
-from pystencils.sympyextensions import SymbolCreator
+"""Module to generate stencil kernels in C or CUDA using sympy expressions and call them as Python functions"""
+from . import sympy_gmpy_bug_workaround
+from .field import Field, FieldType
+from .data_types import TypedSymbol
+from .slicing import make_slice
+from .kernelcreation import create_kernel, create_indexed_kernel
+from .display_utils import show_code, to_dot
+from .assignment_collection import AssignmentCollection
+from .assignment import Assignment
+from .sympyextensions import SymbolCreator
 
 __all__ = ['Field', 'FieldType',
            'TypedSymbol',
diff --git a/field.py b/field.py
index cc7a5f072..40a2accb0 100644
--- a/field.py
+++ b/field.py
@@ -153,7 +153,7 @@ class Field(object):
 
     @staticmethod
     def create_fixed_size(field_name: str, shape: Tuple[int, ...], index_dimensions: int = 0,
-                          dtype=np.float64, layout: str = 'numpy', strides: Optional[Sequence[int]]=None) -> 'Field':
+                          dtype=np.float64, layout: str = 'numpy', strides: Optional[Sequence[int]] = None) -> 'Field':
         """
         Creates a field with fixed sizes i.e. can be called only with arrays of the same size and layout
 
@@ -192,7 +192,7 @@ class Field(object):
 
     def __init__(self, field_name, field_type, dtype, layout, shape, strides):
         """Do not use directly. Use static create* methods"""
-        self._fieldName = field_name
+        self._field_name = field_name
         assert isinstance(field_type, FieldType)
         self.field_type = field_type
         self._dtype = create_type(dtype)
@@ -218,7 +218,7 @@ class Field(object):
 
     @property
     def name(self) -> str:
-        return self._fieldName
+        return self._field_name
 
     @property
     def spatial_shape(self) -> Tuple[int, ...]:
@@ -249,7 +249,7 @@ class Field(object):
         return self._dtype
 
     def __repr__(self):
-        return self._fieldName
+        return self._field_name
 
     def neighbor(self, coord_id, offset):
         offset_list = [0] * self.spatial_dimensions
@@ -294,7 +294,7 @@ class Field(object):
         return Field.Access(self, center)(*args, **kwargs)
 
     def __hash__(self):
-        return hash((self._layout, self.shape, self.strides, self._dtype, self.field_type, self._fieldName))
+        return hash((self._layout, self.shape, self.strides, self._dtype, self.field_type, self._field_name))
 
     def __eq__(self, other):
         self_tuple = (self.shape, self.strides, self.name, self.dtype, self.field_type)
@@ -576,8 +576,7 @@ def offset_component_to_direction_string(coordinate_id: int, value: int) -> str:
     """
     name_components = (('W', 'E'),  # west, east
                        ('S', 'N'),  # south, north
-                       ('B', 'T'),  # bottom, top
-                       )
+                       ('B', 'T'))  # bottom, top
     if value == 0:
         result = ""
     elif value < 0:
diff --git a/sympy_gmpy_bug_workaround.py b/sympy_gmpy_bug_workaround.py
index ce2bfa3c8..aaeaba06b 100644
--- a/sympy_gmpy_bug_workaround.py
+++ b/sympy_gmpy_bug_workaround.py
@@ -14,3 +14,5 @@ try:
                       "MPMATH_NOGMPY=1")
 except ImportError:
     pass
+
+__all__ = []
diff --git a/vtk.py b/vtk.py
index c823e15ae..dcdf2d2d0 100644
--- a/vtk.py
+++ b/vtk.py
@@ -27,8 +27,8 @@ def image_to_vtk(path, cell_data, origin=(0.0, 0.0, 0.0), spacing=(1.0, 1.0, 1.0
         >>> with TemporaryDirectory() as tmp_dir:
         ...     path = os.path.join(tmp_dir, 'out')
         ...     size = (20, 20, 20)
-        ...     res_file = image_to_vtk(path, cell_data={'scalar': np.zeros(size),
-        ...                                              'vector': (np.ones(size), np.ones(size), np.ones(size))
+        ...     res_file = image_to_vtk(path, cell_data={'vector': (np.ones(size), np.ones(size), np.ones(size)),
+        ...                                              'scalar': np.zeros(size)
         ...                                              })
     """
 
-- 
GitLab