Skip to content

FIX: if the first elements of an array are masked keep checking #14429

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

Merged
merged 2 commits into from
Jun 7, 2019
Merged
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
11 changes: 11 additions & 0 deletions lib/matplotlib/tests/test_units.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,14 @@ def test_jpl_barh_units():
def test_empty_arrays():
# Check that plotting an empty array with a dtype works
plt.scatter(np.array([], dtype='datetime64[ns]'), np.array([]))


def test_scatter_element0_masked():

times = np.arange('2005-02', '2005-03', dtype='datetime64[D]')

y = np.arange(len(times), dtype='float')
y[0] = np.nan
fig, ax = plt.subplots()
ax.scatter(times, y)
fig.canvas.draw()
4 changes: 4 additions & 0 deletions lib/matplotlib/units.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ def _is_natively_supported(x):
if np.iterable(x):
# Assume lists are homogeneous as other functions in unit system.
for thisx in x:
if thisx is ma.masked:
continue
return isinstance(thisx, Number) and not isinstance(thisx, Decimal)
else:
return isinstance(x, Number) and not isinstance(x, Decimal)
Expand Down Expand Up @@ -144,6 +146,8 @@ def is_numlike(x):
"""
if np.iterable(x):
for thisx in x:
if thisx is ma.masked:
continue
return isinstance(thisx, Number)
else:
return isinstance(x, Number)
Expand Down