core.py 19.9 KB
Newer Older
1
2
3
4
5
6
7
8
9
#!/usr/bin/env
# encoding: utf-8
"""
Author:     Daniel Boeckenhoff
Mail:       daniel.boeckenhoff@ipp.mpg.de

core of tfields library
contains numpy ndarray derived bases of the tfields package
"""
10
import tfields.bases
Daniel Boeckenhoff's avatar
Daniel Boeckenhoff committed
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import numpy as np
from contextlib import contextmanager
from collections import Counter
np.seterr(all='warn', over='raise')


def rank(tensor):
    """
    Tensor rank
    """
    return len(tensor.shape) - 1


def dim(tensor):
    """
    Manifold dimension
    """
    if rank(tensor) == 0:
        return 1
    return tensor.shape[1]


class AbstractNdarray(np.ndarray):
    """
    All tensors and subclasses should derive from AbstractNdarray.
    AbstractNdarray implements all the inheritance specifics for np.ndarray
    Whene inheriting, three attributes are of interest:
        __slots__ (list of str): If you want to add attributes to
            your AbstractNdarray subclass, add the attribute name to __slots__
40
        __slot_defaults__ (list): if __slot_defaults__ is None, the
Daniel Boeckenhoff's avatar
Daniel Boeckenhoff committed
41
42
43
44
45
46
47
48
49
50
51
52
53
54
            defaults for the attributes in __slots__ will be None
            other values will be treaded as defaults to the corresponding
            arg at the same position in the __slots__ list.
        __slotDtype__ (list of types): for the conversion of the
            args in __slots__ to numpy arrays. None values mean no
            conversion.

    Args:
        array (array-like): input array
        **kwargs: arguments corresponding to __slots__
    TODO:
        equality check
    """
    __slots__ = []
55
    __slot_defaults__ = []
Daniel Boeckenhoff's avatar
Daniel Boeckenhoff committed
56
    __slotDtypes__ = []
57
    __slot_setters__ = []
Daniel Boeckenhoff's avatar
Daniel Boeckenhoff committed
58

59
    def __new__(cls, array, **kwargs):  # pragma: no cover
Daniel Boeckenhoff's avatar
Daniel Boeckenhoff committed
60
61
62
63
64
65
        raise NotImplementedError("{clsType} type must implement '__new__'"
                                  .format(clsType=type(cls)))

    def __array_finalize__(self, obj):
        if obj is None:
            return
66
        for attr in self._iter_slots():
Daniel Boeckenhoff's avatar
Daniel Boeckenhoff committed
67
68
69
70
71
72
            setattr(self, attr, getattr(obj, attr, None))

    def __array_wrap__(self, out_arr, context=None):
        return np.ndarray.__array_wrap__(self, out_arr, context)

    @classmethod
73
    def _iter_slots(cls):
Daniel Boeckenhoff's avatar
Daniel Boeckenhoff committed
74
75
76
        return [att for att in cls.__slots__ if att != '_cache']

    @classmethod
77
    def _update_slot_kwargs(cls, kwargs):
Daniel Boeckenhoff's avatar
Daniel Boeckenhoff committed
78
        """
79
        set the defaults in kwargs according to __slot_defaults__
Daniel Boeckenhoff's avatar
Daniel Boeckenhoff committed
80
81
        and convert the kwargs according to __slotDtypes__
        """
82
83
        slotDefaults = cls.__slot_defaults__ + \
            [None] * (len(cls.__slots__) - len(cls.__slot_defaults__))
Daniel Boeckenhoff's avatar
Daniel Boeckenhoff committed
84
85
86
87
88
89
90
91
92
93
94
95
96
97
        slotDtypes = cls.__slotDtypes__ + \
            [None] * (len(cls.__slots__) - len(cls.__slotDtypes__))
        for attr, default, dtype in zip(cls.__slots__, slotDefaults, slotDtypes):
            if attr == '_cache':
                continue
            if attr not in kwargs:
                kwargs[attr] = default
            if dtype is not None:
                kwargs[attr] = np.array(kwargs[attr], dtype=dtype)

    def __setattr__(self, name, value):
        if name in self.__slots__:
            index = self.__slots__.index(name)
            try:
98
                setter = self.__slot_setters__[index]
Daniel Boeckenhoff's avatar
Daniel Boeckenhoff committed
99
100
101
102
103
104
105
106
107
108
109
110
            except IndexError:
                setter = None
            if setter is not None:
                value = setter(value)
        super(AbstractNdarray, self).__setattr__(name, value)

    def __reduce__(self):
        """
        important for pickling
        Examples:
            >>> from tempfile import NamedTemporaryFile
            >>> import pickle
111
            >>> import tfields
Daniel Boeckenhoff's avatar
Daniel Boeckenhoff committed
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137

            Build a dummy scalar field
            >>> 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')

            Save it and restore it
            >>> outFile = NamedTemporaryFile(suffix='.pickle')

            >>> pickle.dump(scalarField,
            ...             outFile)
            >>> _ = outFile.seek(0)

            >>> sf = pickle.load(outFile)
            >>> sf.coordSys == 'cylinder'
            True
            >>> sf.fields[0][2] == 2.
            True

        """
        # Get the parent's __reduce__ tuple
        pickled_state = super(AbstractNdarray, self).__reduce__()

        # Create our own tuple to pass to __setstate__
        new_state = pickled_state[2] + tuple([getattr(self, slot) for slot in
138
                                              self._iter_slots()])
Daniel Boeckenhoff's avatar
Daniel Boeckenhoff committed
139
140
141
142
143
144
145
146
147

        # Return a tuple that replaces the parent's __setstate__ tuple with our own
        return (pickled_state[0], pickled_state[1], new_state)

    def __setstate__(self, state):
        """
        important for unpickling
        """
        # Call the parent's __setstate__ with the other tuple elements.
148
        super(AbstractNdarray, self).__setstate__(state[0:-len(self._iter_slots())])
Daniel Boeckenhoff's avatar
Daniel Boeckenhoff committed
149
150

        # set the __slot__ attributes
151
        for i, slot in enumerate(reversed(self._iter_slots())):
Daniel Boeckenhoff's avatar
Daniel Boeckenhoff committed
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
            index = -(i + 1)
            setattr(self, slot, state[index])


class Tensors(AbstractNdarray):
    """
    Set of tensors with the same basis.
    TODO:
        all slot args should be protected -> _base
    Args:
        tensors: np.ndarray or AbstractNdarray subclass
    Examples:
        >>> from tfields import Tensors
        >>> import numpy as np

        Initialize a scalar range
        >>> scalars = Tensors([0, 1, 2])
        >>> scalars.rank == 0
        True

        Initialize vectors
        >>> vectors = Tensors([[0, 0, 0], [0, 0, 1], [0, -1, 0]])
        >>> vectors.rank == 1
        True
        >>> vectors.dim == 3
        True
        >>> assert vectors.coordSys == 'cartesian'

        Initialize the Levi-Zivita Tensor
        >>> matrices = Tensors([[[0, 0, 0], [0, 0, 1], [0, -1, 0]],
        ...                     [[0, 0, -1], [0, 0, 0], [1, 0, 0]],
        ...                     [[0, 1, 0], [-1, 0, 0], [0, 0, 0]]])
        >>> matrices.shape == (3, 3, 3)
        True
        >>> matrices.rank == 2
        True
        >>> matrices.dim == 3
        True

        Initializing in different start coordinate system
        >>> cyl = Tensors([[5, np.arctan(4. / 3.), 42]], coordSys='cylinder')
        >>> assert cyl.coordSys == 'cylinder'
194
        >>> cyl.transform('cartesian')
Daniel Boeckenhoff's avatar
Daniel Boeckenhoff committed
195
196
197
198
199
200
201
        >>> assert cyl.coordSys == 'cartesian'
        >>> cart = cyl
        >>> assert round(cart[0, 0], 10) == 3.
        >>> assert round(cart[0, 1], 10) == 4.
        >>> assert cart[0, 2] == 42

        Initialize with copy constructor keeps the coordinate system
202
203
204
205
        >>> with vectors.tmp_transform('cylinder'):
        ...     vect_cyl = Tensors(vectors)
        ...     assert vect_cyl.coordSys == vectors.coordSys
        >>> assert vect_cyl.coordSys == 'cylinder'
Daniel Boeckenhoff's avatar
Daniel Boeckenhoff committed
206
207
208
209
210
211
212
213

        You can demand a special dimension.
        >>> _ = Tensors([[1, 2, 3]], dim=3)
        >>> _ = Tensors([[1, 2, 3]], dim=2)  # doctest: +ELLIPSIS
        Traceback (most recent call last):
            ...
        ValueError: Incorrect dimension: 3 given, 2 demanded.

214
215
216
217
218
219
220
221
222
        The dimension argument (dim) becomes necessary if you want to initialize
        an empty array
        >>> _ = Tensors([])  # doctest: +ELLIPSIS
        Traceback (most recent call last):
            ...
        ValueError: Empty tensors need dimension parameter 'dim'.
        >>> Tensors([], dim=7)
        Tensors([], shape=(0, 7), dtype=float64)

Daniel Boeckenhoff's avatar
Daniel Boeckenhoff committed
223
224
    """
    __slots__ = ['coordSys']
225
226
    __slot_defaults__ = ['cartesian']
    __slot_setters__ = [tfields.bases.get_coord_system_name]
Daniel Boeckenhoff's avatar
Daniel Boeckenhoff committed
227
228
229
230
231
232
233
234
235
236
237
238

    def __new__(cls, tensors, **kwargs):
        ''' copy constructor '''
        if issubclass(type(tensors), cls):
            obj = tensors.copy()
            coordSys = kwargs.pop('coordSys', None)
            if kwargs:
                raise AttributeError("In copy constructor only 'coordSys' "
                                     "attribute is supported. Kwargs {kwargs} "
                                     "are not consumed"
                                     .format(**locals()))
            if coordSys is not None:
239
                obj.transform(coordSys)
Daniel Boeckenhoff's avatar
Daniel Boeckenhoff committed
240
241
242
243
244
245
246
247
248
            return obj

        dtype = kwargs.pop('dtype', np.float64)
        order = kwargs.pop('order', None)
        dim = kwargs.pop('dim', None)

        ''' process empty inputs '''
        if len(tensors) == 0:
            if dim is not None:
249
                tensors = np.empty((0, dim))
Daniel Boeckenhoff's avatar
Daniel Boeckenhoff committed
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
            else:
                raise ValueError("Empty tensors need dimension "
                                 "parameter 'dim'.")

        tensors = np.asarray(tensors, dtype=dtype, order=order)
        obj = tensors.view(cls)

        ''' check dimension(s) '''
        for d in obj.shape[1:]:
            if not d == obj.dim:
                raise ValueError("Dimensions are inconstistent.")
        if dim is not None:
            if dim != obj.dim:
                raise ValueError("Incorrect dimension: {obj.dim} given,"
                                 " {dim} demanded."
                                 .format(**locals()))

        ''' update kwargs with defaults from slots '''
268
        cls._update_slot_kwargs(kwargs)
Daniel Boeckenhoff's avatar
Daniel Boeckenhoff committed
269
270
271

        ''' set kwargs to slots attributes '''
        for attr in kwargs:
272
            if attr not in cls._iter_slots():
Daniel Boeckenhoff's avatar
Daniel Boeckenhoff committed
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
                raise AttributeError("Keywordargument {attr} not accepted "
                                     "for class {cls}".format(**locals()))
            setattr(obj, attr, kwargs[attr])

        return obj

    @classmethod
    def merged(cls, *objects, **kwargs):
        """
        Factory method
        Merges all tensor inputs to one tensor

        Examples:
            >>> import numpy as np
            >>> from tfields import Tensors
            >>> import tfields.bases
            >>> vecA = Tensors([[0, 0, 0], [0, 0, 1], [0, -1, 0]])
            >>> vecB = Tensors([[5, 4, 1]], coordSys=tfields.bases.cylinder)
            >>> vecC = Tensors([[5, 4, 1]], coordSys=tfields.bases.cylinder)
            >>> merge = Tensors.merged(vecA, vecB, vecC, [[2, 0, 1]])
            >>> assert merge.coordSys == 'cylinder'

        """

        ''' get most frequent coordSys or predefined coordSys '''
        coordSys = kwargs.get('coordSys', None)
        if coordSys is None:
            bases = []
            for t in objects:
                try:
                    bases.append(t.coordSys)
                except:
                    pass
            # get most frequent coordSys
            coordSys = sorted(bases, key=Counter(bases).get, reverse=True)[0]
            kwargs['coordSys'] = coordSys

        ''' transform all raw inputs to cls type with correct coordSys. Also
        automatically make a copy of those instances that are of the correct
        type already.'''
        objects = [cls(t, **kwargs) for t in objects]

        ''' check rank and dimension equality '''
        if not len(set([t.rank for t in objects])) == 1:
            raise TypeError("Tensors must have the same rank for merging.")
        if not len(set([t.dim for t in objects])) == 1:
            raise TypeError("Tensors must have the same dimension for merging.")

        ''' merge all objects '''
        remainingObjects = objects[1:] or []
        tensors = objects[0]

        for i, obj in enumerate(remainingObjects):
            tensors = np.append(tensors, obj, axis=0)
        return cls.__new__(cls, tensors, **kwargs)

    @property
    def rank(self):
        """
        Tensor rank
        """
        return rank(self)

    @property
    def dim(self):
        """
        Manifold dimension
        """
        return dim(self)

343
    def transform(self, coordSys):
Daniel Boeckenhoff's avatar
Daniel Boeckenhoff committed
344
345
346
347
348
349
350
351
352
353
        """
        Args:
            coordSys (str)

        Examples:
            >>> import numpy as np
            >>> from tfields import Tensors

            CARTESIAN to SPHERICAL
            >>> t = Tensors([[1, 2, 2], [1, 0, 0], [0, 0, -1], [0, 0, 1], [0, 0, 0]])
354
            >>> t.transform('spherical')
Daniel Boeckenhoff's avatar
Daniel Boeckenhoff committed
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375

            r
            >>> assert t[0, 0] == 3

            phi
            >>> assert t[1, 1] == 0.
            >>> assert t[2, 1] == 0.

            theta is 0 at (0, 0, 1) and pi at (0, 0, -1)
            >>> assert round(t[1, 2], 10) == round(np.pi / 2, 10)
            >>> assert t[2, 2] == np.pi
            >>> assert t[3, 2] == 0.

            theta is defined 0 for R == 0
            >>> assert t[4, 0] == 0.
            >>> assert t[4, 2] == 0.


            CARTESIAN to CYLINDER
            >>> tCart = Tensors([[3, 4, 42], [1, 0, 0], [0, 1, -1], [-1, 0, 1], [0, 0, 0]])
            >>> tCyl = tCart.copy()
376
            >>> tCyl.transform('cylinder')
Daniel Boeckenhoff's avatar
Daniel Boeckenhoff committed
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
            >>> assert tCyl.coordSys == 'cylinder'

            R
            >>> assert tCyl[0, 0] == 5
            >>> assert tCyl[1, 0] == 1
            >>> assert tCyl[2, 0] == 1
            >>> assert tCyl[4, 0] == 0

            Phi
            >>> assert round(tCyl[0, 1], 10) == round(np.arctan(4. / 3), 10)
            >>> assert tCyl[1, 1] == 0
            >>> assert round(tCyl[2, 1], 10) == round(np.pi / 2, 10)
            >>> assert tCyl[1, 1] == 0

            Z
            >>> assert tCyl[0, 2] == 42
            >>> assert tCyl[2, 2] == -1

395
            >>> tCyl.transform('cartesian')
Daniel Boeckenhoff's avatar
Daniel Boeckenhoff committed
396
397
398
399
400
401
402
403
404
            >>> assert tCyl.coordSys == 'cartesian'
            >>> assert tCyl[0, 0] == 3

        """
        #           scalars                 empty             already there
        if self.rank == 0 or self.shape[0] == 0 or self.coordSys == coordSys:
            self.coordSys = coordSys
            return

405
406
        tfields.bases.transform(self, self.coordSys, coordSys)
        # self[:] = tfields.bases.transform(self, self.coordSys, coordSys)
Daniel Boeckenhoff's avatar
Daniel Boeckenhoff committed
407
408
409
        self.coordSys = coordSys

    @contextmanager
410
    def tmp_transform(self, coordSys):
Daniel Boeckenhoff's avatar
Daniel Boeckenhoff committed
411
412
413
414
415
        """
        Temporarily change the coordSys to another coordSys and change it back at exit
        This method is for cleaner code only.
        No speed improvements go with this.
        Args:
416
            see transform
Daniel Boeckenhoff's avatar
Daniel Boeckenhoff committed
417
        Examples:
418
            >>> import tfields
Daniel Boeckenhoff's avatar
Daniel Boeckenhoff committed
419
            >>> p = tfields.Tensors([[1,2,3]], coordSys=tfields.bases.SPHERICAL)
420
            >>> with p.tmp_transform(tfields.bases.CYLINDER):
Daniel Boeckenhoff's avatar
Daniel Boeckenhoff committed
421
422
423
424
425
            ...     assert p.coordSys == tfields.bases.CYLINDER
            >>> assert p.coordSys == tfields.bases.SPHERICAL

        """
        baseBefore = self.coordSys
426
        if baseBefore == coordSys:
Daniel Boeckenhoff's avatar
Daniel Boeckenhoff committed
427
428
            yield
        else:
429
            self.transform(coordSys)
Daniel Boeckenhoff's avatar
Daniel Boeckenhoff committed
430
431
432

            yield

433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
            self.transform(baseBefore)

    def to_segment(self, segment, num_segments, coordinate,
                   periodicity=2 * np.pi, offset=0,
                   coordSys=None):
        """
        For circular (close into themself after
        <periodicity>) coordinates at index <coordinate> assume
        <num_segments> segments and transform all values to
        segment number <segment> 
        Examples:
            >>> import tfields
            >>> import numpy as np
            >>> pStart = tfields.Points3D([[6, 2 * np.pi, 1],
            ...                            [6, 2 * np.pi / 5 * 3, 1]],
            ...                           coordSys='cylinder')
            >>> p = tfields.Points3D(pStart)
            >>> p.to_segment(0, 5, 1, offset=-2 * np.pi / 10)
            >>> assert np.array_equal(p[:, 1], [0, 0])

            >>> p2 = tfields.Points3D(pStart)
            >>> p2.to_segment(1, 5, 1, offset=-2 * np.pi / 10)
            >>> assert np.array_equal(np.round(p2[:, 1], 4), [1.2566] * 2)

        """
        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):
            # map all values to first segment
            self[:, coordinate] = \
                (self[:, coordinate] - offset) % (periodicity /
                                                                 num_segments) + \
                offset + segment * periodicity / num_segments

    def equal(self, other,
              rtol=None, atol=None, equal_nan=False,
              return_bool=True):
        """
        Test, whether the instance has the same content as other.
        Args:
            optional:
                rtol (float)
                atol (float)
                equal_nan (bool)
            see numpy.isclose
        """
        if issubclass(type(other), Tensors) and self.coordSys != other.coordSys:
            other = other.copy()
            other.transform(self.coordSys)
        if rtol is None and atol is None:
            if return_bool:
                return np.array_equal(self, other)
            return self == other
        mask = np.isclose(self, other, rtol=rtol, atol=atol, equal_nan=equal_nan)
        if return_bool:
            return bool(np.all(mask))
        return mask

    def contains(self, other, **kwargs):
        """
        Inspired by a speed argument @
        stackoverflow.com/questions/14766194/testing-whether-a-numpy-array-contains-a-given-row
        Examples:
            >>> p = tfields.Tensors([[1,2,3], [4,5,6], [6,7,8]])
            >>> p.contains([4,5,6])
            True

        """
        return any(self.equal(other, return_bool=False).all(1))

    def getMoment(self, moment):
        """
        Returns:
            Moments of the distribution.
        Note:
            The first moment is given as the mean,
            second as variance etc. Not 0 as it is mathematicaly correct.
        Args:
            moment (int): n-th moment
        """
        if moment == 0:
            return 0
        if moment == 1:  # center of mass
            return np.average(self, axis=0)
        elif moment == 2:  # variance
            return np.var(self, axis=0)
        elif moment == 3 and stats:  # skewness
            return stats.skew(self, axis=0)
        elif moment == 4 and stats:  # kurtosis
            return stats.kurtosis(self, axis=0)
        else:
            raise NotImplementedError("Moment %i not implemented." % moment)


Daniel Boeckenhoff's avatar
Daniel Boeckenhoff committed
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563


class TensorFields(Tensors):
    """
    Discrete Tensor Field

    Examples:
        >>> 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)
        >>> scalarField.rank
        1
        >>> scalarField.fields[0].rank
        0
        >>> vectorField = TensorFields(vectors, vectors)
        >>> vectorField.fields[0].rank
        1
        >>> vectorField.fields[0].dim
        3
        >>> multiField = TensorFields(vectors, scalars, vectors)
        >>> multiField.fields[0].dim
        1
        >>> multiField.fields[1].dim
        3

    """
    __slots__ = ['coordSys', 'fields']

    def __new__(cls, tensors, *fields, **kwargs):
        obj = super(TensorFields, cls).__new__(cls, tensors, **kwargs)
        obj.fields = list(fields)
        return obj

564
565
    def transform(self, coordSys):
        super(TensorFields, self).transform(coordSys)
Daniel Boeckenhoff's avatar
Daniel Boeckenhoff committed
566
        for field in self.fields:
567
            field.transform(coordSys)
568
        
Daniel Boeckenhoff's avatar
Daniel Boeckenhoff committed
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596

class TensorMaps(TensorFields):
    """
    Args:
        tensors: see Tensors class
        *fields (Tensors): see TensorFields class
        **kwargs:
            coordSys ('str'): see Tensors class
            maps (array-like): indices indicating a connection between the
                tensors at the respective index positions
    Examples:
        >>> from tfields import Tensors, TensorMaps
        >>> scalars = Tensors([0, 1, 2])
        >>> vectors = Tensors([[0, 0, 0], [0, 0, 1], [0, -1, 0]])
        >>> mesh = TensorMaps(vectors, scalars, maps=[[[0, 1, 2], [0, 1, 2]],
        ...                                           [[1, 1, 1], [2, 2, 2]]])
        >>> mesh.maps
        array([[[0, 1, 2],
                [0, 1, 2]],
        <BLANKLINE>
               [[1, 1, 1],
                [2, 2, 2]]])

    """
    __slots__ = ['coordSys', 'fields', 'maps']
    __slotDtypes__ = [None, None, int]


597
if __name__ == '__main__':  # pragma: no cover
Daniel Boeckenhoff's avatar
Daniel Boeckenhoff committed
598
599
600
    import doctest
    doctest.testmod()
    # doctest.run_docstring_examples(TensorMaps, globals())