Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
madarrays
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
skmad-suite
madarrays
Commits
af54a8ae
There was a problem fetching the pipeline summary.
Commit
af54a8ae
authored
6 years ago
by
Florent Jaillet
Browse files
Options
Downloads
Patches
Plain Diff
Correct get_known_mask() and finalize doctrings
parent
a896393b
No related branches found
No related tags found
No related merge requests found
Pipeline
#
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
madarrays/mad_array.py
+47
-7
47 additions, 7 deletions
madarrays/mad_array.py
madarrays/tests/test_madarray.py
+25
-13
25 additions, 13 deletions
madarrays/tests/test_madarray.py
with
72 additions
and
20 deletions
madarrays/mad_array.py
+
47
−
7
View file @
af54a8ae
...
...
@@ -524,16 +524,29 @@ class MadArray(np.ndarray):
string
=
'
<MadArray at {}>
'
return
string
.
format
(
hex
(
id
(
self
)))
def
get_known_mask
(
self
,
mask_type
=
'
a
ny
'
):
def
get_known_mask
(
self
,
mask_type
=
'
a
ll
'
):
"""
Boolean mask for known coefficients.
TODO: finish this
Compute the boolean mask marking known coefficients as True.
Parameters
----------
mask_type : {
'
a
ny
'
,
'
a
ll
'
,
'
magnitude
'
,
'
phase
'
,
'
magnitude only
'
,
\
mask_type : {
'
a
ll
'
,
'
a
ny
'
,
'
magnitude
'
,
'
phase
'
,
'
magnitude only
'
,
\
'
phase only
'
}
TODO
Type of mask:
- ``all``: mark coefficients for wich both the magnitude and the
phase are known,
- ``any``: mark coefficients for wich the magnitude or the phase
are known (including when both the magnitude and the phase are
known),
- ``magnitude``: mark coefficients for wich the magnitude is
known,
- ``phase``: mark coefficients for wich the phase is known,
- ``magnitude only``: mark coefficients for wich both the magnitude
is known and the phase is unknown,
- ``phase only``: mark coefficients for wich both the phase is
known and the magnitude is unknown.
Returns
-------
...
...
@@ -546,18 +559,45 @@ class MadArray(np.ndarray):
ValueError
If ``mask_type`` has an invalid value.
"""
return
~
self
.
get_unknown_mask
(
mask_type
)
if
mask_type
==
'
all
'
:
return
~
self
.
get_unknown_mask
(
'
any
'
)
elif
mask_type
==
'
any
'
:
return
~
self
.
get_unknown_mask
(
'
all
'
)
elif
mask_type
==
'
magnitude
'
:
return
~
self
.
get_unknown_mask
(
'
magnitude
'
)
elif
mask_type
==
'
phase
'
:
return
~
self
.
get_unknown_mask
(
'
phase
'
)
elif
mask_type
==
'
magnitude only
'
:
return
self
.
get_unknown_mask
(
'
phase only
'
)
elif
mask_type
==
'
phase only
'
:
return
self
.
get_unknown_mask
(
'
magnitude only
'
)
errmsg
=
'
Invalid value for mask_type: {}
'
.
format
(
mask_type
)
raise
ValueError
(
errmsg
)
def
get_unknown_mask
(
self
,
mask_type
=
'
any
'
):
"""
Boolean mask for unknown coefficients.
TODO: finish this
Compute the boolean mask marking unknown coefficients as True.
Parameters
----------
mask_type : {
'
any
'
,
'
all
'
,
'
magnitude
'
,
'
phase
'
,
'
magnitude only
'
,
\
'
phase only
'
}
TODO
Type of mask:
- ``any``: mark coefficients for wich the magnitude or the phase
are unknown (including when both the magnitude and the phase are
unknown),
- ``all``: mark coefficients for wich both the magnitude and the
phase are unknown,
- ``magnitude``: mark coefficients for wich the magnitude is
unknown,
- ``phase``: mark coefficients for wich the phase is unknown,
- ``magnitude only``: mark coefficients for wich both the magnitude
is unknown and the phase is known,
- ``phase only``: mark coefficients for wich both the phase is
unknown and the magnitude is known.
Returns
-------
...
...
This diff is collapsed.
Click to expand it.
madarrays/tests/test_madarray.py
+
25
−
13
View file @
af54a8ae
...
...
@@ -138,11 +138,11 @@ class TestMadArray:
np
.
testing
.
assert_equal
(
ma
.
get_unknown_mask
(
'
phase only
'
),
self
.
empty_mask
)
np
.
testing
.
assert_equal
(
ma
.
get_known_mask
(
'
phase only
'
),
self
.
full
_mask
)
self
.
empty
_mask
)
np
.
testing
.
assert_equal
(
ma
.
get_unknown_mask
(
'
magnitude only
'
),
self
.
empty_mask
)
np
.
testing
.
assert_equal
(
ma
.
get_known_mask
(
'
magnitude only
'
),
self
.
full
_mask
)
self
.
empty
_mask
)
match
=
'
Invalid value for mask_type: error
'
with
pytest
.
raises
(
ValueError
,
match
=
match
):
...
...
@@ -183,22 +183,34 @@ class TestMadArray:
assert
ma
.
is_masked
()
np
.
testing
.
assert_equal
(
ma
.
to_np_array
(),
x
)
np
.
testing
.
assert_equal
(
ma
.
get_known_mask
(),
np
.
logical_and
(
~
self
.
mm
,
~
self
.
mp
))
np
.
testing
.
assert_equal
(
ma
.
get_unknown_mask
(),
np
.
logical_or
(
self
.
mm
,
self
.
mp
))
self
.
mm
|
self
.
mp
)
np
.
testing
.
assert_equal
(
ma
.
get_known_mask
(),
~
self
.
mm
&
~
self
.
mp
)
np
.
testing
.
assert_equal
(
ma
.
get_unknown_mask
(
'
any
'
),
np
.
logical_or
(
self
.
mm
,
self
.
mp
))
self
.
mm
|
self
.
mp
)
np
.
testing
.
assert_equal
(
ma
.
get_known_mask
(
'
any
'
),
~
self
.
mm
|
~
self
.
mp
)
np
.
testing
.
assert_equal
(
ma
.
get_unknown_mask
(
'
all
'
),
np
.
logical_and
(
self
.
mm
,
self
.
mp
))
np
.
testing
.
assert_equal
(
ma
.
get_known_mask
(
'
phase
'
),
~
self
.
mp
)
np
.
testing
.
assert_equal
(
ma
.
get_unknown_mask
(
'
phase
'
),
self
.
mp
)
np
.
testing
.
assert_equal
(
ma
.
get_known_mask
(
'
magnitude
'
),
~
self
.
mm
)
np
.
testing
.
assert_equal
(
ma
.
get_unknown_mask
(
'
magnitude
'
),
self
.
mm
)
self
.
mm
&
self
.
mp
)
np
.
testing
.
assert_equal
(
ma
.
get_known_mask
(
'
all
'
),
~
self
.
mm
&
~
self
.
mp
)
np
.
testing
.
assert_equal
(
ma
.
get_unknown_mask
(
'
phase
'
),
self
.
mp
)
np
.
testing
.
assert_equal
(
ma
.
get_known_mask
(
'
phase
'
),
~
self
.
mp
)
np
.
testing
.
assert_equal
(
ma
.
get_unknown_mask
(
'
magnitude
'
),
self
.
mm
)
np
.
testing
.
assert_equal
(
ma
.
get_known_mask
(
'
magnitude
'
),
~
self
.
mm
)
np
.
testing
.
assert_equal
(
ma
.
get_unknown_mask
(
'
phase only
'
),
np
.
logical_and
(
self
.
mp
,
~
self
.
mm
))
self
.
mp
&
~
self
.
mm
)
np
.
testing
.
assert_equal
(
ma
.
get_known_mask
(
'
phase only
'
),
~
self
.
mp
&
self
.
mm
)
np
.
testing
.
assert_equal
(
ma
.
get_unknown_mask
(
'
magnitude only
'
),
np
.
logical_and
(
~
self
.
mp
,
self
.
mm
))
self
.
mm
&
~
self
.
mp
)
np
.
testing
.
assert_equal
(
ma
.
get_unknown_mask
(
'
phase only
'
),
~
self
.
mm
&
self
.
mp
)
match
=
'
Invalid value for mask_type: error
'
with
pytest
.
raises
(
ValueError
,
match
=
match
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment