Commit ac8c8113 authored by Daniel Böckenhoff (Laptop)'s avatar Daniel Böckenhoff (Laptop)
Browse files

core - raise in maps

parent de2644d1
......@@ -1024,6 +1024,7 @@ class TensorFields(Tensors):
if fields:
# (over)write fields
obj.fields = [Tensors(field) for field in fields]
return obj
def __getitem__(self, index):
......@@ -1147,6 +1148,13 @@ class TensorMaps(TensorFields):
>>> assert mesh.equal(tfields.TensorFields(vectors, scalars))
>>> assert mesh.maps[0].fields[0].equal(maps[0].fields[0])
Raises:
>>> import tfields
>>> tfields.TensorMaps([1] * 4, dim=3, maps=[[1, 2, 3]]) # +doctest: ELLIPSIS
Traceback (most recent call last):
...
ValueError: Incorrect map rank 0
"""
__slots__ = ['coordSys', 'fields', 'maps']
......@@ -1155,6 +1163,9 @@ class TensorMaps(TensorFields):
maps_cp = []
for mp in maps:
mp = TensorFields(mp, dtype=int)
if not mp.rank == 1:
raise ValueError("Incorrect map rank {mp.rank}"
.format(**locals()))
maps_cp.append(mp)
kwargs['maps'] = maps_cp
obj = super(TensorMaps, cls).__new__(cls, tensors, *fields, **kwargs)
......
Supports Markdown
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