Commit 687fae33 authored by Daniel Boeckenhoff's avatar Daniel Boeckenhoff
Browse files

renamed coordSys to coord_sys

parent df704e78
......@@ -51,7 +51,7 @@ class Base_Test(object):
merge_list[1].transform(tfields.bases.CYLINDER)
merge_list[2].transform(tfields.bases.SPHERICAL)
obj = type(self._inst).merged(*merge_list)
self.assertTrue(obj.coordSys == tfields.bases.CARTESIAN)
self.assertTrue(obj.coord_sys == tfields.bases.CARTESIAN)
for i in range(len(merge_list)):
value = np.allclose(merge_list[0],
obj[i * len(self._inst): (i + 1) *
......@@ -59,7 +59,7 @@ class Base_Test(object):
atol=ATOL)
self.assertTrue(value)
obj_cs = type(self._inst).merged(*merge_list, coordSys=tfields.bases.CYLINDER)
obj_cs = type(self._inst).merged(*merge_list, coord_sys=tfields.bases.CYLINDER)
for i in range(len(merge_list)):
value = np.allclose(merge_list[1],
obj_cs[i * len(self._inst): (i + 1) *
......@@ -99,7 +99,7 @@ class TensorFields_Empty_Test(Tensors_Empty_Test):
class TensorFields_Copy_Test(TensorFields_Empty_Test):
def setUp(self):
base = [(-5, 5, 11)] * 3
self._fields = [tfields.Tensors.grid(*base, coordSys='cylinder'),
self._fields = [tfields.Tensors.grid(*base, coord_sys='cylinder'),
tfields.Tensors(range(11**3))]
tensors = tfields.Tensors.grid(*base)
self._inst = tfields.TensorFields(tensors, *self._fields)
......@@ -116,7 +116,7 @@ class TensorMaps_Copy_Test(TensorMaps_Empty_Test):
def setUp(self):
base = [(-1, 1, 3)] * 3
tensors = tfields.Tensors.grid(*base)
self._fields = [tfields.Tensors.grid(*base, coordSys='cylinder'),
self._fields = [tfields.Tensors.grid(*base, coord_sys='cylinder'),
tfields.Tensors(range(len(tensors)))]
self._maps_tensors = [[[0, 0, 0],
[1, 2, 3],
......
__version__ = '0.1.0.dev3'
__version__ = '0.1.0.dev4'
__author__ = "Daniel Boeckenhoff"
__email__ = "daniel.boeckenhoff@ipp.mpg.de"
......
......@@ -27,7 +27,7 @@ def get_coord_system(base):
if not isinstance(base, sympy.diffgeom.CoordSystem):
bse_tpe = type(base)
expctd_tpe = type(sympy.diffgeom.CoordSystem)
raise TypeError("Wrong type of coordSystem base {bse_tpe}. "
raise TypeError("Wrong type of coord_system base {bse_tpe}. "
"Expected {expctd_tpe}"
.format(**locals()))
return base
......
......@@ -124,7 +124,7 @@ class AbstractNdarray(np.ndarray):
>>> from tfields import Tensors, TensorFields
>>> scalars = Tensors([0, 1, 2])
>>> vectors = Tensors([[0, 0, 0], [0, 0, 1], [0, -1, 0]])
>>> scalarField = TensorFields(vectors, scalars, coordSys='cylinder')
>>> scalarField = TensorFields(vectors, scalars, coord_sys='cylinder')
Save it and restore it
>>> outFile = NamedTemporaryFile(suffix='.pickle')
......@@ -134,7 +134,7 @@ class AbstractNdarray(np.ndarray):
>>> _ = outFile.seek(0)
>>> sf = pickle.load(outFile)
>>> sf.coordSys == 'cylinder'
>>> sf.coord_sys == 'cylinder'
True
>>> sf.fields[0][2] == 2.
True
......@@ -269,7 +269,7 @@ class AbstractNdarray(np.ndarray):
else:
kwargs[attr] = getattr(self, attr)
np.savez(path, self, **kwargs)
np.savez(path, self, **kwargs)
@classmethod
def _load_npz(cls, path, **load_kwargs):
......@@ -305,7 +305,7 @@ class Tensors(AbstractNdarray):
True
>>> vectors.dim == 3
True
>>> assert vectors.coordSys == 'cartesian'
>>> assert vectors.coord_sys == 'cartesian'
Initialize the Levi-Zivita Tensor
>>> matrices = tfields.Tensors([[[0, 0, 0], [0, 0, 1], [0, -1, 0]],
......@@ -319,10 +319,10 @@ class Tensors(AbstractNdarray):
True
Initializing in different start coordinate system
>>> cyl = tfields.Tensors([[5, np.arctan(4. / 3.), 42]], coordSys='cylinder')
>>> assert cyl.coordSys == 'cylinder'
>>> cyl = tfields.Tensors([[5, np.arctan(4. / 3.), 42]], coord_sys='cylinder')
>>> assert cyl.coord_sys == 'cylinder'
>>> cyl.transform('cartesian')
>>> assert cyl.coordSys == 'cartesian'
>>> assert cyl.coord_sys == 'cartesian'
>>> cart = cyl
>>> assert round(cart[0, 0], 10) == 3.
>>> assert round(cart[0, 1], 10) == 4.
......@@ -331,8 +331,8 @@ class Tensors(AbstractNdarray):
Initialize with copy constructor keeps the coordinate system
>>> with vectors.tmp_transform('cylinder'):
... vect_cyl = tfields.Tensors(vectors)
... assert vect_cyl.coordSys == vectors.coordSys
>>> assert vect_cyl.coordSys == 'cylinder'
... assert vect_cyl.coord_sys == vectors.coord_sys
>>> assert vect_cyl.coord_sys == 'cylinder'
You can demand a special dimension.
>>> _ = tfields.Tensors([[1, 2, 3]], dim=3)
......@@ -351,7 +351,7 @@ class Tensors(AbstractNdarray):
Tensors([], shape=(0, 7), dtype=float64)
"""
__slots__ = ['coordSys']
__slots__ = ['coord_sys']
__slot_defaults__ = ['cartesian']
__slot_setters__ = [tfields.bases.get_coord_system_name]
......@@ -364,10 +364,10 @@ class Tensors(AbstractNdarray):
if issubclass(type(tensors), Tensors):
if dim is not None:
dim = tensors.dim
coordSys = kwargs.pop('coordSys', tensors.coordSys)
coord_sys = kwargs.pop('coord_sys', tensors.coord_sys)
tensors = tensors.copy()
tensors.transform(coordSys)
kwargs['coordSys'] = coordSys
tensors.transform(coord_sys)
kwargs['coord_sys'] = coord_sys
if dtype is None:
dtype = tensors.dtype
else:
......@@ -436,10 +436,10 @@ class Tensors(AbstractNdarray):
Use of most frequent coordinate system
>>> vec_a = tfields.Tensors([[0, 0, 0], [0, 0, 1], [0, -1, 0]])
>>> vec_b = tfields.Tensors([[5, 4, 1]], coordSys=tfields.bases.cylinder)
>>> vec_c = tfields.Tensors([[4, 2, 3]], coordSys=tfields.bases.cylinder)
>>> vec_b = tfields.Tensors([[5, 4, 1]], coord_sys=tfields.bases.cylinder)
>>> vec_c = tfields.Tensors([[4, 2, 3]], coord_sys=tfields.bases.cylinder)
>>> merge = tfields.Tensors.merged(vec_a, vec_b, vec_c, [[2, 0, 1]])
>>> assert merge.coordSys == 'cylinder'
>>> assert merge.coord_sys == 'cylinder'
>>> assert merge.equal([[0, 0, 0],
... [0, 0, 1],
... [1, -np.pi / 2, 0],
......@@ -450,42 +450,42 @@ class Tensors(AbstractNdarray):
Merge also shifts the maps to still refer to the same tensors
>>> tm_a = tfields.TensorMaps(merge, maps=[[[0, 1, 2]]])
>>> tm_b = tm_a.copy()
>>> assert tm_a.coordSys == 'cylinder'
>>> assert tm_a.coord_sys == 'cylinder'
>>> tm_merge = tfields.TensorMaps.merged(tm_a, tm_b)
>>> assert tm_merge.coordSys == 'cylinder'
>>> assert tm_merge.coord_sys == 'cylinder'
>>> assert tm_merge.maps[0].equal([[0, 1, 2],
... list(range(len(merge),
... len(merge) + 3,
... 1))])
>>> obj_list = [tfields.Tensors([[1, 2, 3]], coordSys=tfields.bases.CYLINDER),
>>> obj_list = [tfields.Tensors([[1, 2, 3]], coord_sys=tfields.bases.CYLINDER),
... tfields.Tensors([[3] * 3]),
... tfields.Tensors([[5, 1, 3]])]
>>> merge2 = tfields.Tensors.merged(*obj_list, coordSys=tfields.bases.CARTESIAN)
>>> merge2 = tfields.Tensors.merged(*obj_list, coord_sys=tfields.bases.CARTESIAN)
>>> assert merge2.equal([[-0.41614684, 0.90929743, 3.],
... [3, 3, 3], [5, 1, 3]], atol=1e-8)
"""
''' get most frequent coordSys or predefined coordSys '''
coordSys = kwargs.get('coordSys', None)
''' get most frequent coord_sys or predefined coord_sys '''
coord_sys = kwargs.get('coord_sys', None)
dimension = kwargs.get('dim', None)
if coordSys is None:
if coord_sys is None:
bases = []
for t in objects:
try:
bases.append(t.coordSys)
bases.append(t.coord_sys)
except AttributeError:
pass
if bases:
# get most frequent coordSys
coordSys = sorted(bases, key=Counter(bases).get, reverse=True)[0]
kwargs['coordSys'] = coordSys
# get most frequent coord_sys
coord_sys = sorted(bases, key=Counter(bases).get, reverse=True)[0]
kwargs['coord_sys'] = coord_sys
else:
default = cls.__slot_defaults__[cls.__slots__.index('coordSys')]
kwargs['coordSys'] = default
default = cls.__slot_defaults__[cls.__slots__.index('coord_sys')]
kwargs['coord_sys'] = default
''' transform all raw inputs to cls type with correct coordSys. Also
''' transform all raw inputs to cls type with correct coord_sys. Also
automatically make a copy of those instances that are of the correct
type already.'''
objects = [cls.__new__(cls, t, **kwargs) for t in objects]
......@@ -584,10 +584,10 @@ class Tensors(AbstractNdarray):
"""
return dim(self)
def transform(self, coordSys):
def transform(self, coord_sys):
"""
Args:
coordSys (str)
coord_sys (str)
Examples:
>>> import numpy as np
......@@ -618,7 +618,7 @@ class Tensors(AbstractNdarray):
>>> tCart = tfields.Tensors([[3, 4, 42], [1, 0, 0], [0, 1, -1], [-1, 0, 1], [0, 0, 0]])
>>> t_cyl = tCart.copy()
>>> t_cyl.transform('cylinder')
>>> assert t_cyl.coordSys == 'cylinder'
>>> assert t_cyl.coord_sys == 'cylinder'
R
>>> assert t_cyl[0, 0] == 5
......@@ -637,40 +637,40 @@ class Tensors(AbstractNdarray):
>>> assert t_cyl[2, 2] == -1
>>> t_cyl.transform('cartesian')
>>> assert t_cyl.coordSys == 'cartesian'
>>> assert t_cyl.coord_sys == 'cartesian'
>>> assert t_cyl[0, 0] == 3
"""
# scalars empty already there
if self.rank == 0 or self.shape[0] == 0 or self.coordSys == coordSys:
self.coordSys = coordSys
if self.rank == 0 or self.shape[0] == 0 or self.coord_sys == coord_sys:
self.coord_sys = coord_sys
return
tfields.bases.transform(self, self.coordSys, coordSys)
# self[:] = tfields.bases.transform(self, self.coordSys, coordSys)
self.coordSys = coordSys
tfields.bases.transform(self, self.coord_sys, coord_sys)
# self[:] = tfields.bases.transform(self, self.coord_sys, coord_sys)
self.coord_sys = coord_sys
@contextmanager
def tmp_transform(self, coordSys):
def tmp_transform(self, coord_sys):
"""
Temporarily change the coordSys to another coordSys and change it back at exit
Temporarily change the coord_sys to another coord_sys and change it back at exit
This method is for cleaner code only.
No speed improvements go with this.
Args:
see transform
Examples:
>>> import tfields
>>> p = tfields.Tensors([[1,2,3]], coordSys=tfields.bases.SPHERICAL)
>>> p = tfields.Tensors([[1,2,3]], coord_sys=tfields.bases.SPHERICAL)
>>> with p.tmp_transform(tfields.bases.CYLINDER):
... assert p.coordSys == tfields.bases.CYLINDER
>>> assert p.coordSys == tfields.bases.SPHERICAL
... assert p.coord_sys == tfields.bases.CYLINDER
>>> assert p.coord_sys == tfields.bases.SPHERICAL
"""
baseBefore = self.coordSys
if baseBefore == coordSys:
baseBefore = self.coord_sys
if baseBefore == coord_sys:
yield
else:
self.transform(coordSys)
self.transform(coord_sys)
yield
......@@ -716,7 +716,7 @@ class Tensors(AbstractNdarray):
def to_segment(self, segment, num_segments, coordinate,
periodicity=2 * np.pi, offset=0.,
coordSys=None):
coord_sys=None):
"""
For circular (close into themself after
<periodicity>) coordinates at index <coordinate> assume
......@@ -728,14 +728,14 @@ class Tensors(AbstractNdarray):
coordinate (int): coordinate index
periodicity (float): after what lenght, the coordiante repeats
offset (float): offset in the mapping
coordSys (str or sympy.CoordinateSystem): in which coord sys the
coord_sys (str or sympy.CoordinateSystem): in which coord sys the
transformation should be done
Examples:
>>> import tfields
>>> import numpy as np
>>> pStart = tfields.Points3D([[6, 2 * np.pi, 1],
... [6, 2 * np.pi / 5 * 3, 1]],
... coordSys='cylinder')
... coord_sys='cylinder')
>>> p = tfields.Points3D(pStart)
>>> p.to_segment(0, 5, 1, offset=-2 * np.pi / 10)
>>> assert np.array_equal(p[:, 1], [0, 0])
......@@ -748,9 +748,9 @@ class Tensors(AbstractNdarray):
if segment > num_segments - 1:
raise ValueError("Segment {0} not existent.".format(segment))
if coordSys is None:
coordSys = self.coordSys
with self.tmp_transform(coordSys):
if coord_sys is None:
coord_sys = self.coord_sys
with self.tmp_transform(coord_sys):
# map all values to first segment
self[:, coordinate] = \
(self[:, coordinate] - offset) % (periodicity / num_segments) + \
......@@ -768,9 +768,9 @@ class Tensors(AbstractNdarray):
equal_nan (bool)
see numpy.isclose
"""
if issubclass(type(other), Tensors) and self.coordSys != other.coordSys:
if issubclass(type(other), Tensors) and self.coord_sys != other.coord_sys:
other = other.copy()
other.transform(self.coordSys)
other.transform(self.coord_sys)
x, y = np.asarray(self), np.asarray(other)
if rtol is None and atol is None:
mask = (x == y)
......@@ -854,7 +854,7 @@ class Tensors(AbstractNdarray):
array([2, 3, 4])
"""
with other.tmp_transform(self.coordSys):
with other.tmp_transform(self.coord_sys):
# balanced_tree option gives huge speedup!
kd_tree = sp.spatial.cKDTree(other, 1000,
balanced_tree=False)
......@@ -863,11 +863,11 @@ class Tensors(AbstractNdarray):
return array
def evalf(self, expression=None, coordSys=None):
def evalf(self, expression=None, coord_sys=None):
"""
Args:
expression (sympy logical expression)
coordSys (str): coordSys to evalfuate the expression in.
coord_sys (str): coord_sys to evalfuate the expression in.
Returns:
np.ndarray: mask of dtype bool with lenght of number of points in self.
This array is True, where expression evalfuates True.
......@@ -897,17 +897,17 @@ class Tensors(AbstractNdarray):
"""
coords = sympy.symbols('x y z')
with self.tmp_transform(coordSys or self.coordSys):
with self.tmp_transform(coord_sys or self.coord_sys):
mask = tfields.evalf(self, expression, coords=coords)
return mask
def cut(self, expression, coordSys=None):
def cut(self, expression, coord_sys=None):
"""
Default cut method for Points3D. Works on a copy.
Args:
expression (sympy logical expression): logical expression which will be evalfuated.
use symbols x, y and z
coordSys (str): coordSys to evalfuate the expression in.
coord_sys (str): coord_sys to evalfuate the expression in.
Examples:
>>> import tfields
>>> import sympy
......@@ -930,7 +930,7 @@ class Tensors(AbstractNdarray):
"""
if len(self) == 0:
return self.copy()
mask = self.evalf(expression, coordSys=coordSys or self.coordSys)
mask = self.evalf(expression, coord_sys=coord_sys or self.coord_sys)
mask.astype(bool)
inst = self[mask].copy()
return inst
......@@ -955,9 +955,9 @@ class Tensors(AbstractNdarray):
True
"""
if issubclass(type(other), Tensors) and self.coordSys != other.coordSys:
if issubclass(type(other), Tensors) and self.coord_sys != other.coord_sys:
other = other.copy()
other.transform(self.coordSys)
other.transform(self.coord_sys)
return sp.spatial.distance.cdist(self, other, **kwargs)
def min_dists(self, other=None, **kwargs):
......@@ -1139,10 +1139,10 @@ class TensorFields(Tensors):
>>> cp = TensorFields(vectorField)
>>> assert vectorField.equal(cp)
Copying takes care of coordSys
Copying takes care of coord_sys
>>> cp.transform(tfields.bases.CYLINDER)
>>> cp_cyl = TensorFields(cp)
>>> assert cp_cyl.coordSys == tfields.bases.CYLINDER
>>> assert cp_cyl.coord_sys == tfields.bases.CYLINDER
Copying with changing type
>>> tcp = TensorFields(vectorField, dtype=int)
......@@ -1162,7 +1162,7 @@ class TensorFields(Tensors):
>>> assert len(loose) != 1
"""
__slots__ = ['coordSys', 'fields']
__slots__ = ['coord_sys', 'fields']
def __new__(cls, tensors, *fields, **kwargs):
rigid = kwargs.pop('rigid', True)
......@@ -1280,10 +1280,10 @@ class TensorFields(Tensors):
inst = cls.__new__(cls, inst, *fields)
return inst
def transform(self, coordSys):
super(TensorFields, self).transform(coordSys)
def transform(self, coord_sys):
super(TensorFields, self).transform(coord_sys)
for field in self.fields:
field.transform(coordSys)
field.transform(coord_sys)
def equal(self, other, **kwargs):
"""
......@@ -1296,7 +1296,7 @@ class TensorFields(Tensors):
if not issubclass(type(other), Tensors):
return super(TensorFields, self).equal(other, **kwargs)
else:
with other.tmp_transform(self.coordSys):
with other.tmp_transform(self.coord_sys):
mask = super(TensorFields, self).equal(other, **kwargs)
if issubclass(type(other), TensorFields):
if len(self.fields) != len(other.fields):
......@@ -1325,7 +1325,7 @@ class TensorMaps(TensorFields):
tensors: see Tensors class
*fields (Tensors): see TensorFields class
**kwargs:
coordSys ('str'): see Tensors class
coord_sys ('str'): see Tensors class
maps (array-like): indices indicating a connection between the
tensors at the respective index positions
Examples:
......@@ -1346,10 +1346,10 @@ class TensorMaps(TensorFields):
Copy constructor
>>> mesh_copy = tfields.TensorMaps(mesh)
Copying takes care of coordSys
Copying takes care of coord_sys
>>> mesh_copy.transform(tfields.bases.CYLINDER)
>>> mesh_cp_cyl = tfields.TensorMaps(mesh_copy)
>>> assert mesh_cp_cyl.coordSys == tfields.bases.CYLINDER
>>> assert mesh_cp_cyl.coord_sys == tfields.bases.CYLINDER
Raises:
>>> import tfields
......@@ -1359,7 +1359,7 @@ class TensorMaps(TensorFields):
ValueError: Incorrect map rank 0
"""
__slots__ = ['coordSys', 'fields', 'maps']
__slots__ = ['coord_sys', 'fields', 'maps']
def __new__(cls, tensors, *fields, **kwargs):
maps = kwargs.pop('maps', [])
......@@ -1506,7 +1506,7 @@ class TensorMaps(TensorFields):
if not issubclass(type(other), Tensors):
return super(TensorMaps, self).equal(other, **kwargs)
else:
with other.tmp_transform(self.coordSys):
with other.tmp_transform(self.coord_sys):
mask = super(TensorMaps, self).equal(other, **kwargs)
if issubclass(type(other), TensorMaps):
if len(self.maps) != len(other.maps):
......
......@@ -18,7 +18,7 @@ def evalf(array, cutExpression=None, coords=None):
Args:
array (numpy ndarray)
cutExpression (sympy logical expression)
coordSys (str): coordSys to evalfuate the expression in.
coord_sys (str): coord_sys to evalfuate the expression in.
Returns:
np.array: mask which is True, where cutExpression evalfuates True.
Examples:
......
......@@ -462,7 +462,7 @@ class Mesh3D(tfields.TensorMaps):
new_points = np.empty((0, 3))
new_faces = np.empty((0, 3))
new_fields = [tfields.Tensors(np.empty((0,) + field.shape[1:]),
coordSys=field.coordSys)
coord_sys=field.coord_sys)
for field in inst.fields]
new_map_fields = [[] for field in inst.maps[0].fields]
new_norm_vectors = []
......@@ -524,11 +524,11 @@ class Mesh3D(tfields.TensorMaps):
face_map = tfields.TensorFields(faces, *faces_fields,
dtype=int,
coordSys=inst.maps[0].coordSys)
coord_sys=inst.maps[0].coord_sys)
inst = tfields.Mesh3D(vertices,
*fields,
maps=[face_map] + inst.maps[1:],
coordSys=inst.coordSys)
coord_sys=inst.coord_sys)
mask = np.full(len(inst.maps[0]), True, dtype=bool)
for face_idx in range(len(inst.maps[0])):
if face_idx in face_delete_indices:
......@@ -627,7 +627,7 @@ class Mesh3D(tfields.TensorMaps):
maps=maps)
return inst
def cut(self, expression, coordSys=None, at_intersection=None,
def cut(self, expression, coord_sys=None, at_intersection=None,
return_template=False):
"""
cut method for Mesh3D.
......@@ -642,7 +642,7 @@ class Mesh3D(tfields.TensorMaps):
We use the vertices and maps of the Mesh as the sceleton of
the returned mesh. The fields are mapped according to
indices in the template.maps[i].fields.
coordSys (coordinate system to cut in):
coord_sys (coordinate system to cut in):
at_intersection (str): instruction on what to do, when a cut will intersect a triangle.
Options: "remove" (Default)
"split" - Create new triangles that make up the old one.
......@@ -713,7 +713,7 @@ class Mesh3D(tfields.TensorMaps):
* optional: template
"""
with self.tmp_transform(coordSys or self.coordSys):
with self.tmp_transform(coord_sys or self.coord_sys):
if isinstance(expression, Mesh3D):
obj = self._cut_template(expression)
else:
......
......@@ -18,11 +18,11 @@ class Points3D(tfields.Tensors):
Args:
points3DInstance -> copy constructor
[points3DInstance1, points3DInstance2, ...] -> coordSys are correctly treated
[points3DInstance1, points3DInstance2, ...] -> coord_sys are correctly treated
list of coordinates (see examples)
Kwargs:
coordSys (str):
coord_sys (str):
Use tfields.bases.CARTESIAN -> x, y, z
Use tfields.bases.CYLINDER -> r, phi, z
Use tfields.bases.SPHERICAL -> r, phi, theta
......@@ -55,11 +55,11 @@ class Points3D(tfields.Tensors):
[ 8.06225775, 1.05165021, -1. ],
[ 9.43398113, 1.01219701, 0. ]])
Copy constructor with one instance preserves coordSys of instance
>>> assert tfields.Points3D(p2).coordSys == p2.coordSys
Copy constructor with one instance preserves coord_sys of instance
>>> assert tfields.Points3D(p2).coord_sys == p2.coord_sys
Unless you specify other:
>>> tfields.Points3D(p2, coordSys=tfields.bases.CARTESIAN)
>>> tfields.Points3D(p2, coord_sys=tfields.bases.CARTESIAN)
Points3D([[ 1., 4., 1.],
[ 2., 5., 2.],
[ 3., 6., -6.],
......@@ -83,7 +83,7 @@ class Points3D(tfields.Tensors):
>>> p1.transform(tfields.bases.CYLINDER)
... unless specified other. Here it is specified
>>> tfields.Points3D.merged(p1, p2, coordSys=tfields.bases.CYLINDER)
>>> tfields.Points3D.merged(p1, p2, coord_sys=tfields.bases.CYLINDER)
Points3D([[ 2.23606798, 1.10714872, 3. ],
[ 6.40312424, 0.89605538, 6. ],
[ 2.23606798, 1.10714872, -6. ],
......@@ -127,7 +127,7 @@ class Points3D(tfields.Tensors):
... [7.071, -2.356, -5.],
... [1. , 0. , -1.],
... [1. , 1.571, -1.]],
... coordSys=tfields.bases.CYLINDER),
... coord_sys=tfields.bases.CYLINDER),
... atol=1e-3)
>>> p.transform(tfields.bases.CARTESIAN)
>>> assert p.equal(p_cart, atol=1e-15)
......
......@@ -124,7 +124,7 @@ class Triangles3D(tfields.TensorFields):
def triangleScalars(self, scalars):
self.fields = tfields.scalars_to_fields(scalars)
def evalf(self, expression=None, coordSys=None):
def evalf(self, expression=None, coord_sys=None):
"""
Triangle3D implementation
Examples:
......@@ -141,12 +141,12 @@ class Triangles3D(tfields.TensorFields):
Returns:
np.array: mask which is True, where expression evaluates True
"""
mask = super(Triangles3D, self).evalf(expression, coordSys=coordSys)
mask = super(Triangles3D, self).evalf(expression, coord_sys=coord_sys)
mask = self._to_triangles_mask(mask)
mask = np.array([mask] * 3).T.reshape((len(self)))
return mask
def cut(self, expression, coordSys=None):
def cut(self, expression, coord_sys=None):
"""
Default cut method for Triangles3D
Examples:
......@@ -166,7 +166,7 @@ class Triangles3D(tfields.TensorFields):
>>> assert np.array_equal(tc2.triangleScalars, np.array([[2.]]))
"""
mask = self.evalf(expression, coordSys=coordSys)
mask = self.evalf(expression, coord_sys=coord_sys)
inst = self[mask].copy()
# inst.triangleScalars =
......@@ -290,12 +290,12 @@ class Triangles3D(tfields.TensorFields):
nT = self.ntriangles()
mat = np.ones((1, 3)) / 3.0
# matrix product calculatesq center of all triangles
return tfields.Points3D(np.dot(mat, self.reshape(nT, 3, 3))[0], coordSys=self.coordSys)
return tfields.Points3D(np.dot(mat, self.reshape(nT, 3, 3))[0], coord_sys=self.coord_sys)
"""
Old version:
pointA, pointB, pointC = self.corners()
return Points3D(1. / 3 * (pointA + pointB + pointC)), coordSys=self.coordSys
return Points3D(1. / 3 * (pointA + pointB + pointC)), coord_sys=self.coord_sys
This versioin was slightly slower (110 % of new version)
Memory usage of new version is better for a factor of 4 or so.
Not really reliable method of measurement
......@@ -549,7 +549,7 @@ class Triangles3D(tfields.TensorFields):
return np.empty((tensors.shape[0], 0), dtype=bool)
masks = np.zeros((len(tensors), self.ntriangles()), dtype=bool)
with tensors.tmp_transform(self.