8000 Faster array creation for transforms.update_from_data_x and transform… · matplotlib/matplotlib@042d068 · GitHub
[go: up one dir, main page]

Skip to content

Commit 042d068

Browse files
Faster array creation for transforms.update_from_data_x and transforms.update_from_data_y
tweak
1 parent dc37bf1 commit 042d068

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lib/matplotlib/transforms.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -896,8 +896,9 @@ def update_from_data_x(self, x, ignore=None):
896896
- When ``None``, use the last value passed to :meth:`ignore`.
897897
"""
898898
x = np.ravel(x)
899-
self.update_from_data_xy(np.column_stack([x, np.ones(x.size)]),
900-
ignore=ignore, updatey=False)
899+
xy = np.empty((x.size, 2), dtype=x.dtype)
900+
xy[:, 0] = x
901+
self.update_from_data_xy(xy, ignore=ignore, updatey=False)
901902

902903
def update_from_data_y(self, y, ignore=None):
903904
"""
@@ -915,8 +916,9 @@ def update_from_data_y(self, y, ignore=None):
915916
- When ``None``, use the last value passed to :meth:`ignore`.
916917
"""
917918
y = np.ravel(y)
918-
self.update_from_data_xy(np.column_stack([np.ones(y.size), y]),
919-
ignore=ignore, updatex=False)
919+
xy = np.empty((y.size, 2), dtype=y.dtype)
920+
xy[:, 1] = y
921+
self.update_from_data_xy(xy, ignore=ignore, updatex=False)
920922

921923
def update_from_data_xy(self, xy, ignore=None, updatex=True, updatey=True):
922924
"""

0 commit comments

Comments
 (0)
0