Browse Source

Surface.find_label_border_polygonal_chains: normalize to fix tests on python<3.8

Fabian Peter Hammerle 3 years ago
parent
commit
658fb8b0ca
2 changed files with 10 additions and 14 deletions
  1. 1 1
      CHANGELOG.md
  2. 9 13
      tests/test_surface.py

+ 1 - 1
CHANGELOG.md

@@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 - method `PolygonalCircuit.normalized()`
 
 ### Fixed
-- `PolygonalCircuit.find_label_border_polygonal_chains`:
+- `Surface.find_label_border_polygonal_chains`:
   always include vertices along border with single neighbour
   (previously indeterministic behaviour)
 - `PolygonalCircuit`: fix equals operator for circuits

+ 9 - 13
tests/test_surface.py

@@ -481,23 +481,19 @@ def test_find_label_border_polygonal_chains():
         lambda l: l.name == "precentral", surface.annotation.labels.values()
     )
     (border_chain,) = surface.find_label_border_polygonal_chains(precentral_label)
-    vertex_indices = list(border_chain.vertex_indices)
-    assert len(vertex_indices) == 418
-    min_index = vertex_indices.index(min(vertex_indices))
-    vertex_indices_normalized = vertex_indices[min_index:] + vertex_indices[:min_index]
-    if vertex_indices_normalized[-1] < vertex_indices_normalized[1]:
-        vertex_indices_normalized.reverse()
-    assert vertex_indices_normalized[346:353] == [
-        63264,
-        63255,
+    vertex_indices_normalized = list(border_chain.normalized().vertex_indices)
+    assert len(vertex_indices_normalized) == 418
+    assert vertex_indices_normalized[66:73] == [
+        61044,
+        62119,
         62118,
         62107,
         62118,
-        62119,
-        61044,
+        63255,
+        63264,
     ]
-    assert vertex_indices_normalized[:4] == [32065, 33450, 33454, 34870]
-    assert vertex_indices_normalized[-4:] == [33464, 32080, 32073, 32072]
+    assert vertex_indices_normalized[:4] == [32065, 32072, 32073, 32080]
+    assert vertex_indices_normalized[-4:] == [36281, 34870, 33454, 33450]
 
 
 def test__unused_vertices():