MCPcopy
hub / github.com/CadQuery/cadquery / test_approximate

Function test_approximate

tests/test_nurbs.py:248–281  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

246
247
248def test_approximate():
249
250 pts_ = circle(1).trim(0, 1).sample(100)[0]
251 pts = np.array([list(p) for p in pts_])
252
253 # regular approximate
254 crv = approximate(pts)
255 e = crv.edge()
256
257 assert e.isValid()
258 assert e.Length() == approx(1)
259
260 # approximate with a double penalty
261 crv = approximate(pts, penalty=4, lam=1e-9)
262 e = crv.edge()
263
264 assert e.isValid()
265 assert e.Length() == approx(1)
266
267 # approximate with a single penalty
268 crv = approximate(pts, penalty=2, lam=1e-9)
269 e = crv.edge()
270
271 assert e.isValid()
272 assert e.Length() == approx(1)
273
274 # multiple approximate
275 crvs = approximate([pts, pts], penalty=2, lam=1e-9)
276
277 for crv in crvs:
278 e = crv.edge()
279
280 assert e.isValid()
281 assert e.Length() == approx(1)
282
283
284@mark.parametrize(("penalty", "lam"), [(3, 1e-9), (4, 1e-9), (5, 1e-9), (2, 0)])

Callers

nothing calls this directly

Calls 7

approximateFunction · 0.90
circleFunction · 0.85
sampleMethod · 0.80
isValidMethod · 0.80
trimMethod · 0.45
edgeMethod · 0.45
LengthMethod · 0.45

Tested by

no test coverage detected