Skip to content
GitLab
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
dab8d7b9
Commit
dab8d7b9
authored
May 14, 2020
by
dboe
Browse files
bugfix for empty template cutting
parent
e227a907
Changes
1
Hide whitespace changes
Inline
Side-by-side
tfields/core.py
View file @
dab8d7b9
...
...
@@ -1408,10 +1408,8 @@ class Tensors(AbstractNdarray):
# template
indices
=
np
.
arange
(
len
(
self
))[
mask
]
# TODO: maybe np.empty instead of inst below. Reason why i copy is
# that the template is such marked for where it comes from.
# We have a trade-off with small memory consumpiton here.
template
=
tfields
.
TensorFields
(
inst
,
indices
)
template
=
tfields
.
TensorFields
(
np
.
empty
((
len
(
indices
),
0
)),
indices
)
return
inst
,
template
def
_cut_template
(
self
,
template
):
...
...
@@ -1449,7 +1447,7 @@ class Tensors(AbstractNdarray):
projected_field
[
nan_mask
]
=
np
.
nan
# correction for nan
fields
.
append
(
projected_field
)
if
dim
(
template
)
==
0
:
tensors
=
self
tensors
=
np
.
array
(
self
)[
template
.
fields
[
0
]]
else
:
tensors
=
template
return
type
(
self
)(
Tensors
(
tensors
),
*
fields
)
...
...
@@ -2413,21 +2411,6 @@ class TensorMaps(TensorFields):
else
:
return
inst
def
_cut_sympy
(
self
,
expression
):
if
len
(
self
)
==
0
:
return
self
.
copy
()
mask
=
self
.
evalf
(
expression
)
# coord_sys is handled by tmp_transform
mask
.
astype
(
bool
)
inst
=
self
[
mask
].
copy
()
# template
indices
=
np
.
arange
(
len
(
self
))[
mask
]
# TODO: maybe np.empty instead of inst below. Reason why i copy is
# that the template is such marked for where it comes from.
# We have a trade-off with small memory consumpiton here.
template
=
tfields
.
TensorFields
(
inst
,
indices
)
return
inst
,
template
def
_cut_template
(
self
,
template
):
"""
Args:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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