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
deformvis
insarviz
Commits
97fc92ad
Commit
97fc92ad
authored
Dec 21, 2020
by
Margaux Mouchene
Browse files
first commit
parent
d76318a2
Changes
2
Hide whitespace changes
Inline
Side-by-side
testing/conftest.py
0 → 100644
View file @
97fc92ad
import
os
import
numpy
as
np
import
pytest
import
pytest
import
insarviz.ts_viz
@
pytest
.
fixture
def
mainwindow_for_test
():
"""
Create a test window.
"""
# this_dir = os.path.abspath(os.path.dirname(__file__))
# infile = os.path.join(this_dir, "test_fr_input.txt")
z
=
mg
.
node_x
.
copy
()
A_target
=
(
np
.
array
(
[
[
0.0
,
0.0
,
0.0
,
0.0
,
0.0
],
[
3.0
,
3.0
,
2.0
,
1.0
,
0.0
],
[
3.0
,
3.0
,
2.0
,
1.0
,
0.0
],
[
3.0
,
3.0
,
2.0
,
1.0
,
0.0
],
[
0.0
,
0.0
,
0.0
,
0.0
,
0.0
],
]
).
flatten
()
*
100.0
)
frcvr_target
=
np
.
array
(
[
[
0
,
1
,
2
,
3
,
4
],
[
5
,
5
,
6
,
7
,
9
],
[
10
,
10
,
11
,
12
,
14
],
[
15
,
15
,
16
,
17
,
19
],
[
20
,
21
,
22
,
23
,
24
],
]
).
flatten
()
upids_target
=
np
.
array
(
[
[
0
,
1
,
2
,
3
,
4
],
[
5
,
6
,
7
,
8
,
9
],
[
10
,
11
,
12
,
13
,
14
],
[
15
,
16
,
17
,
18
,
19
],
[
20
,
21
,
22
,
23
,
24
],
]
).
flatten
()
links2rcvr_target
=
np
.
full
(
25
,
XX
)
links2rcvr_target
[
mg
.
core_nodes
]
=
np
.
array
([
9
,
10
,
11
,
18
,
19
,
20
,
27
,
28
,
29
])
Q_target
=
A_target
*
2.0
# only once Q_in is used
steepest_target
=
np
.
array
(
[
[
0.0
,
0.0
,
0.0
,
0.0
,
0.0
],
[
0.0
,
1.0
,
1.0
,
1.0
,
0.0
],
[
0.0
,
1.0
,
1.0
,
1.0
,
0.0
],
[
0.0
,
1.0
,
1.0
,
1.0
,
0.0
],
[
0.0
,
0.0
,
0.0
,
0.0
,
0.0
],
]
).
flatten
()
mg
.
add_field
(
"topographic__elevation"
,
z
,
at
=
"node"
,
units
=
"-"
)
class
DansGrid
(
object
):
pass
dans_grid
=
DansGrid
()
dans_grid
.
mg
=
mg
dans_grid
.
z
=
z
dans_grid
.
infile
=
infile
dans_grid
.
A_target
=
A_target
dans_grid
.
frcvr_target
=
frcvr_target
dans_grid
.
upids_target
=
upids_target
dans_grid
.
Q_target
=
Q_target
dans_grid
.
steepest_target
=
steepest_target
dans_grid
.
links2rcvr_target
=
links2rcvr_target
return
dans_grid
window
=
Window
()
window
.
show
()
qtbot
.
addWidget
(
window
)
testing/test_ts_qt.py
0 → 100644
View file @
97fc92ad
import
numpy
as
np
from
numpy.testing
import
assert_array_equal
from
landlab.components.flow_accum
import
find_drainage_area_and_discharge
from
landlab.components.flow_accum.flow_accum_to_n
import
(
find_drainage_area_and_discharge_to_n
,
)
def
test_boundary_to_n
():
r
=
np
.
array
(
[
[
1
,
2
],
[
4
,
5
],
[
1
,
5
],
[
6
,
2
],
[
4
,
-
1
],
[
4
,
-
1
],
[
5
,
7
],
[
4
,
5
],
[
6
,
7
],
[
7
,
8
],
]
)
p
=
np
.
array
(
[
[
0.6
,
0.4
],
[
0.85
,
0.15
],
[
0.65
,
0.35
],
[
0.9
,
0.1
],
[
1.0
,
0.0
],
[
1.0
,
0.0
],
[
0.75
,
0.25
],
[
0.55
,
0.45
],
[
0.8
,
0.2
],
[
0.95
,
0.05
],
]
)
s
=
np
.
array
([
4
,
5
,
1
,
7
,
2
,
6
,
0
,
8
,
3
,
9
])
a
,
q
=
find_drainage_area_and_discharge_to_n
(
s
,
r
,
p
,
boundary_nodes
=
[
0
])
true_a
=
np
.
array
([
0.0
,
1.715
,
1.1
,
1.0
,
9.0
,
4.9775
,
2.74
,
2.845
,
1.05
,
1.0
])
assert
np
.
allclose
(
a
,
true_a
)
def
test_boundary_bw
():
r
=
np
.
array
([
2
,
5
,
2
,
7
,
5
,
5
,
6
,
5
,
7
,
8
])
-
1
s
=
np
.
array
([
4
,
1
,
0
,
2
,
5
,
6
,
3
,
8
,
7
,
9
])
a
,
q
=
find_drainage_area_and_discharge
(
s
,
r
,
boundary_nodes
=
[
0
])
true_a
=
np
.
array
([
0.0
,
2.0
,
1.0
,
1.0
,
9.0
,
4.0
,
3.0
,
2.0
,
1.0
,
1.0
])
assert_array_equal
(
a
,
true_a
)
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