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
ift
NIFTy
Commits
203d3975
Commit
203d3975
authored
Jan 15, 2019
by
Philipp Arras
Browse files
Cleanup
parent
c14efdc6
Changes
1
Hide whitespace changes
Inline
Side-by-side
nifty5/operators/mask_operator.py
View file @
203d3975
...
...
@@ -39,24 +39,17 @@ class MaskOperator(LinearOperator):
def
__init__
(
self
,
mask
):
if
not
isinstance
(
mask
,
Field
):
raise
TypeError
self
.
_domain
=
DomainTuple
.
make
(
mask
.
domain
)
self
.
_mask
=
np
.
logical_not
(
mask
.
to_global_data
())
self
.
_target
=
DomainTuple
.
make
(
UnstructuredDomain
(
self
.
_mask
.
sum
()))
self
.
_capability
=
self
.
TIMES
|
self
.
ADJOINT_TIMES
def
data_indices
(
self
):
if
len
(
self
.
domain
.
shape
)
==
1
:
return
np
.
arange
(
self
.
domain
.
shape
[
0
])[
self
.
_mask
]
if
len
(
self
.
domain
.
shape
)
==
2
:
return
np
.
indices
(
self
.
domain
.
shape
).
transpose
((
1
,
2
,
0
))[
self
.
_mask
]
def
apply
(
self
,
x
,
mode
):
self
.
_check_input
(
x
,
mode
)
x
=
x
.
to_global_data
()
if
mode
==
self
.
TIMES
:
res
=
x
.
to_global_data
()
[
self
.
_mask
]
res
=
x
[
self
.
_mask
]
return
Field
.
from_global_data
(
self
.
target
,
res
)
x
=
x
.
to_global_data
()
res
=
np
.
empty
(
self
.
domain
.
shape
,
x
.
dtype
)
res
[
self
.
_mask
]
=
x
res
[
~
self
.
_mask
]
=
0
...
...
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