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
4
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
4d8d3d86
Commit
4d8d3d86
authored
1 year ago
by
Sebastian Müller
🐈
Browse files
Options
Downloads
Patches
Plain Diff
tests: test masking adapter
parent
4a6296e4
No related branches found
No related tags found
1 merge request
!258
Grid mask support
Pipeline
#181248
failed with stages
in 2 minutes and 39 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/adapters/test_masking.py
+62
-0
62 additions, 0 deletions
tests/adapters/test_masking.py
with
62 additions
and
0 deletions
tests/adapters/test_masking.py
0 → 100644
+
62
−
0
View file @
4d8d3d86
"""
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
()
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