Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
finam
Manage
Activity
Members
Labels
Plan
Issues
31
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
Merge requests
!258
Grid mask support
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Grid mask support
grid_mask_support
into
main
Overview
10
Commits
30
Pipelines
18
Changes
13
All threads resolved!
Hide all comments
Merged
Sebastian Müller
requested to merge
grid_mask_support
into
main
1 year ago
Overview
10
Commits
30
Pipelines
18
Changes
1
All threads resolved!
Hide all comments
Expand
👍
0
👎
0
Merge request reports
Viewing commit
4d8d3d86
Prev
Next
Show latest version
1 file
+
62
−
0
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
4d8d3d86
tests: test masking adapter
· 4d8d3d86
Sebastian Müller
authored
1 year ago
tests/adapters/test_masking.py
0 → 100644
+
62
−
0
Options
"""
Unit tests for masking adapter.
"""
import
unittest
from
datetime
import
datetime
,
timedelta
import
numpy
as
np
from
finam
import
(
Composition
,
EsriGrid
,
Info
,
)
from
finam.adapters.masking
import
Masking
from
finam.modules
import
debug
,
generators
class
TestMasking
(
unittest
.
TestCase
):
def
test_masking
(
self
):
time
=
datetime
(
2000
,
1
,
1
)
mask
=
[
[
True
,
False
,
True
],
[
False
,
False
,
True
],
[
False
,
False
,
False
],
[
True
,
False
,
False
],
]
in_grid
=
EsriGrid
(
ncols
=
3
,
nrows
=
4
,
order
=
"
F
"
)
out_grid
=
EsriGrid
(
ncols
=
3
,
nrows
=
4
,
mask
=
mask
,
order
=
"
F
"
)
in_info
=
Info
(
time
=
time
,
grid
=
in_grid
,
units
=
"
m
"
)
in_data
=
np
.
zeros
(
shape
=
in_info
.
grid
.
data_shape
,
order
=
in_info
.
grid
.
order
)
in_data
.
data
[
0
,
0
]
=
1.0
in_data
.
data
[
0
,
1
]
=
2.0
source
=
generators
.
CallbackGenerator
(
callbacks
=
{
"
Output
"
:
(
lambda
t
:
in_data
,
in_info
)},
start
=
datetime
(
2000
,
1
,
1
),
step
=
timedelta
(
days
=
1
),
)
sink
=
debug
.
DebugConsumer
(
{
"
Input
"
:
Info
(
None
,
grid
=
out_grid
,
units
=
None
)},
start
=
datetime
(
2000
,
1
,
1
),
step
=
timedelta
(
days
=
1
),
)
composition
=
Composition
([
source
,
sink
],
log_level
=
"
DEBUG
"
)
composition
.
initialize
()
source
.
outputs
[
"
Output
"
]
>>
Masking
()
>>
sink
.
inputs
[
"
Input
"
]
composition
.
connect
()
self
.
assertTrue
(
np
.
isnan
(
sink
.
data
[
"
Input
"
][
0
][
0
,
0
]))
self
.
assertAlmostEqual
(
sink
.
data
[
"
Input
"
][
0
][
0
,
1
].
magnitude
,
2.0
)
print
(
sink
.
data
[
"
Input
"
][
0
])
if
__name__
==
"
__main__
"
:
unittest
.
main
()
Loading