Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
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):
...
@@ -1408,10 +1408,8 @@ class Tensors(AbstractNdarray):
# template
# template
indices
=
np
.
arange
(
len
(
self
))[
mask
]
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.
template
=
tfields
.
TensorFields
(
np
.
empty
((
len
(
indices
),
0
)),
indices
)
# We have a trade-off with small memory consumpiton here.
template
=
tfields
.
TensorFields
(
inst
,
indices
)
return
inst
,
template
return
inst
,
template
def
_cut_template
(
self
,
template
):
def
_cut_template
(
self
,
template
):
...
@@ -1449,7 +1447,7 @@ class Tensors(AbstractNdarray):
...
@@ -1449,7 +1447,7 @@ class Tensors(AbstractNdarray):
projected_field
[
nan_mask
]
=
np
.
nan
# correction for nan
projected_field
[
nan_mask
]
=
np
.
nan
# correction for nan
fields
.
append
(
projected_field
)
fields
.
append
(
projected_field
)
if
dim
(
template
)
==
0
:
if
dim
(
template
)
==
0
:
tensors
=
self
tensors
=
np
.
array
(
self
)[
template
.
fields
[
0
]]
else
:
else
:
tensors
=
template
tensors
=
template
return
type
(
self
)(
Tensors
(
tensors
),
*
fields
)
return
type
(
self
)(
Tensors
(
tensors
),
*
fields
)
...
@@ -2413,21 +2411,6 @@ class TensorMaps(TensorFields):
...
@@ -2413,21 +2411,6 @@ class TensorMaps(TensorFields):
else
:
else
:
return
inst
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
):
def
_cut_template
(
self
,
template
):
"""
"""
Args:
Args:
...
...
Write
Preview
Markdown
is supported
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