Skip to content

Commit

Permalink
Remove depretated calls in conftest
Browse files Browse the repository at this point in the history
  • Loading branch information
janbridley committed Sep 14, 2024
1 parent ceeb6e3 commit e6d42ff
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 10 deletions.
28 changes: 19 additions & 9 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,16 @@
CatalanFamily,
JohnsonFamily,
PlatonicFamily,
PrismAntiprismFamily,
PyramidDipyramidFamily,
RegularNGonFamily,
UniformAntiprismFamily,
UniformDipyramidFamily,
UniformPrismFamily,
UniformPyramidFamily,
)
from coxeter.shapes import ConvexPolyhedron, ConvexSpheropolyhedron, Polyhedron, Shape2D

MAX_INFINITE_FAMILY_N = 11


# Define a function to combine marks in order to more compactly test shape families
def combine_marks(*marks):
Expand Down Expand Up @@ -186,7 +190,7 @@ def assert_distance_to_surface_2d(shape, angles, computed_distance):

def quaternion_from_axis_angle(x, y, z, theta):
"""Generate a quaternion from axis [x, y, z] and angle theta."""
if x == y == z == 0:
if np.allclose([x, y, z], 0):
return np.array([1, 0, 0, 0])
axis = np.array([x, y, z])
axis /= np.linalg.norm(axis)
Expand Down Expand Up @@ -284,22 +288,28 @@ def johnson_solids():
ids=_johnson_shape_names,
)

_prismantiprism_shape_names = PrismAntiprismFamily.data.keys()
named_prismantiprism_mark = pytest.mark.parametrize(
argnames="poly",
argvalues=[
PrismAntiprismFamily.get_shape(name) for name in _prismantiprism_shape_names
*[UniformPrismFamily.get_shape(n) for n in range(3, MAX_INFINITE_FAMILY_N)],
*[UniformAntiprismFamily.get_shape(n) for n in range(3, MAX_INFINITE_FAMILY_N)],
],
ids=[
*[f"prism-{n}" for n in range(3, MAX_INFINITE_FAMILY_N)],
*[f"antiprism-{n}" for n in range(3, MAX_INFINITE_FAMILY_N)],
],
ids=_prismantiprism_shape_names,
)

_pyramiddipyramid_shape_names = PyramidDipyramidFamily.data.keys()
named_pyramiddipyramid_mark = pytest.mark.parametrize(
argnames="poly",
argvalues=[
PyramidDipyramidFamily.get_shape(name) for name in _pyramiddipyramid_shape_names
*[UniformPyramidFamily.get_shape(n) for n in range(3, 6)],
*[UniformDipyramidFamily.get_shape(n) for n in range(3, 6)],
],
ids=[
*[f"pyramid-{n}" for n in range(3, 6)],
*[f"dipyramid-{n}" for n in range(3, 6)],
],
ids=_pyramiddipyramid_shape_names,
)


Expand Down
9 changes: 8 additions & 1 deletion tests/test_shape_getters.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import json

import numpy as np
import pytest
from pytest import approx

from conftest import data_filenames_mark
Expand Down Expand Up @@ -117,6 +118,12 @@ def test_json_data_families(family):
# Extract the stored shape keys
shapes = list(fam_data.keys())
for shape in shapes:
module_vertices = module.get_shape(shape).vertices
if "pyramid" in family or "prism" in family:
with pytest.warns(
DeprecationWarning, match="deprecated in favor of"
):
module_vertices = module.get_shape(shape).vertices
else:
module_vertices = module.get_shape(shape).vertices
json_vertices = fam_data[shape]["vertices"]
assert np.all(module_vertices == json_vertices)

0 comments on commit e6d42ff

Please sign in to comment.