| 246 | |
| 247 | |
| 248 | def 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)]) |