Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
finam
Manage
Activity
Members
Labels
Plan
Issues
32
Issue boards
Milestones
Code
Merge requests
3
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Monitor
Service Desk
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FINAM
finam
Commits
c499b3fe
Commit
c499b3fe
authored
1 month ago
by
Sebastian Müller
🐈
Browse files
Options
Downloads
Patches
Plain Diff
test: add mask routine tests
parent
3ecfea7a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!286
Add mask to Info object
Pipeline
#267951
passed with stages
in 4 minutes and 31 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/data/test_masked.py
+54
-0
54 additions, 0 deletions
tests/data/test_masked.py
with
54 additions
and
0 deletions
tests/data/test_masked.py
+
54
−
0
View file @
c499b3fe
...
...
@@ -121,6 +121,60 @@ class TestMasked(unittest.TestCase):
np
.
testing
.
assert_allclose
(
data
[
mask
],
ucdata_c
[
mask
])
np
.
testing
.
assert_allclose
(
data
[
mask
],
ucdata_f
[
mask
])
# more specific routines
grid1
=
fm
.
RectilinearGrid
([(
1.0
,
2.0
,
3.0
,
4.0
)])
grid2
=
fm
.
RectilinearGrid
([(
1.0
,
2.0
,
3.0
)])
grid3
=
fm
.
RectilinearGrid
([(
1.0
,
2.0
,
3.0
),
(
1.0
,
2.0
,
3.0
)])
mask1
=
np
.
array
((
1
,
0
,
0
),
dtype
=
bool
)
mask2
=
np
.
array
((
0
,
0
,
1
),
dtype
=
bool
)
mask3
=
np
.
array
((
1
,
0
,
1
),
dtype
=
bool
)
mask4
=
np
.
array
((
1
,
1
,
1
),
dtype
=
bool
)
mask5
=
np
.
array
((
0
,
0
,
0
),
dtype
=
bool
)
mask6
=
np
.
array
((
1
,
0
),
dtype
=
bool
)
mask7
=
np
.
array
(((
0
,
1
),
(
0
,
1
)),
dtype
=
bool
)
data
=
np
.
ma
.
masked_array
((
10.0
,
20.0
,
30.0
),
mask1
,
fill_value
=
np
.
nan
)
# submask check
self
.
assertFalse
(
fm
.
data
.
tools
.
is_sub_mask
(
mask1
,
mask2
))
self
.
assertFalse
(
fm
.
data
.
tools
.
is_sub_mask
(
mask1
,
np
.
ma
.
nomask
))
self
.
assertTrue
(
fm
.
data
.
tools
.
is_sub_mask
(
mask1
,
mask3
))
self
.
assertTrue
(
fm
.
data
.
tools
.
is_sub_mask
(
mask2
,
mask3
))
self
.
assertTrue
(
fm
.
data
.
tools
.
is_sub_mask
(
np
.
ma
.
nomask
,
mask1
))
self
.
assertTrue
(
fm
.
data
.
tools
.
is_sub_mask
(
np
.
ma
.
nomask
,
mask2
))
self
.
assertTrue
(
fm
.
data
.
tools
.
is_sub_mask
(
np
.
ma
.
nomask
,
mask3
))
self
.
assertTrue
(
fm
.
data
.
tools
.
is_sub_mask
(
np
.
ma
.
nomask
,
mask4
))
self
.
assertTrue
(
fm
.
data
.
tools
.
is_sub_mask
(
np
.
ma
.
nomask
,
mask5
))
self
.
assertTrue
(
fm
.
data
.
tools
.
is_sub_mask
(
np
.
ma
.
nomask
,
np
.
ma
.
nomask
))
self
.
assertTrue
(
fm
.
data
.
tools
.
is_sub_mask
(
mask5
,
np
.
ma
.
nomask
))
self
.
assertFalse
(
fm
.
data
.
tools
.
is_sub_mask
(
mask1
,
mask6
))
self
.
assertFalse
(
fm
.
data
.
tools
.
is_sub_mask
(
mask1
,
mask7
))
# equal mask
self
.
assertTrue
(
fm
.
data
.
tools
.
masks_equal
(
None
,
None
))
self
.
assertTrue
(
fm
.
data
.
tools
.
masks_equal
(
fm
.
Mask
.
NONE
,
fm
.
Mask
.
NONE
))
self
.
assertTrue
(
fm
.
data
.
tools
.
masks_equal
(
fm
.
Mask
.
FLEX
,
fm
.
Mask
.
FLEX
))
self
.
assertFalse
(
fm
.
data
.
tools
.
masks_equal
(
fm
.
Mask
.
FLEX
,
fm
.
Mask
.
NONE
))
self
.
assertTrue
(
fm
.
data
.
tools
.
masks_equal
(
np
.
ma
.
nomask
,
np
.
ma
.
nomask
))
self
.
assertTrue
(
fm
.
data
.
tools
.
masks_equal
(
np
.
ma
.
nomask
,
mask5
))
self
.
assertTrue
(
fm
.
data
.
tools
.
masks_equal
(
mask5
,
np
.
ma
.
nomask
))
self
.
assertFalse
(
fm
.
data
.
tools
.
masks_equal
(
mask1
,
mask6
,
grid1
,
grid2
))
self
.
assertFalse
(
fm
.
data
.
tools
.
masks_equal
(
mask1
,
mask7
,
grid1
,
grid3
))
self
.
assertFalse
(
fm
.
data
.
tools
.
masks_equal
(
mask1
,
mask2
,
grid1
,
grid1
))
# cover domain
self
.
assertTrue
(
fm
.
data
.
tools
.
check_data_covers_domain
(
data
,
mask3
))
self
.
assertFalse
(
fm
.
data
.
tools
.
check_data_covers_domain
(
data
,
mask2
))
self
.
assertFalse
(
fm
.
data
.
tools
.
check_data_covers_domain
(
data
,
np
.
ma
.
nomask
))
np
.
testing
.
assert_array_almost_equal
(
data
,
fm
.
data
.
tools
.
to_masked
(
data
))
np
.
testing
.
assert_array_almost_equal
((
1
,
2
,
3
),
fm
.
data
.
tools
.
filled
((
1
,
2
,
3
)))
def
test_info_mask
(
self
):
grid
=
fm
.
RectilinearGrid
([(
1.0
,
2.0
,
3.0
)])
mask
=
np
.
array
((
1
,
0
,
0
),
dtype
=
bool
)
with
self
.
assertRaises
(
fm
.
FinamMetaDataError
):
fm
.
Info
(
grid
=
grid
,
mask
=
mask
)
if
__name__
==
"
__main__
"
:
unittest
.
main
()
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