From e6d42ffd83cd9e61cbe0a76c9bf0f444e36661f0 Mon Sep 17 00:00:00 2001 From: janbridley Date: Sat, 14 Sep 2024 15:06:01 -0400 Subject: [PATCH] Remove depretated calls in conftest --- tests/conftest.py | 28 +++++++++++++++++++--------- tests/test_shape_getters.py | 9 ++++++++- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 9c126d3d..e20b56d9 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -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): @@ -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) @@ -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, ) diff --git a/tests/test_shape_getters.py b/tests/test_shape_getters.py index 95ff4707..078f9d93 100644 --- a/tests/test_shape_getters.py +++ b/tests/test_shape_getters.py @@ -4,6 +4,7 @@ import json import numpy as np +import pytest from pytest import approx from conftest import data_filenames_mark @@ -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)