Skip to content

Commit

Permalink
Update new tests case after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
deltaLuki committed Jun 28, 2023
1 parent 8ad1bf7 commit 8209f01
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 17 deletions.
8 changes: 4 additions & 4 deletions tests/test_bezier_extraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import common as c


class BezierExtractionTest(c.unittest.TestCase):
class BezierExtractionTest(c.SplineBasedTestCase):
def test_extraction(self):
"""
test the extraction of beziers
Expand Down Expand Up @@ -45,7 +45,7 @@ def test_extraction(self):
def test_extraction_matrice_bspline_3D(self):
"""Create matrices to extract splines"""
# Init b-splines
bspline = c.splinepy.BSpline(**c.b3P3D)
bspline = self.bspline_3d
bspline.elevate_degrees([0, 1, 2])
bspline.insert_knots(0, c.np.random.rand(3))
bspline.insert_knots(1, c.np.random.rand(3))
Expand All @@ -65,7 +65,7 @@ def test_extraction_matrices_bspline_2D(self):
"""Create matrices to extract splines"""

# Init nurbs
bspline = c.splinepy.BSpline(**c.b2P2D.copy())
bspline = self.bspline
bspline.elevate_degrees([0, 1])
bspline.insert_knots(0, c.np.random.rand(3))
bspline.insert_knots(1, c.np.random.rand(3))
Expand All @@ -82,7 +82,7 @@ def test_extraction_matrices_nurbs_2D(self):
"""Create matrices to extract splines"""

# Init nurbs
nurbs = c.splinepy.NURBS(**c.n2P2D.copy())
nurbs = self.nurbs
nurbs.elevate_degrees([0, 1])
nurbs.insert_knots(0, c.np.random.rand(3))
nurbs.insert_knots(1, c.np.random.rand(3))
Expand Down
4 changes: 2 additions & 2 deletions tests/test_composition_sensitivities.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import common as c


class ComposeSensitivitiesTest(c.unittest.TestCase):
class ComposeSensitivitiesTest(c.SplineBasedTestCase):
"""
Test composition sensitivity, i.e., the derivative concerning the
deformation function's control points.
Expand Down Expand Up @@ -76,7 +76,7 @@ def test_composition_sensitivities_on_bsplines(self):
"""Combine Composition sensitivities with BSpline extraction"""

# Initialize outer functions
bspline = c.splinepy.BSpline(**c.b2P2D)
bspline = self.bspline
inner_function = c.splinepy.Bezier(
degrees=[1, 1],
control_points=[
Expand Down
18 changes: 9 additions & 9 deletions tests/test_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
import common as c


class CreatorTest(c.unittest.TestCase):
class CreatorTest(c.SplineBasedTestCase):
# Test Extrusion routines
def test_create_extrude(self):
"""
Test extrusion for different input types and arguments
"""
# make a couple of 2D splines
bspline = c.splinepy.BSpline(**c.b2p2d())
nurbs = c.splinepy.NURBS(**c.n2p2d())
bezier = c.splinepy.Bezier(**c.z2p2d())
rationalbezier = c.splinepy.RationalBezier(**c.r2p2d())
bspline = self.bspline
nurbs = self.nurbs
bezier = self.bezier
rationalbezier = self.rational

# Expect Failure - not a spline
with self.assertRaises(NotImplementedError):
Expand Down Expand Up @@ -66,10 +66,10 @@ def test_create_revolution(self):
Test revolution routines for different input types and arguments
"""
# make a couple of 2D splines
bspline = c.splinepy.BSpline(**c.b2p2d())
nurbs = c.splinepy.NURBS(**c.n2p2d())
bezier = c.splinepy.Bezier(**c.z2p2d())
rationalbezier = c.splinepy.RationalBezier(**c.r2p2d())
bspline = self.bspline
nurbs = self.nurbs
bezier = self.bezier
rationalbezier = self.rational

# Make some lines
bezier_line = c.splinepy.Bezier(
Expand Down
8 changes: 6 additions & 2 deletions tests/test_spline_type_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,13 @@ def convert_and_compare_samples(spline, conversion_list):
assert type(converted).__qualname__.lower().startswith(convert_to)


class SplineTypeConversionTest(c.unittest.TestCase):
class SplineTypeConversionTest(c.SplineBasedTestCase):
def setUp(self):
self.z, self.r, self.b, self.n = c.all2p2d()
splines = c.get_all_spline_typs_as_list()
self.b = splines[0]
self.n = splines[1]
self.z = splines[2]
self.r = splines[3]

def test_bezier_conversions(self):
test_conversions = ["bezier", "rationalbezier", "bspline", "nurbs"]
Expand Down

0 comments on commit 8209f01

Please sign in to comment.