Skip to content

Commit a62cead

Browse files
authored
Merge pull request #11564 from anntzer/cleantri
triinterpolate cleanups.
2 parents 4100e90 + 1039c71 commit a62cead

File tree

1 file changed

+9
-24
lines changed

1 file changed

+9
-24
lines changed

lib/matplotlib/tri/triinterpolate.py

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def __init__(self, triangulation, z, trifinder=None):
8282
8383
"""
8484

85-
_docstringgradient = """
85+
_docstringgradient = r"""
8686
Returns a list of 2 masked arrays containing interpolated derivatives
8787
at the specified x,y points.
8888
@@ -99,8 +99,8 @@ def __init__(self, triangulation, z, trifinder=None):
9999
corresponding to (x,y) points outside of the triangulation
100100
are masked out.
101101
The first returned array contains the values of
102-
:math:`\\frac{\\partial z}{\\partial x}` and the second those of
103-
:math:`\\frac{\\partial z}{\\partial y}`.
102+
:math:`\frac{\partial z}{\partial x}` and the second those of
103+
:math:`\frac{\partial z}{\partial y}`.
104104
105105
"""
106106

@@ -292,7 +292,7 @@ def _interpolate_single_key(self, return_key, tri_index, x, y):
292292

293293

294294
class CubicTriInterpolator(TriInterpolator):
295-
"""
295+
r"""
296296
A CubicTriInterpolator performs cubic interpolation on triangular grids.
297297
298298
In one-dimension - on a segment - a cubic interpolating function is
@@ -367,11 +367,11 @@ class CubicTriInterpolator(TriInterpolator):
367367
368368
.. math::
369369
370-
E(z) = \\ \\frac{1}{2} \\int_{\\Omega} \\left(
371-
\\left( \\frac{\\partial^2{z}}{\\partial{x}^2} \\right)^2 +
372-
\\left( \\frac{\\partial^2{z}}{\\partial{y}^2} \\right)^2 +
373-
2\\left( \\frac{\\partial^2{z}}{\\partial{y}\\partial{x}}
374-
\\right)^2 \\right) dx\\,dy
370+
E(z) = \frac{1}{2} \int_{\Omega} \left(
371+
\left( \frac{\partial^2{z}}{\partial{x}^2} \right)^2 +
372+
\left( \frac{\partial^2{z}}{\partial{y}^2} \right)^2 +
373+
2\left( \frac{\partial^2{z}}{\partial{y}\partial{x}} \right)^2
374+
\right) dx\,dy
375375
376376
If the case *kind* ='geom' is chosen by the user, a simple geometric
377377
approximation is used (weighted average of the triangle normal
@@ -1376,7 +1376,6 @@ def _cg(A, b, x0=None, tol=1.e-10, maxiter=1000):
13761376

13771377

13781378
# The following private functions:
1379-
# :func:`_inv22_vectorized`
13801379
# :func:`_safe_inv22_vectorized`
13811380
# :func:`_pseudo_inv22sym_vectorized`
13821381
# :func:`_prod_vectorized`
@@ -1387,20 +1386,6 @@ def _cg(A, b, x0=None, tol=1.e-10, maxiter=1000):
13871386
# :func:`_extract_submatrices`
13881387
# provide fast numpy implementation of some standard operations on arrays of
13891388
# matrices - stored as (:, n_rows, n_cols)-shaped np.arrays.
1390-
def _inv22_vectorized(M):
1391-
"""
1392-
Inversion of arrays of (2,2) matrices.
1393-
"""
1394-
assert (M.ndim == 3)
1395-
assert (M.shape[-2:] == (2, 2))
1396-
M_inv = np.empty_like(M)
1397-
delta_inv = np.reciprocal(M[:, 0, 0]*M[:, 1, 1] - M[:, 0, 1]*M[:, 1, 0])
1398-
M_inv[:, 0, 0] = M[:, 1, 1]*delta_inv
1399-
M_inv[:, 0, 1] = -M[:, 0, 1]*delta_inv
1400-
M_inv[:, 1, 0] = -M[:, 1, 0]*delta_inv
1401-
M_inv[:, 1, 1] = M[:, 0, 0]*delta_inv
1402-
return M_inv
1403-
14041389

14051390
# Development note: Dealing with pathologic 'flat' triangles in the
14061391
# CubicTriInterpolator code and impact on (2,2)-matrix inversion functions

0 commit comments

Comments
 (0)