MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / check_continuity

Function check_continuity

lib/matplotlib/tests/test_triangulation.py:538–566  ·  view source on GitHub ↗

Checks the continuity of interpolator (and its derivatives) near location loc. Can check the value at loc itself if *values* is provided. *interpolator* TriInterpolator *loc* location to test (x0, y0) *values* (optional) array [z0, dzx0, dzy0] to che

(interpolator, loc, values=None)

Source from the content-addressed store, hash-verified

536
537 # Utility test function check_continuity
538 def check_continuity(interpolator, loc, values=None):
539 """
540 Checks the continuity of interpolator (and its derivatives) near
541 location loc. Can check the value at loc itself if *values* is
542 provided.
543
544 *interpolator* TriInterpolator
545 *loc* location to test (x0, y0)
546 *values* (optional) array [z0, dzx0, dzy0] to check the value at *loc*
547 """
548 n_star = 24 # Number of continuity points in a boundary of loc
549 epsilon = 1.e-10 # Distance for loc boundary
550 k = 100. # Continuity coefficient
551 (loc_x, loc_y) = loc
552 star_x = loc_x + epsilon*np.cos(np.linspace(0., 2*np.pi, n_star))
553 star_y = loc_y + epsilon*np.sin(np.linspace(0., 2*np.pi, n_star))
554 z = interpolator([loc_x], [loc_y])[0]
555 (dzx, dzy) = interpolator.gradient([loc_x], [loc_y])
556 if values is not None:
557 assert_array_almost_equal(z, values[0])
558 assert_array_almost_equal(dzx[0], values[1])
559 assert_array_almost_equal(dzy[0], values[2])
560 diff_z = interpolator(star_x, star_y) - z
561 (tab_dzx, tab_dzy) = interpolator.gradient(star_x, star_y)
562 diff_dzx = tab_dzx - dzx
563 diff_dzy = tab_dzy - dzy
564 assert_array_less(diff_z, epsilon*k)
565 assert_array_less(diff_dzx, epsilon*k)
566 assert_array_less(diff_dzy, epsilon*k)
567
568 # Drawing arbitrary triangle (a, b, c) inside a unit square.
569 (ax, ay) = (0.2, 0.3)

Callers 1

Calls 1

gradientMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…