Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Daniel Boeckenhoff
tfields
Commits
ac8c8113
Commit
ac8c8113
authored
May 28, 2018
by
Daniel Böckenhoff (Laptop)
Browse files
core - raise in maps
parent
de2644d1
Changes
1
Hide whitespace changes
Inline
Side-by-side
tfields/core.py
View file @
ac8c8113
...
...
@@ -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
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment