Skip to content

Commit c4d06d5

Browse files
committed
run black on tests
1 parent b3f9247 commit c4d06d5

23 files changed

+56
-195
lines changed

tests/compas/data/test_json.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,7 @@ def test_json_network():
6969

7070

7171
def test_json_mesh():
72-
before = Mesh.from_vertices_and_faces(
73-
[[0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0]], [[0, 1, 2, 3]]
74-
)
72+
before = Mesh.from_vertices_and_faces([[0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0]], [[0, 1, 2, 3]])
7573
after = compas.json_loads(compas.json_dumps(before))
7674
assert before.dtype == after.dtype
7775
assert before.attributes == after.attributes
@@ -81,10 +79,7 @@ def test_json_mesh():
8179
assert all(after.has_face(face) for face in before.faces())
8280
assert all(before.has_edge(edge) for edge in after.edges())
8381
assert all(after.has_edge(edge) for edge in before.edges())
84-
assert all(
85-
before.face_vertices(a) == after.face_vertices(b)
86-
for a, b in zip(before.faces(), after.faces())
87-
)
82+
assert all(before.face_vertices(a) == after.face_vertices(b) for a, b in zip(before.faces(), after.faces()))
8883
assert before.guid == after.guid
8984

9085

tests/compas/data/test_jsonschema.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,7 @@ def test_schema_vector_invalid(vector_validator, vector):
215215
def test_schema_line_valid(line_validator, line):
216216
line_validator.validate(line)
217217

218-
@pytest.mark.parametrize(
219-
"line", [[[0, 0, 0], [0, 0, 0]], {"START": [0, 0, 0], "END": [0, 0, 0]}]
220-
)
218+
@pytest.mark.parametrize("line", [[[0, 0, 0], [0, 0, 0]], {"START": [0, 0, 0], "END": [0, 0, 0]}])
221219
def test_schema_line_invalid(line_validator, line):
222220
with pytest.raises(jsonschema.exceptions.ValidationError):
223221
line_validator.validate(line)
@@ -226,16 +224,12 @@ def test_schema_line_invalid(line_validator, line):
226224
def test_schema_plane_valid(plane_validator, plane):
227225
plane_validator.validate(plane)
228226

229-
@pytest.mark.parametrize(
230-
"plane", [[[0, 0, 0], [0, 0, 1]], {"POINT": [0, 0, 0], "NORMAL": [0, 0, 1]}]
231-
)
227+
@pytest.mark.parametrize("plane", [[[0, 0, 0], [0, 0, 1]], {"POINT": [0, 0, 0], "NORMAL": [0, 0, 1]}])
232228
def test_schema_plane_invalid(plane_validator, plane):
233229
with pytest.raises(jsonschema.exceptions.ValidationError):
234230
plane_validator.validate(plane)
235231

236-
@pytest.mark.parametrize(
237-
"circle", [{"plane": {"point": [0, 0, 0], "normal": [0, 0, 1]}, "radius": 1.0}]
238-
)
232+
@pytest.mark.parametrize("circle", [{"plane": {"point": [0, 0, 0], "normal": [0, 0, 1]}, "radius": 1.0}])
239233
def test_schema_circle_valid(circle_validator, circle):
240234
circle_validator.validate(circle)
241235

@@ -442,9 +436,7 @@ def test_schema_box_invalid(box_validator, box):
442436
with pytest.raises(jsonschema.exceptions.ValidationError):
443437
box_validator.validate(box)
444438

445-
@pytest.mark.parametrize(
446-
"capsule", [{"line": {"start": [0, 0, 0], "end": [1, 0, 0]}, "radius": 1.0}]
447-
)
439+
@pytest.mark.parametrize("capsule", [{"line": {"start": [0, 0, 0], "end": [1, 0, 0]}, "radius": 1.0}])
448440
def test_schema_capsule_valid(capsule_validator, capsule):
449441
capsule_validator.validate(capsule)
450442

tests/compas/datastructures/test_graph.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,7 @@ def test_edgedata_io(graph):
3535
for index, (u, v) in enumerate(graph.edges()):
3636
graph.edge_attribute((u, v), "index", index)
3737
other = Graph.from_data(graph.data)
38-
assert all(
39-
other.edge_attribute(edge, "index") == index
40-
for index, edge in enumerate(other.edges())
41-
)
38+
assert all(other.edge_attribute(edge, "index") == index for index, edge in enumerate(other.edges()))
4239

4340

4441
def test_data_schema(graph):

tests/compas/datastructures/test_halfedge.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,21 +71,15 @@ def test_edgedata_nondirectionality(mesh):
7171
mesh.update_default_edge_attributes({"index": 0})
7272
for index, (u, v) in enumerate(mesh.edges()):
7373
mesh.edge_attribute((u, v), "index", index)
74-
assert all(
75-
mesh.edge_attribute((u, v), "index") == mesh.edge_attribute((v, u), "index")
76-
for u, v in mesh.edges()
77-
)
74+
assert all(mesh.edge_attribute((u, v), "index") == mesh.edge_attribute((v, u), "index") for u, v in mesh.edges())
7875

7976

8077
def test_edgedata_io(mesh):
8178
mesh.update_default_edge_attributes({"index": 0})
8279
for index, (u, v) in enumerate(mesh.edges()):
8380
mesh.edge_attribute((u, v), "index", index)
8481
other = HalfEdge.from_data(mesh.data)
85-
assert all(
86-
other.edge_attribute(edge, "index") == index
87-
for index, edge in enumerate(other.edges())
88-
)
82+
assert all(other.edge_attribute(edge, "index") == index for index, edge in enumerate(other.edges()))
8983

9084

9185
def test_data_schema(mesh):

tests/compas/datastructures/test_halfface.py

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,7 @@ def test_vertices_where_predicate():
8484
hf.add_vertex(0)
8585
hf.add_vertex(1, {"a": 5, "b": 10})
8686
hf.add_vertex(2, {"a": 15, "b": 20})
87-
assert list(
88-
hf.vertices_where_predicate(lambda v, attr: attr["b"] - attr["a"] == 5)
89-
) == [1, 2]
87+
assert list(hf.vertices_where_predicate(lambda v, attr: attr["b"] - attr["a"] == 5)) == [1, 2]
9088

9189

9290
# ==============================================================================
@@ -109,9 +107,7 @@ def test_edges_where_predicate():
109107
hf.add_vertex(vkey)
110108
hf.add_halfface([0, 1, 2])
111109
hf.edge_attribute((0, 1), "a", 5)
112-
assert list(hf.edges_where_predicate(lambda e, attr: attr["a"] - attr["b"] == 3))[
113-
0
114-
] == (0, 1)
110+
assert list(hf.edges_where_predicate(lambda e, attr: attr["a"] - attr["b"] == 3))[0] == (0, 1)
115111

116112

117113
# ==============================================================================
@@ -136,10 +132,7 @@ def test_faces_where_predicate():
136132
for i in range(3):
137133
hf.add_halfface([i, i + 1, i + 2])
138134
hf.face_attribute(1, "a", 5)
139-
assert (
140-
list(hf.faces_where_predicate(lambda e, attr: attr["a"] - attr["b"] == 3))[0]
141-
== 1
142-
)
135+
assert list(hf.faces_where_predicate(lambda e, attr: attr["a"] - attr["b"] == 3))[0] == 1
143136

144137

145138
# ==============================================================================
@@ -178,7 +171,4 @@ def test_cells_where_predicate():
178171
]
179172
)
180173
hf.cell_attribute(1, "a", 5)
181-
assert (
182-
list(hf.cells_where_predicate(lambda e, attr: attr["a"] - attr["b"] == 3))[0]
183-
== 1
184-
)
174+
assert list(hf.cells_where_predicate(lambda e, attr: attr["a"] - attr["b"] == 3))[0] == 1

tests/compas/datastructures/test_mesh_subd.py

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,55 +20,41 @@ def test_quads_subdivide(mesh_quads):
2020
subd = mesh_quads.subdivide()
2121
assert subd.number_of_faces() == 4 * mesh_quads.number_of_faces()
2222
assert subd.number_of_vertices() == (
23-
mesh_quads.number_of_vertices()
24-
+ mesh_quads.number_of_edges()
25-
+ mesh_quads.number_of_faces()
23+
mesh_quads.number_of_vertices() + mesh_quads.number_of_edges() + mesh_quads.number_of_faces()
2624
)
2725

2826

2927
def test_tris_subdivide(mesh_tris):
3028
subd = mesh_tris.subdivide()
3129
assert subd.number_of_faces() == 3 * mesh_tris.number_of_faces()
3230
assert subd.number_of_vertices() == (
33-
mesh_tris.number_of_vertices()
34-
+ mesh_tris.number_of_edges()
35-
+ mesh_tris.number_of_faces()
31+
mesh_tris.number_of_vertices() + mesh_tris.number_of_edges() + mesh_tris.number_of_faces()
3632
)
3733

3834

3935
def test_quads_subdivide_tri(mesh_quads):
4036
subd = mesh_quads.subdivide(scheme="tri")
4137
assert subd.number_of_faces() == 4 * mesh_quads.number_of_faces()
42-
assert (
43-
subd.number_of_vertices()
44-
== mesh_quads.number_of_vertices() + mesh_quads.number_of_faces()
45-
)
38+
assert subd.number_of_vertices() == mesh_quads.number_of_vertices() + mesh_quads.number_of_faces()
4639

4740

4841
def test_tris_subdivide_tri(mesh_tris):
4942
subd = mesh_tris.subdivide(scheme="tri")
5043
assert subd.number_of_faces() == 3 * mesh_tris.number_of_faces()
51-
assert (
52-
subd.number_of_vertices()
53-
== mesh_tris.number_of_vertices() + mesh_tris.number_of_faces()
54-
)
44+
assert subd.number_of_vertices() == mesh_tris.number_of_vertices() + mesh_tris.number_of_faces()
5545

5646

5747
def test_quads_subdivide_quad(mesh_quads):
5848
subd = mesh_quads.subdivide(scheme="quad")
5949
assert subd.number_of_faces() == 4 * mesh_quads.number_of_faces()
6050
assert subd.number_of_vertices() == (
61-
mesh_quads.number_of_vertices()
62-
+ mesh_quads.number_of_edges()
63-
+ mesh_quads.number_of_faces()
51+
mesh_quads.number_of_vertices() + mesh_quads.number_of_edges() + mesh_quads.number_of_faces()
6452
)
6553

6654

6755
def test_tris_subdivide_quad(mesh_tris):
6856
subd = mesh_tris.subdivide(scheme="quad")
6957
assert subd.number_of_faces() == 3 * mesh_tris.number_of_faces()
7058
assert subd.number_of_vertices() == (
71-
mesh_tris.number_of_vertices()
72-
+ mesh_tris.number_of_edges()
73-
+ mesh_tris.number_of_faces()
59+
mesh_tris.number_of_vertices() + mesh_tris.number_of_edges() + mesh_tris.number_of_faces()
7460
)

tests/compas/geometry/test_core.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -197,14 +197,10 @@ def test_centroid_polyhedron(polyhedron, centroid):
197197
# ==============================================================================
198198

199199

200-
@pytest.mark.parametrize(
201-
("polyhedron", "volume"), [(Polyhedron.from_platonicsolid(6), None)]
202-
)
200+
@pytest.mark.parametrize(("polyhedron", "volume"), [(Polyhedron.from_platonicsolid(6), None)])
203201
def test_volume_polyhedron(polyhedron, volume):
204202
if volume is None:
205-
L = length_vector(
206-
subtract_vectors(polyhedron.vertices[0], polyhedron.vertices[1])
207-
)
203+
L = length_vector(subtract_vectors(polyhedron.vertices[0], polyhedron.vertices[1]))
208204
volume = L * L * L
209205
V = volume_polyhedron(polyhedron)
210206
assert close(V, volume)

tests/compas/geometry/test_distance.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
from compas.geometry import closest_point_on_segment_xy
66

77

8-
@pytest.mark.parametrize(
9-
"point,point_on_line", [[[0, 0, -10], [1, 1, 0]], [[5, 4, 80], [4.5, 4.5, 0]]]
10-
)
8+
@pytest.mark.parametrize("point,point_on_line", [[[0, 0, -10], [1, 1, 0]], [[5, 4, 80], [4.5, 4.5, 0]]])
119
def test_closest_point_segment_xy(point, point_on_line):
1210
line = Line([1, 1, -15], [10, 10, 20])
1311
ponl = closest_point_on_segment_xy(Point(*point), line)

tests/compas/geometry/test_offset.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,7 @@ def test_offset_polyline_equals_offset_line(polyline, distance, normal, tol):
7979
)
8080
],
8181
)
82-
def test_variable_offset_on_colinear_polyline(
83-
polyline, distance, normal, tol, output_polyline
84-
):
82+
def test_variable_offset_on_colinear_polyline(polyline, distance, normal, tol, output_polyline):
8583
output_polyline = [v for v in output_polyline]
8684
assert allclose(offset_polyline(polyline, distance, normal, tol), output_polyline)
8785

tests/compas/geometry/test_polygon.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,7 @@
1010
if not compas.IPY:
1111

1212
def test_data():
13-
p = Polygon(
14-
[
15-
Point(random.random(), random.random(), random.random())
16-
for i in range(10)
17-
]
18-
)
13+
p = Polygon([Point(random.random(), random.random(), random.random()) for i in range(10)])
1914
assert p.data == p.validate_data()
2015
o = Polygon.from_data(p.data)
2116
assert p == o

0 commit comments

Comments
 (0)