n_swath_test.py
Go to the documentation of this file.
1 #==============================================================================
2 # Copyright (C) 2021-2024 Wageningen University - All Rights Reserved
3 # Author: Gonzalo Mier
4 # BSD-3 License
5 #==============================================================================
6 
7 import pytest
8 import fields2cover as f2c
9 
10 def near(a, b):
11  assert pytest.approx(a) == pytest.approx(b)
12 
14  swaths = f2c.Swaths(2);
15 
16  obj = f2c.OBJ_NSwath()
17  near(obj.computeCost(swaths), 2)
18 
19  for i in range(10):
20  swaths.push_back(f2c.Swath());
21  near(obj.computeCost(swaths), 3 + i)
22 
23 
25  swaths1 = f2c.Swaths(1);
26  swaths2 = f2c.Swaths(2);
27  swaths3 = f2c.Swaths(2);
28  swaths_cells = f2c.SwathsByCells();
29  swaths_cells.push_back(swaths2);
30  swaths_cells.push_back(swaths3);
31 
32  obj = f2c.OBJ_NSwath();
33 
34  near(obj.computeCost(swaths1), 1.0);
35  near(obj.computeCostWithMinimizingSign(swaths1), 1.0);
36 
37  near(obj.computeCost(swaths2), 2.0);
38  near(obj.computeCostWithMinimizingSign(swaths2), 2.0);
39 
40  near(obj.computeCost(swaths3), 2.0);
41  near(obj.computeCostWithMinimizingSign(swaths3), 2.0);
42 
43  near(obj.computeCost(swaths_cells), 4.0);
44  near(obj.computeCostWithMinimizingSign(swaths_cells), 4.0);
45 
46  swaths3.emplace_back(f2c.Swath());
47  near(obj.computeCost(swaths3), 3.0);
48 
49  swaths3.emplace_back(f2c.Swath());
50  near(obj.computeCost(swaths3), 4.0);
51 
53  objective = f2c.OBJ_NSwath();
54 
55  assert not (objective.isMaximizing());
56  assert (objective.isMinimizing());
n_swath_test.test_fields2cover_obj_n_swath_getBestValue
def test_fields2cover_obj_n_swath_getBestValue()
Definition: n_swath_test.py:13
n_swath_test.test_fields2cover_obj_n_swath_paramsCheck
def test_fields2cover_obj_n_swath_paramsCheck()
Definition: n_swath_test.py:52
n_swath_test.near
def near(a, b)
Definition: n_swath_test.py:10
n_swath_test.test_fields2cover_obj_n_swath_computeCost
def test_fields2cover_obj_n_swath_computeCost()
Definition: n_swath_test.py:24


fields2cover
Author(s):
autogenerated on Fri Apr 25 2025 02:18:31