8 import fields2cover
as f2c
11 assert pytest.approx(a) == pytest.approx(b)
15 swaths = sw_gen.generateBestSwaths(obj, swath_width, poly);
16 assert not (swaths.size() < 1),
"Error 2001: No swaths were generated.";
17 assert not (swaths.size() > poly.area() / (swath_width * swath_width)), \
18 "Error 2002: " + str(swaths.size()) +
" swaths were generated." + \
19 "Expected less than " + str(poly.area() / (swath_width * swath_width)) + \
23 for i
in range(checks):
24 rand_ang = rand.getAngleRandom();
25 swaths2 = sw_gen.generateSwaths(rand_ang, swath_width, poly);
26 assert (obj.computeCostWithMinimizingSign(swaths) <= \
27 obj.computeCostWithMinimizingSign(swaths2)), \
28 "Error 2003: Cost (signed) of the optimal angle is " + \
29 str(obj.computeCostWithMinimizingSign(swaths)) + \
30 ", but the cost (signed) of a non-optimal angle (" + \
31 str(rand_ang) +
") is " + \
32 str(obj.computeCostWithMinimizingSign(swaths2)) +
".";
33 assert not (swaths.size() > poly.area() / (swath_width * swath_width)), \
34 "Error 2004: " + str(swaths2.size()) + \
35 " swaths were generated with angle " + str(rand_ang) + \
36 "Expected less than " + str(poly.area() / (swath_width * swath_width)) + \