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

Skip to content

Path fast verts bug fix #4008

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/matplotlib/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def _fast_from_codes_and_verts(cls, verts, codes, internals=None):
Parameters
----------
verts : numpy array
codes : numpy array (may not be None)
codes : numpy array
internals : dict or None
The attributes that the resulting path should have.
Allowed keys are ``readonly``, ``should_simplify``,
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion lib/matplotlib/tests/test_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3473,18 +3473,21 @@ def test_pathological_hexbin():
fig.savefig(out)
assert_equal(len(w), 0)


@cleanup
def test_color_None():
# issue 3855
fig, ax = plt.subplots()
ax.plot([1,2], [1,2], color=None)
ax.plot([1, 2], [1, 2], color=None)
plt.show()


@cleanup
def test_numerical_hist_label():
fig, ax = plt.subplots()
ax.hist([range(15)] * 5, label=range(5))


if __name__ == '__main__':
import nose
import sys
Expand Down
11 changes: 11 additions & 0 deletions lib/matplotlib/tests/test_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,17 @@ def test_point_in_path_nan():
assert not contains[0]


@image_comparison(baseline_images=['semi_log_with_zero'], extensions=['png'])
def test_log_transform_with_zero():
x = np.arange(-10, 10)
y = (1.0 - 1.0/(x**2+1))**20

fig, ax = plt.subplots()
ax.semilogy(x, y, "-o", lw=15)
ax.grid(True)
plt.show()


if __name__ == '__main__':
import nose
nose.runmodule(argv=['-s', '--with-doctest'], exit=False)
31 changes: 22 additions & 9 deletions lib/matplotlib/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -1300,7 +1300,7 @@ def transform(self, values):

# Convert the result back to the shape of the input values.
if ndim == 0:
assert not np.ma.is_masked(res) # just to be on the safe side
assert not np.ma.is_masked(res) # just to be on the safe side
return res[0, 0]
if ndim == 1:
return res.reshape(-1)
Expand Down Expand Up @@ -1412,6 +1412,8 @@ def transform_path_non_affine(self, path):
``transform_path_affine(transform_path_non_affine(values))``.
"""
x = self.transform_non_affine(path.vertices)
if ma.isMaskedArray(x):
x = x.astype(np.float_).filled(np.nan)
return Path._fast_from_codes_and_verts(x, path.codes,
{'interpolation_steps': path._interpolation_steps})

Expand Down Expand Up @@ -2613,14 +2615,25 @@ def __init__(self, path, transform):
self._transformed_points = None

def _revalidate(self):
# only recompute if the invalidation includes the non_affine part of the transform
if ((self._invalid & self.INVALID_NON_AFFINE == self.INVALID_NON_AFFINE)
or self._transformed_path is None):
self._transformed_path = \
self._transform.transform_path_non_affine(self._path)
self._transformed_points = \
Path._fast_from_codes_and_verts(self._transform.transform_non_affine(self._path.vertices),
None, {'interpolation_steps': self._path._interpolation_steps})
# only recompute if the invalidation includes
# the non_affine part of the transform
if ((self._invalid &
self.INVALID_NON_AFFINE == self.INVALID_NON_AFFINE)
or self._transformed_path is None):

tpath = self._transform.transform_path_non_affine(self._path)
self._transformed_path = tpath

x = self._transform.transform_non_affine(self._path.vertices)
if ma.isMaskedArray(x):
x = x.astype(np.float_).filled(np.nan)

tpts = Path._fast_from_codes_and_verts(verts=x, codes=None,
internals={'interpolation_steps':
self._path._interpolation_steps})

self._transformed_points = tpts

self._invalid = 0

def get_transformed_points_and_affine(self):
Expand Down