|
85 | 85 | _, AX = plt.subplots()
|
86 | 86 |
|
87 | 87 |
|
88 |
| -@pytest.mark.parametrize("component", GEO_TYPES) |
89 |
| -def test_plot(component): |
90 |
| - _ = component.plot(z=0, ax=AX) |
| 88 | +@pytest.mark.parametrize("component, swap_axes", zip(GEO_TYPES, [True, False])) |
| 89 | +def test_plot(component, swap_axes): |
| 90 | + _ = component.plot(z=0, ax=AX, swap_axes=swap_axes) |
91 | 91 | plt.close()
|
92 | 92 |
|
93 |
| - |
94 |
| -def test_plot_with_units(): |
95 |
| - _ = BOX.plot(z=0, ax=AX, plot_length_units="nm") |
| 93 | +@pytest.mark.parametrize("swap_axes", [True, False]) |
| 94 | +def test_plot_with_units(swap_axes): |
| 95 | + _ = BOX.plot(z=0, ax=AX, plot_length_units="nm", swap_axes=swap_axes) |
96 | 96 | plt.close()
|
97 | 97 |
|
98 | 98 |
|
@@ -204,11 +204,11 @@ def test_array_to_vertices():
|
204 | 204 | assert np.all(np.array(vertices) == np.array(vertices2))
|
205 | 205 |
|
206 | 206 |
|
207 |
| -@pytest.mark.parametrize("component", GEO_TYPES) |
208 |
| -def test_intersections_plane(component): |
209 |
| - assert len(component.intersections_plane(z=0.2)) > 0 |
210 |
| - assert len(component.intersections_plane(x=0.2)) > 0 |
211 |
| - assert len(component.intersections_plane(x=10000)) == 0 |
| 207 | +@pytest.mark.parametrize("component, swap_axes", zip(GEO_TYPES, [True, False])) |
| 208 | +def test_intersections_plane(component, swap_axes): |
| 209 | + assert len(component.intersections_plane(z=0.2, swap_axes=swap_axes)) > 0 |
| 210 | + assert len(component.intersections_plane(x=0.2, swap_axes=swap_axes)) > 0 |
| 211 | + assert len(component.intersections_plane(x=10000, swap_axes=swap_axes)) == 0 |
212 | 212 |
|
213 | 213 |
|
214 | 214 | def test_intersections_plane_inf():
|
@@ -778,38 +778,39 @@ def test_pop_axis():
|
778 | 778 | assert Ly == _Ly
|
779 | 779 |
|
780 | 780 |
|
781 |
| -def test_pop_axis_and_swap(): |
| 781 | +@pytest.mark.parametrize("swap_axes", [True, False]) |
| 782 | +def test_pop_axis_and_swap(swap_axes): |
782 | 783 | b = td.Box(size=(1, 1, 1))
|
783 |
| - for swap_axes in (False, True): |
784 |
| - for axis in range(3): |
785 |
| - coords = (1, 2, 3) |
786 |
| - Lz, (Lx, Ly) = b.pop_axis_and_swap(coords, axis=axis, swap_axes=swap_axes) |
787 |
| - _coords = b.unpop_axis_and_swap(Lz, (Lx, Ly), axis=axis, swap_axes=swap_axes) |
788 |
| - assert all(c == _c for (c, _c) in zip(coords, _coords)) |
789 |
| - _Lz, (_Lx, _Ly) = b.pop_axis_and_swap(_coords, axis=axis, swap_axes=swap_axes) |
790 |
| - assert Lz == _Lz |
791 |
| - assert Lx == _Lx |
792 |
| - assert Ly == _Ly |
793 |
| - |
794 |
| - |
795 |
| -def test_2b_box_intersections(): |
| 784 | + for axis in range(3): |
| 785 | + coords = (1, 2, 3) |
| 786 | + Lz, (Lx, Ly) = b.pop_axis_and_swap(coords, axis=axis, swap_axes=swap_axes) |
| 787 | + _coords = b.unpop_axis_and_swap(Lz, (Lx, Ly), axis=axis, swap_axes=swap_axes) |
| 788 | + assert all(c == _c for (c, _c) in zip(coords, _coords)) |
| 789 | + _Lz, (_Lx, _Ly) = b.pop_axis_and_swap(_coords, axis=axis, swap_axes=swap_axes) |
| 790 | + assert Lz == _Lz |
| 791 | + assert Lx == _Lx |
| 792 | + assert Ly == _Ly |
| 793 | + |
| 794 | + |
| 795 | +@pytest.mark.parametrize("swap_axes", [True, False]) |
| 796 | +def test_2b_box_intersections(swap_axes): |
796 | 797 | plane = td.Box(size=(1, 4, 0))
|
797 | 798 | box1 = td.Box(size=(1, 1, 1))
|
798 | 799 | box2 = td.Box(size=(1, 1, 1), center=(3, 0, 0))
|
799 | 800 |
|
800 |
| - result = plane.intersections_with(box1) |
| 801 | + result = plane.intersections_with(box1, swap_axes=swap_axes) |
801 | 802 | assert len(result) == 1
|
802 | 803 | assert result[0].geom_type == "Polygon"
|
803 |
| - assert len(plane.intersections_with(box2)) == 0 |
| 804 | + assert len(plane.intersections_with(box2, swap_axes=swap_axes)) == 0 |
804 | 805 |
|
805 | 806 | with pytest.raises(ValidationError):
|
806 |
| - _ = box1.intersections_with(box2) |
| 807 | + _ = box1.intersections_with(box2, swap_axes=swap_axes) |
807 | 808 |
|
808 |
| - assert len(box1.intersections_2dbox(plane)) == 1 |
809 |
| - assert len(box2.intersections_2dbox(plane)) == 0 |
| 809 | + assert len(box1.intersections_2dbox(plane, swap_axes=swap_axes)) == 1 |
| 810 | + assert len(box2.intersections_2dbox(plane, swap_axes=swap_axes)) == 0 |
810 | 811 |
|
811 | 812 | with pytest.raises(ValidationError):
|
812 |
| - _ = box2.intersections_2dbox(box1) |
| 813 | + _ = box2.intersections_2dbox(box1, swap_axes=swap_axes) |
813 | 814 |
|
814 | 815 |
|
815 | 816 | def test_polyslab_merge():
|
|
0 commit comments