[get_moments] fix dimension of moments of empty poly
This commit is contained in:
parent
0dd2c45908
commit
1ff8ab1014
2 changed files with 14 additions and 1 deletions
|
|
@ -47,7 +47,7 @@ def get_moments(poly: poly_t, order: int) -> NDArray[numpy.float64]:
|
|||
num_verts = vertices.shape[0]
|
||||
|
||||
if num_verts == 0:
|
||||
return numpy.array([0], dtype=float)
|
||||
return numpy.zeros(number_of_moments(order), dtype=float)
|
||||
|
||||
#
|
||||
# Decompose polyhedron into triangle fans
|
||||
|
|
|
|||
13
adze/test/test_edge_cases.py
Normal file
13
adze/test/test_edge_cases.py
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
import numpy
|
||||
import pytest
|
||||
from numpy.testing import assert_allclose
|
||||
|
||||
import adze
|
||||
|
||||
|
||||
@pytest.mark.parametrize('order', [0, 1, 2, 3])
|
||||
def test_empty_poly_moments_shape(order: int) -> None:
|
||||
moments = adze.get_moments(adze.util.build_empty(), order)
|
||||
assert moments.shape == (adze.number_of_moments(order),)
|
||||
assert_allclose(moments, numpy.zeros_like(moments))
|
||||
|
||||
Loading…
Reference in a new issue