|
1 |
| - |
2 |
| - |
3 |
| - |
4 |
| - |
5 | 1 | import os
|
6 | 2 |
|
7 | 3 | import numpy as np
|
|
14 | 10 |
|
15 | 11 | from ..conftest import testdata
|
16 | 12 |
|
| 13 | +import pytest |
17 | 14 |
|
18 | 15 | class ComponentMove(cy_fixtures.CyTestMove):
|
19 | 16 |
|
@@ -104,6 +101,7 @@ def test_certain_move():
|
104 | 101 | print('--------------')
|
105 | 102 | print('test_certain_move')
|
106 | 103 | tgt = ComponentMove()
|
| 104 | + |
107 | 105 | tgt.certain_move()
|
108 | 106 |
|
109 | 107 | assert np.all(tgt.delta['lat'] != 0)
|
@@ -174,5 +172,45 @@ def test_ref_point():
|
174 | 172 | assert c_component.ref_point == tuple(tgt)
|
175 | 173 |
|
176 | 174 |
|
| 175 | +@pytest.mark.xfail(reason="component mover can't take negative integer") |
| 176 | +def test_run_backwards(): |
| 177 | + """ |
| 178 | + test that a component mover can work running backwards. |
| 179 | + """ |
| 180 | + tgt = ComponentMove() |
| 181 | + |
| 182 | + # same as the regular one, except with negative timestep. |
| 183 | + tgt.component.get_move( |
| 184 | + tgt.model_time, |
| 185 | + - tgt.time_step, |
| 186 | + tgt.ref, |
| 187 | + tgt.delta, |
| 188 | + tgt.status, |
| 189 | + basic_types.spill_type.forecast, |
| 190 | + ) |
| 191 | + deltas = tgt.delta |
| 192 | + tgt.component.model_step_is_done() |
| 193 | + |
| 194 | + print(deltas) |
| 195 | + |
| 196 | + # deltas when running forward: |
| 197 | + # [(4.42500067e-06, 9.92425248e-07, 0.) |
| 198 | + # (4.42500067e-06, 9.92425248e-07, 0.) |
| 199 | + # (4.42500067e-06, 9.92425248e-07, 0.) |
| 200 | + # (4.42500067e-06, 9.92425248e-07, 0.)] |
| 201 | + |
| 202 | + # Not sure how to test that it's correct, but maybe: |
| 203 | + # deltas should be all the same: |
| 204 | + for d in deltas: |
| 205 | + assert d == deltas[0] |
| 206 | + |
| 207 | + # They should be negative (frontwards are positive) |
| 208 | + assert deltas['lat'][0] < 0.0 |
| 209 | + assert deltas['long'][0] < 0.0 |
| 210 | + assert deltas['z'][0] == 0.0 |
| 211 | + |
| 212 | + assert False |
| 213 | + |
| 214 | + |
177 | 215 | if __name__ == '__main__':
|
178 | 216 | test_move()
|
0 commit comments