Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jul 7, 2023
1 parent 3a896bc commit da5ebe1
Showing 1 changed file with 32 additions and 40 deletions.
72 changes: 32 additions & 40 deletions tests/test_spline_constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,9 @@ def testBSplines(self):
"""
# No assertion querz
c.splinepy.BSpline(
degrees=[1,1],
knot_vectors=[
[0,0,1,1]
,[0,0,0.4,.5,.7,1,1]
],
control_points=c.np.random.rand(10,2)
degrees=[1, 1],
knot_vectors=[[0, 0, 1, 1], [0, 0, 0.4, 0.5, 0.7, 1, 1]],
control_points=c.np.random.rand(10, 2),
)
# Check control points
self.assertRaisesRegex(
Expand Down Expand Up @@ -51,11 +48,11 @@ def testBSplines(self):
)
self.assertRaisesRegex(
RuntimeError,
"SPLINEPY ERROR - 0.6 0.3 Knots of parametric dimension \( 0 \) "
r"SPLINEPY ERROR - 0.6 0.3 Knots of parametric dimension \( 0 \) "
"are not in increasing order.",
c.splinepy.BSpline,
degrees=[1],
knot_vectors=[[0, 0,.6,.3, 1, 1], [0,0,1,1]],
knot_vectors=[[0, 0, 0.6, 0.3, 1, 1], [0, 0, 1, 1]],
control_points=c.np.ones((8, 2)),
)

Expand All @@ -66,22 +63,20 @@ def testBSplines(self):
"Detected degree -4 along parametric dimension: 1",
c.splinepy.BSpline,
degrees=[-4],
knot_vectors=[[0,0,1,1]],
knot_vectors=[[0, 0, 1, 1]],
control_points=c.np.ones((1, 1)),
)

def testNURBS(self):
"""
Perform checks on BSpline class
"""
# No assertion querz
c.splinepy.NURBS(
degrees=[1,1],
knot_vectors=[
[0,0,1,1]
,[0,0,0.4,.5,.7,1,1]
],
control_points=c.np.random.rand(10,2),
weights=c.np.ones((10))
degrees=[1, 1],
knot_vectors=[[0, 0, 1, 1], [0, 0, 0.4, 0.5, 0.7, 1, 1]],
control_points=c.np.random.rand(10, 2),
weights=c.np.ones(10),
)
# Check control points
self.assertRaisesRegex(
Expand All @@ -92,7 +87,7 @@ def testNURBS(self):
degrees=[1],
knot_vectors=[[0, 0, 1, 1]],
control_points=c.np.ones((9, 3)),
weights=c.np.ones((2))
weights=c.np.ones(2),
)
self.assertRaisesRegex(
RuntimeError,
Expand All @@ -102,7 +97,7 @@ def testNURBS(self):
degrees=[1],
knot_vectors=[[0, 0, 1, 1]],
control_points=c.np.ones((2, 0)),
weights=c.np.ones((2))
weights=c.np.ones(2),
)
# Check knot-vectors
self.assertRaisesRegex(
Expand All @@ -113,17 +108,17 @@ def testNURBS(self):
degrees=[1],
knot_vectors=[[0, 0.5, 1, 1]],
control_points=c.np.ones((2, 1)),
weights=c.np.ones((2))
weights=c.np.ones(2),
)
self.assertRaisesRegex(
RuntimeError,
"SPLINEPY ERROR - 0.6 0.3 Knots of parametric dimension \( 0 \) "
r"SPLINEPY ERROR - 0.6 0.3 Knots of parametric dimension \( 0 \) "
"are not in increasing order.",
c.splinepy.NURBS,
degrees=[1],
knot_vectors=[[0, 0,.6,.3, 1, 1], [0,0,1,1]],
knot_vectors=[[0, 0, 0.6, 0.3, 1, 1], [0, 0, 1, 1]],
control_points=c.np.ones((8, 2)),
weights=c.np.ones((8))
weights=c.np.ones(8),
)

# Check degrees
Expand All @@ -133,26 +128,23 @@ def testNURBS(self):
"Detected degree -4 along parametric dimension: 1",
c.splinepy.NURBS,
degrees=[-4],
knot_vectors=[[0,0,1,1]],
knot_vectors=[[0, 0, 1, 1]],
control_points=c.np.ones((1, 1)),
weights=c.np.ones((1))
weights=c.np.ones(1),
)

# Check weights
self.assertRaisesRegex(
RuntimeError,
"SPLINEPY ERROR - Number of weights \( 19 \) does not match number"
" of control points \( 2 \)",
r"SPLINEPY ERROR - Number of weights \( 19 \) does not match number"
r" of control points \( 2 \)",
c.splinepy.NURBS,
degrees=[1],
knot_vectors=[[0,0,1,1]],
knot_vectors=[[0, 0, 1, 1]],
control_points=c.np.ones((2, 1)),
weights=c.np.ones((19))
weights=c.np.ones(19),
)




def testBezier(self):
"""Feed Bezier constructor with random data and see if the errors are
meaningful"""
Expand Down Expand Up @@ -192,8 +184,8 @@ def testRationalBezier(self):
c.splinepy.RationalBezier(
degrees=[1, 1],
control_points=c.np.ones((4, 1)),
weights=c.np.random.rand(4)
)
weights=c.np.random.rand(4),
)

# Check assertions
self.assertRaisesRegex(
Expand All @@ -203,7 +195,7 @@ def testRationalBezier(self):
c.splinepy.RationalBezier,
degrees=[-4],
control_points=c.np.ones((2, 4)),
weights=c.np.random.rand(0)
weights=c.np.random.rand(0),
)
self.assertRaisesRegex(
RuntimeError,
Expand All @@ -212,7 +204,7 @@ def testRationalBezier(self):
c.splinepy.RationalBezier,
degrees=[2, 2],
control_points=c.np.ones((4, 1)),
weights=c.np.random.rand(0)
weights=c.np.random.rand(0),
)
self.assertRaisesRegex(
RuntimeError,
Expand All @@ -221,7 +213,7 @@ def testRationalBezier(self):
c.splinepy.RationalBezier,
degrees=[2, 3, 1],
control_points=c.np.ones((9, 2)),
weights=c.np.random.rand(0)
weights=c.np.random.rand(0),
)
self.assertRaisesRegex(
RuntimeError,
Expand All @@ -230,16 +222,16 @@ def testRationalBezier(self):
c.splinepy.RationalBezier,
degrees=[2, 3, 1],
control_points=c.np.ones((24, 0)),
weights=c.np.random.rand(9)
weights=c.np.random.rand(9),
)
self.assertRaisesRegex(
RuntimeError,
"SPLINEPY ERROR - Number of weights \( 9 \) does not match number "
"of control points \( 24 \).",
r"SPLINEPY ERROR - Number of weights \( 9 \) does not match number "
r"of control points \( 24 \).",
c.splinepy.RationalBezier,
degrees=[2, 3, 1],
control_points=c.np.ones((24, 2)),
weights=c.np.random.rand(9)
weights=c.np.random.rand(9),
)


Expand Down

0 comments on commit da5ebe1

Please sign in to comment.