Skip to content

Commit

Permalink
Split unit & integration-test with marker
Browse files Browse the repository at this point in the history
  • Loading branch information
deltaLuki committed Jun 28, 2023
1 parent 8209f01 commit 8e95961
Show file tree
Hide file tree
Showing 25 changed files with 55 additions and 5 deletions.
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,9 @@ build = ["cp*-many*"]

[tool.cibuildwheel.windows]
skip = "pp*"

[tool.pytest.ini_options]
markers = [
"unit_test",
"integration_test"
]
7 changes: 2 additions & 5 deletions tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@
import unittest

import numpy as np
import pytest

import splinepy

__all__ = [
"unittest",
"np",
"splinepy",
]
__all__ = ["unittest", "np", "splinepy", "pytest"]

# abbreviation
# z: bezier
Expand Down
1 change: 1 addition & 0 deletions tests/test_bezier_extraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import common as c


@c.pytest.mark.unit_test
class BezierExtractionTest(c.SplineBasedTestCase):
def test_extraction(self):
"""
Expand Down
1 change: 1 addition & 0 deletions tests/test_c_contiguous.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import common as c


@c.pytest.mark.integration_test
class ContiguousArrayInputTest(c.unittest.TestCase):
def test_c_contiguous_array_input(self):
"""
Expand Down
1 change: 1 addition & 0 deletions tests/test_cartesian.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from itertools import product


@c.pytest.mark.unit_test
class CartesianProductTest(c.unittest.TestCase):
def test_cartesian_product(self):
"""
Expand Down
2 changes: 2 additions & 0 deletions tests/test_composition_sensitivities.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class ComposeSensitivitiesTest(c.SplineBasedTestCase):
deformation function's control points.
"""

@c.pytest.mark.unit_test
def test_composition(self):
# Here we only try 2D compositions (surface-line is tested in bezman)
# Init Splines to be tested
Expand Down Expand Up @@ -72,6 +73,7 @@ def test_splines(outer, inner):
test_splines(surface_rational, inner_polynomial)
test_splines(surface_rational, inner_rational)

@c.pytest.mark.integration_test
def test_composition_sensitivities_on_bsplines(self):
"""Combine Composition sensitivities with BSpline extraction"""

Expand Down
1 change: 1 addition & 0 deletions tests/test_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import common as c


@c.pytest.mark.integration_test
class CreatorTest(c.SplineBasedTestCase):
# Test Extrusion routines
def test_create_extrude(self):
Expand Down
6 changes: 6 additions & 0 deletions tests/test_evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@


class TestSplinepyEvaluation(c.SplineBasedTestCase):
@c.pytest.mark.unit_test
def test_basis_and_support(self):
"""Test the correct calculation of the basis functions.
(.basis_and_support())"""
Expand Down Expand Up @@ -128,6 +129,7 @@ def test_basis_and_support(self):
)
)

@c.pytest.mark.unit_test
def test_jacobian(self):
"""Test the correct evaluation of basis function derivatives"""
# Test both for nurbs as for rational beziers for the integration of a
Expand Down Expand Up @@ -221,6 +223,7 @@ def test_jacobian(self):
).T
self.assertTrue(c.np.allclose(jacs, expected_jacs))

@c.pytest.mark.unit_test
def test_basis_function_derivatives(self):
"""Test the correct evaluation of basis function derivatives"""
# Cross-testing different libraries
Expand Down Expand Up @@ -303,6 +306,7 @@ def test_basis_function_derivatives(self):
)
)

@c.pytest.mark.unit_test
def test_partition_of_unity(self):
"""Test the partition of unity of the calculated basis functions."""

Expand All @@ -319,6 +323,7 @@ def basis_functions_sum(basis_functions):
u_nurbs = basis_functions_sum(self.nurbs.basis_and_support(q2D)[0])
self.assertTrue(c.np.allclose(u_nurbs, c.np.ones(c.np.shape(u_nurbs))))

@c.pytest.mark.unit_test
def test_evaluate(self):
"""Test the correct spline evaluation in the physical space.
(.evaluate())"""
Expand Down Expand Up @@ -375,6 +380,7 @@ def test_evaluate(self):
c.np.allclose(self.rational.evaluate(c.q2D), rational_ref_evaluate)
)

@c.pytest.mark.unit_test
def test_derivative(self):
"""Test the correct calculation of the first derivative.
(.derivative())"""
Expand Down
2 changes: 2 additions & 0 deletions tests/test_extract_boundaries.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@


class extractBoundariesTest(c.unittest.TestCase):
@c.pytest.mark.unit_test
def testExtraction2D(self):
"""Create a Spline, extract boundaries and check validity"""
# uniform
Expand Down Expand Up @@ -44,6 +45,7 @@ def testExtraction2D(self):
list_of_boundaries = bez_el0.extract_boundaries([2])
self.assertTrue(c.are_splines_equal(list_of_boundaries[0], boundary_2))

@c.pytest.mark.unit_test
def testExtraction3D(self):
"""Create a Spline, extract boundaries and check validity"""
# uniform
Expand Down
4 changes: 4 additions & 0 deletions tests/test_fitting.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class TestSplinepyFitting(c.unittest.TestCase):
be used for validation.
"""

@c.pytest.mark.unit_test
def test_interpolate_curve_2d(self):
n_sample = 20
resolution = [3 * n_sample]
Expand Down Expand Up @@ -45,6 +46,7 @@ def f(x):
)
)

@c.pytest.mark.unit_test
def test_approximate_curve_2d(self):
n_sample = 20
resolution = [3 * n_sample]
Expand All @@ -70,6 +72,7 @@ def f(x):
)
)

@c.pytest.mark.unit_test
def test_interpolate_surface_3d(self):
sample_size = [10, 10]
x = [c.np.linspace(-2, 2, n) for n in sample_size]
Expand Down Expand Up @@ -100,6 +103,7 @@ def f(x, y):
)
)

@c.pytest.mark.unit_test
def test_approximate_surface_3d(self):
sample_size = [10, 10]
x = [c.np.linspace(-1, 1, n) for n in sample_size]
Expand Down
1 change: 1 addition & 0 deletions tests/test_gismo.py
Original file line number Diff line number Diff line change
Expand Up @@ -746,6 +746,7 @@
]


@c.pytest.mark.integration_test
class gismoExportTest(c.unittest.TestCase):
def test_gismo_export(self):
"""
Expand Down
1 change: 1 addition & 0 deletions tests/test_greville.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@


class GrevilleAbscissaeTest(c.SplineBasedTestCase):
@c.pytest.mark.integration_test
def test_greville_points(self):
"""
test permute
Expand Down
1 change: 1 addition & 0 deletions tests/test_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import common as c


@c.pytest.mark.integration_test
class jsonExportTest(c.unittest.TestCase):
def test_gismo_import(self):
"""
Expand Down
3 changes: 3 additions & 0 deletions tests/test_kv_manipulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@


class TestSplinepyKnotVectorManipulation(c.SplineBasedTestCase):
@c.pytest.mark.unit_test
def test_insert_knot(self):
"""Test the knot insertion function (.insert_knot())."""

Expand Down Expand Up @@ -69,6 +70,7 @@ def test_insert_knot(self):
)
)

@c.pytest.mark.unit_test
def test_insert_knot_with_matrix(self):
"""Test the knot insertion function (.insert_knot())."""

Expand Down Expand Up @@ -134,6 +136,7 @@ def test_insert_knot_with_matrix(self):
)
)

@c.pytest.mark.unit_test
def test_remove_knot(self):
"""Test the function .remove_knots.
This test also depends on the function .insert_knots!"""
Expand Down
4 changes: 4 additions & 0 deletions tests/test_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def setUp(self) -> None:
self.query_points2D = c.np.random.rand(13, 2)
self.query_points3D = c.np.random.rand(17, 3)

@c.pytest.mark.unit_test
def test_cross_evaluation_of_different_implementations(self):
"""Divergence and Laplacian are implemented differently when gradients
are called at the same time
Expand Down Expand Up @@ -141,6 +142,7 @@ def check_assertions(self):
mapper = self.solution_field_rando.mapper(self.askew_spline2D)
self.assertRaises(mapper.divergence(self.query_points2D))

@c.pytest.mark.unit_test
def test_first_order_derivatives_analytical(self):
mapper2D = self.solution_field_rando.mapper(self.rotating2D)
mapper3D = self.solution_field_mono3D.mapper(self.scaling3D)
Expand Down Expand Up @@ -197,6 +199,7 @@ def test_first_order_derivatives_analytical(self):
)
self.assertTrue(c.np.allclose(bf_gradient, bf_reference))

@c.pytest.mark.unit_test
def test_second_order_analytical(self):
mapper2D = self.solution_field_rando.mapper(self.rotating2D)
bf_hessian, support = mapper2D.basis_hessian_and_support(
Expand Down Expand Up @@ -243,6 +246,7 @@ def test_second_order_analytical(self):
)
self.assertTrue(c.np.allclose(bf_hessian, bf_reference))

@c.pytest.mark.unit_test
def test_second_order_fd(self):
"Use proximity to get points on askew geometry and approcimate hessian"
mapper = self.solution_field_rando2D.mapper(self.askew_spline2D)
Expand Down
1 change: 1 addition & 0 deletions tests/test_mfem_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@
]


@c.pytest.mark.integration_test
class MFEMExportTest(c.unittest.TestCase):
def test_mfem_export(self):
"""
Expand Down
1 change: 1 addition & 0 deletions tests/test_multi_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@


class MultiIndexTest(c.unittest.TestCase):
@c.pytest.mark.unit_test
def test_multi_index(self):
"""
Test MultiIndex using a round trip of np.ravel_multi_index
Expand Down
3 changes: 3 additions & 0 deletions tests/test_multipatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def setUp(self) -> None:

return

@c.pytest.mark.integration_test
def test_interfaces(self):
""" """
# init multipatch with multiple splines
Expand Down Expand Up @@ -76,6 +77,7 @@ def test_interfaces(self):
).all()
)

@c.pytest.mark.unit_test
def test_boundaries(self):
""" """
# init multipatch with multiple splines
Expand Down Expand Up @@ -122,6 +124,7 @@ def west_side(points):
).all()
)

@c.pytest.mark.unit_test
def test_interfaces_and_boundaries(self):
# 2 --- 3 1 --- 0
# | 1 | | 3 |
Expand Down
2 changes: 2 additions & 0 deletions tests/test_normalize_knot_vectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@


class NormalizeKnotVectorsTest(c.SplineBasedTestCase):
@c.pytest.mark.unit_test
def test_bspline_normalize_knot_vectors(self):
""" """
# make "iga book" bspline
Expand All @@ -28,6 +29,7 @@ def test_bspline_normalize_knot_vectors(self):
ref_kv, kv
), f"{i}. para dim failed to normalize"

@c.pytest.mark.unit_test
def test_nurbs_normalize_knot_vectors(self):
""" """
nurbs = c.nurbs_half_circle_2d()
Expand Down
2 changes: 2 additions & 0 deletions tests/test_order_manipulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@


class TestSplinepyOrderManipulation(c.SplineBasedTestCase):
@c.pytest.mark.unit_test
def test_elevate_degree(self):
"""Test the order elevation function (.elevate_degrees())."""

Expand Down Expand Up @@ -66,6 +67,7 @@ def test_elevate_degree(self):
)
)

@c.pytest.mark.unit_test
def test_reduce_degree(self):
"""Test the function .reduce_degrees.
This test also depends on the function .elevate_degrees!"""
Expand Down
1 change: 1 addition & 0 deletions tests/test_orientation.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class orientationTest(c.unittest.TestCase):
O- 3--2
"""

@c.pytest.mark.integration_test
def test_orientation(self):
# Init Splines to be tested
a_s = c.splinepy.Bezier(
Expand Down
1 change: 1 addition & 0 deletions tests/test_permute_parametric_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@


class PermuteParametricAxesTest(c.SplineBasedTestCase):
@c.pytest.mark.integration_test
def test_permute_parametric_axes(self):
"""
test permute
Expand Down
6 changes: 6 additions & 0 deletions tests/test_property_modification.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@


class InplaceModificationTest(c.unittest.TestCase):
@c.pytest.mark.unit_test
def test_inplace_change_degrees(self):
"""inplace change of degrees should not be allowed if core spline is
initialized"""
Expand All @@ -23,6 +24,7 @@ def test_inplace_change_degrees(self):
with self.assertRaises(ValueError):
spline.degrees += 1

@c.pytest.mark.unit_test
def test_inplace_change_knot_vectors(self):
"""test inplace change of knot_vectors"""
# let's test 3D splines
Expand Down Expand Up @@ -62,6 +64,7 @@ def test_inplace_change_knot_vectors(self):
# evaluation check
assert c.np.allclose(raster_query, s.evaluate(modified_query))

@c.pytest.mark.unit_test
def test_inplace_change_control_points(self):
"""test inplace changes of control points"""
dim = 3
Expand All @@ -86,6 +89,7 @@ def test_inplace_change_control_points(self):
s.control_points /= 2
assert c.np.allclose(orig.sample(res) / 2, s.sample(res))

@c.pytest.mark.unit_test
def test_inplace_change_weights(self):
"""test inplace change of weights by compareing quarter circle"""
n_q_circle = c.n2p2d_quarter_circle()
Expand Down Expand Up @@ -116,6 +120,7 @@ def test_inplace_change_weights(self):


class CoordinateReferencesModificationTest(c.unittest.TestCase):
@c.pytest.mark.unit_test
def test_coordinate_references(self):
dim = 3
res = [3] * dim
Expand Down Expand Up @@ -162,6 +167,7 @@ def test_coordinate_references(self):
)
assert c.np.allclose(s.evaluate(query), ref_eval)

@c.pytest.mark.unit_test
def test_coordinate_references_weight_handling(self):
"""test if coordiante references reflect weights
and handles weight as expected is apply_weight is True."""
Expand Down
1 change: 1 addition & 0 deletions tests/test_proximity.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@


class ProximityTest(c.unittest.TestCase):
@c.pytest.mark.unit_test
def test_queries_inside_spline_initial_guess_with_kdt(self):
"""
Initial guess made with kdt. Mid-point as initial guess tends to fail,
Expand Down
Loading

0 comments on commit 8e95961

Please sign in to comment.