Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b12b7b0

Browse files
committed
Fix mistyped function method and fix stub
1 parent af5946b commit b12b7b0

File tree

2 files changed

+39
-35
lines changed

2 files changed

+39
-35
lines changed

lib/matplotlib/transforms.py

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -81,40 +81,6 @@ def strrepr(x): return repr(x) if isinstance(x, str) else str(x)
8181
+ ")")
8282

8383

84-
def matrix_transform(vertices, mtx):
85-
"""
86-
Transforms a vertex or set of vertices with a matrix mtx of
87-
one dimension higher.
88-
89-
Parameters
90-
----------
91-
vertices : n-element array or (m, n) array, with m vertices
92-
mtx : (n+1, n+1) matrix
93-
"""
94-
values = np.asanyarray(vertices)
95-
_, input_dims = mtx.shape
96-
input_dims = input_dims - 1
97-
98-
if (len(values.shape) == 1):
99-
# single point
100-
if (values.shape == (input_dims,)):
101-
point = mtx.dot(np.append(values, [1]))
102-
point = point/point[-1]
103-
return point[:input_dims]
104-
raise RuntimeError("Invalid vertices provided to transform")
105-
106-
# multiple points
107-
if (len(values.shape) == 2 and values.shape[1] == input_dims):
108-
points = np.hstack((values, np.ones((values.shape[0], 1))))
109-
points = np.dot(mtx, points.T).T
110-
last_coords = points[:, -1]
111-
points = points / last_coords[:, np.newaxis]
112-
return points[:, :-1]
113-
114-
raise ValueError("Dimensions of input must match the input dimensions of "
115-
"the transform")
116-
117-
11884
class TransformNode:
11985
"""
12086
The base class for anything that participates in the transform tree
@@ -2361,7 +2327,7 @@ def rotate_around_vector(self, vector, theta):
23612327
np.matmul(rot, self._mtx, out=self._mtx)
23622328
return self
23632329

2364-
def rotate_around_vector_deg(self, vector, degrees):
2330+
def rotate_deg_around_vector(self, vector, degrees):
23652331
"""
23662332
Add a rotation (in radians) around the vector (vx, vy, vz) in place.
23672333
@@ -3377,3 +3343,37 @@ def offset_copy(trans, fig=None, x=0.0, y=0.0, units='inches'):
33773343
y /= 72.0
33783344
# Default units are 'inches'
33793345
return trans + ScaledTranslation(x, y, fig.dpi_scale_trans)
3346+
3347+
3348+
def matrix_transform(vertices, mtx):
3349+
"""
3350+
Transforms a vertex or set of vertices with a matrix mtx of
3351+
one dimension higher.
3352+
3353+
Parameters
3354+
----------
3355+
vertices : n-element array or (m, n) array, with m vertices
3356+
mtx : (n+1, n+1) matrix
3357+
"""
3358+
values = np.asanyarray(vertices)
3359+
_, input_dims = mtx.shape
3360+
input_dims = input_dims - 1
3361+
3362+
if (len(values.shape) == 1):
3363+
# single point
3364+
if (values.shape == (input_dims,)):
3365+
point = mtx.dot(np.append(values, [1]))
3366+
point = point/point[-1]
3367+
return point[:input_dims]
3368+
raise RuntimeError("Invalid vertices provided to transform")
3369+
3370+
# multiple points
3371+
if (len(values.shape) == 2 and values.shape[1] == input_dims):
3372+
points = np.hstack((values, np.ones((values.shape[0], 1))))
3373+
points = np.dot(mtx, points.T).T
3374+
last_coords = points[:, -1]
3375+
points = points / last_coords[:, np.newaxis]
3376+
return points[:, :-1]
3377+
3378+
raise ValueError("Dimensions of input must match the input dimensions of "
3379+
"the transform")

lib/matplotlib/transforms.pyi

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,3 +364,7 @@ def offset_copy(
364364
y: float = ...,
365365
units: Literal["inches", "points", "dots"] = ...,
366366
) -> Transform: ...
367+
def matrix_transform(
368+
vertices: ArrayLike,
369+
mtx: ArrayLike
370+
) -> ArrayLike: ...

0 commit comments

Comments
 (0)