36 lines
1,014 B
Python
36 lines
1,014 B
Python
import numpy
|
|
import pytest
|
|
from numpy.testing import assert_allclose
|
|
|
|
import adze
|
|
import adze.util
|
|
|
|
def test_boundary_from_empty_poly() -> None:
|
|
assert adze.boundary_from_poly(adze.util.build_empty()) == []
|
|
|
|
|
|
@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))
|
|
|
|
|
|
|
|
def test_check_poly_rejects_row_count_mismatch() -> None:
|
|
poly = {
|
|
'vertices': numpy.array([
|
|
[0.0, 0.0, 0.0],
|
|
[1.0, 0.0, 0.0],
|
|
[0.0, 1.0, 0.0],
|
|
[9.0, 9.0, 9.0],
|
|
]),
|
|
'neighbors': numpy.array([
|
|
[1, 2, 0],
|
|
[2, 0, 1],
|
|
[0, 1, 2],
|
|
], dtype=int),
|
|
}
|
|
|
|
with pytest.raises(adze.AdzeError, match='Neighbors must have shape'):
|
|
adze.util.check_poly(poly, check_connectivity=False)
|