(torus_surf, lam, penalty)
| 551 | @mark.parametrize("lam", [0.0, 1e-6]) |
| 552 | @mark.parametrize("penalty", [3]) |
| 553 | def test_constrainedApproximate2D(torus_surf, lam, penalty): |
| 554 | |
| 555 | # sample the surface |
| 556 | us_ = np.linspace(0, 1, endpoint=False) |
| 557 | vs_ = np.linspace(0, 1, endpoint=False) |
| 558 | |
| 559 | pts = np.stack([torus_surf(u, v) for v in vs_ for u in us_]).squeeze() |
| 560 | |
| 561 | us = us_[None, :].repeat(len(vs_), 0).ravel() |
| 562 | vs = vs_[:, None].repeat(len(us_), 1).ravel() |
| 563 | |
| 564 | # add some noise to make the problem non-trivial |
| 565 | pts += np.random.randn(*pts.shape) / 100 |
| 566 | |
| 567 | surf = approximate2D( |
| 568 | pts, |
| 569 | us, |
| 570 | vs, |
| 571 | 3, |
| 572 | 3, |
| 573 | 10, |
| 574 | 10, |
| 575 | uperiodic=True, |
| 576 | vperiodic=True, |
| 577 | penalty=penalty, |
| 578 | lam=lam, |
| 579 | ) |
| 580 | |
| 581 | isou = surf.isoline(0.0, "u") |
| 582 | isov = surf.isoline(0.0, "v") |
| 583 | |
| 584 | # check that the constraints will do something |
| 585 | assert not np.allclose(isou.pts[:, 1], 0) |
| 586 | assert not np.allclose(isov.pts[:, 2], 0) |
| 587 | |
| 588 | # # constraints per direction |
| 589 | Au = uIsoMatrix(surf, 0.0) |
| 590 | Av = vIsoMatrix(surf, 0.0) |
| 591 | by = np.zeros(Au.shape[0]) |
| 592 | bz = np.zeros(Av.shape[0]) |
| 593 | |
| 594 | surf = constrainedApproximate2D( |
| 595 | (None, Au, Av), |
| 596 | (None, by, bz), |
| 597 | pts, |
| 598 | us, |
| 599 | vs, |
| 600 | 3, |
| 601 | 3, |
| 602 | len(surf.uknots), |
| 603 | len(surf.vknots), |
| 604 | uperiodic=True, |
| 605 | vperiodic=True, |
| 606 | penalty=penalty, |
| 607 | lam=lam, |
| 608 | ) |
| 609 | |
| 610 | isou = surf.isoline(0.0, "u") |
nothing calls this directly
no test coverage detected