(lam, penalty)
| 345 | |
| 346 | @mark.parametrize(("penalty", "lam"), [(3, 1e-6), (4, 1e-6), (5, 1e-6), (2, 0)]) |
| 347 | def test_approximate2D(lam, penalty): |
| 348 | |
| 349 | t = torus(5, 1).face() |
| 350 | |
| 351 | # double periodic surface |
| 352 | us = np.linspace(0, 1, endpoint=False) |
| 353 | vs = np.linspace(0, 1, endpoint=False) |
| 354 | |
| 355 | pts = np.array( |
| 356 | [t.positionAt(u * 2 * np.pi, v * 2 * np.pi).toTuple() for v in vs for u in us] |
| 357 | ) |
| 358 | |
| 359 | surf = approximate2D( |
| 360 | pts, |
| 361 | us[None, :].repeat(len(vs), 0).ravel(), |
| 362 | vs[:, None].repeat(len(us), 1).ravel(), |
| 363 | 3, |
| 364 | 3, |
| 365 | 15, |
| 366 | 15, |
| 367 | uperiodic=True, |
| 368 | vperiodic=True, |
| 369 | penalty=penalty, |
| 370 | lam=lam, |
| 371 | ) |
| 372 | |
| 373 | f = surf.face() |
| 374 | |
| 375 | # general sanity checks |
| 376 | assert f.isValid() |
| 377 | assert f.Area() == approx(t.Area(), rel=1e-3) |
| 378 | |
| 379 | # check the stability of the parameters |
| 380 | us0 = us[None, :].repeat(len(vs), 0).ravel() |
| 381 | vs0 = vs[:, None].repeat(len(us), 1).ravel() |
| 382 | |
| 383 | us2, vs2 = f.params(array2vec(pts)) |
| 384 | |
| 385 | delta_u = np.array(us2 - us0) |
| 386 | delta_v = np.array(vs2 - vs0) |
| 387 | |
| 388 | assert np.allclose(np.where(delta_u >= 1, delta_u, 0) % 1, 0) |
| 389 | assert np.allclose(np.where(delta_v >= 1, delta_v, 0) % 1, 0) |
| 390 | |
| 391 | |
| 392 | EDGES = ( |
nothing calls this directly
no test coverage detected