Skip to content

Commit

Permalink
Add pytest.warns for backward compatibility tests
Browse files Browse the repository at this point in the history
  • Loading branch information
janbridley committed Sep 14, 2024
1 parent e6d42ff commit 99c8c38
Showing 1 changed file with 35 additions and 29 deletions.
64 changes: 35 additions & 29 deletions tests/test_shape_families.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,35 +262,41 @@ def test_uniform_dipyramids(n):


def test_new_prism_antiprism():
for i, nameshape in enumerate(PrismAntiprismFamily):
name, shape = nameshape

if "Anti" in name:
n = i + 3 # count + min_n
comparative_shape = UniformAntiprismFamily.get_shape(n)
else:
n = (i + 3) - 8 # count + min_n + n_prism
comparative_shape = UniformPrismFamily.get_shape(n)

np.testing.assert_allclose(shape.volume, comparative_shape.volume, atol=ATOL)
np.testing.assert_allclose(
shape.edge_lengths, comparative_shape.edge_lengths, atol=ATOL
)
with pytest.warns(DeprecationWarning, match="deprecated in favor of"):
for i, nameshape in enumerate(PrismAntiprismFamily):
name, shape = nameshape

if "Anti" in name:
n = i + 3 # count + min_n
comparative_shape = UniformAntiprismFamily.get_shape(n)
else:
n = (i + 3) - 8 # count + min_n + n_prism
comparative_shape = UniformPrismFamily.get_shape(n)

np.testing.assert_allclose(
shape.volume, comparative_shape.volume, atol=ATOL
)
np.testing.assert_allclose(
shape.edge_lengths, comparative_shape.edge_lengths, atol=ATOL
)


def test_new_pyramid_dipyramid():
for i, nameshape in enumerate(PyramidDipyramidFamily):
name, shape = nameshape

if "Di" in name:
n = i + 3 # count + min_n
comparative_shape = UniformDipyramidFamily.get_shape(n)
else:
n = (i + 3) - 3 # count + min_n + n_pyramid
comparative_shape = UniformPyramidFamily.get_shape(n)

np.testing.assert_allclose(comparative_shape.centroid, 0.0, atol=ATOL)
np.testing.assert_allclose(shape.volume, comparative_shape.volume, atol=ATOL)
np.testing.assert_allclose(
shape.edge_lengths, comparative_shape.edge_lengths, atol=ATOL
)
with pytest.warns(DeprecationWarning, match="deprecated in favor of"):
for i, nameshape in enumerate(PyramidDipyramidFamily):
name, shape = nameshape

if "Di" in name:
n = i + 3 # count + min_n
comparative_shape = UniformDipyramidFamily.get_shape(n)
else:
n = (i + 3) - 3 # count + min_n + n_pyramid
comparative_shape = UniformPyramidFamily.get_shape(n)

np.testing.assert_allclose(comparative_shape.centroid, 0.0, atol=ATOL)
np.testing.assert_allclose(
shape.volume, comparative_shape.volume, atol=ATOL
)
np.testing.assert_allclose(
shape.edge_lengths, comparative_shape.edge_lengths, atol=ATOL
)

0 comments on commit 99c8c38

Please sign in to comment.