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

Skip to content

Commit a4d6768

Browse files
committed
Deprecate is_sequence_of_strings; cleanup.
`Axes3D.scatter` no longer flattens a 2D color input.
1 parent 5ca32ab commit a4d6768

File tree

12 files changed

+21
-46
lines changed

12 files changed

+21
-46
lines changed

examples/mplot3d/2dcollections3d.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@
2525
# Fixing random state for reproducibility
2626
np.random.seed(19680801)
2727

28-
x = np.random.sample(20*len(colors))
29-
y = np.random.sample(20*len(colors))
28+
x = np.random.sample(20 * len(colors))
29+
y = np.random.sample(20 * len(colors))
3030
c_list = []
3131
for c in colors:
32-
c_list.append([c]*20)
32+
c_list.extend([c] * 20)
3333
# By using zdir='y', the y value of these points is fixed to the zs value 0
3434
# and the (x,y) points are plotted on the x and z axes.
3535
ax.scatter(x, y, zs=0, zdir='y', c=c_list, label='points in (x,z)')

lib/matplotlib/__init__.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,9 @@
122122
# definitions, so it is safe to import from it here.
123123
from . import cbook
124124
from matplotlib.cbook import (
125-
mplDeprecation,
126-
dedent, get_label,
127-
sanitize_sequence)
125+
mplDeprecation, dedent, get_label, sanitize_sequence)
128126
from matplotlib.compat import subprocess
129-
from matplotlib.rcsetup import (defaultParams,
130-
validate_backend,
131-
cycler)
127+
from matplotlib.rcsetup import defaultParams, validate_backend, cycler
132128

133129
import numpy
134130
from six.moves.urllib.request import urlopen

lib/matplotlib/axes/_axes.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@
1616
from matplotlib import _preprocess_data
1717

1818
import matplotlib.cbook as cbook
19-
from matplotlib.cbook import (mplDeprecation, STEP_LOOKUP_MAP,
20-
iterable,
21-
safe_first_element)
19+
from matplotlib.cbook import (
20+
mplDeprecation, STEP_LOOKUP_MAP, iterable, safe_first_element)
2221
import matplotlib.collections as mcoll
2322
import matplotlib.colors as mcolors
2423
import matplotlib.contour as mcontour

lib/matplotlib/backends/backend_cairo.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ def _fn_name(): return sys._getframe(1).f_code.co_name
3535
try:
3636
import cairo
3737
except ImportError:
38-
raise ImportError("Cairo backend requires that cairocffi or pycairo is installed.")
38+
raise ImportError("Cairo backend requires that cairocffi or pycairo "
39+
"is installed.")
3940
else:
4041
HAS_CAIRO_CFFI = False
4142
else:
@@ -49,8 +50,8 @@ def _fn_name(): return sys._getframe(1).f_code.co_name
4950
backend_version = cairo.version
5051
del _version_required
5152

52-
from matplotlib.backend_bases import RendererBase, GraphicsContextBase,\
53-
FigureManagerBase, FigureCanvasBase
53+
from matplotlib.backend_bases import (
54+
RendererBase, GraphicsContextBase, FigureManagerBase, FigureCanvasBase)
5455
from matplotlib.figure import Figure
5556
from matplotlib.mathtext import MathTextParser
5657
from matplotlib.path import Path

lib/matplotlib/backends/backend_ps.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ def _fn_name(): return sys._getframe(1).f_code.co_name
1515
from tempfile import mkstemp
1616
from matplotlib import verbose, __version__, rcParams, checkdep_ghostscript
1717
from matplotlib.afm import AFM
18-
from matplotlib.backend_bases import RendererBase, GraphicsContextBase,\
19-
FigureManagerBase, FigureCanvasBase
18+
from matplotlib.backend_bases import (RendererBase, GraphicsContextBase,
19+
FigureManagerBase, FigureCanvasBase)
2020

21-
from matplotlib.cbook import get_realpath_and_stat, \
22-
is_writable_file_like, maxdict, file_requires_unicode
21+
from matplotlib.cbook import (get_realpath_and_stat, is_writable_file_like,
22+
maxdict, file_requires_unicode)
2323
from matplotlib.compat.subprocess import subprocess
2424
from matplotlib.figure import Figure
2525

@@ -144,7 +144,7 @@ def _num_to_str(val):
144144
if isinstance(val, six.string_types): return val
145145

146146
ival = int(val)
147-
if val==ival: return str(ival)
147+
if val == ival: return str(ival)
148148

149149
s = "%1.3f"%val
150150
s = s.rstrip("0")

lib/matplotlib/backends/backend_wx.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@
3535
from matplotlib.backend_bases import _has_pil
3636

3737
from matplotlib._pylab_helpers import Gcf
38-
from matplotlib.cbook import ( is_writable_file_like,
39-
warn_deprecated)
38+
from matplotlib.cbook import is_writable_file_like, warn_deprecated
4039
from matplotlib.figure import Figure
4140
from matplotlib.path import Path
4241
from matplotlib.transforms import Affine2D

lib/matplotlib/blocking_input.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727

2828
import six
2929
from matplotlib import verbose
30-
from matplotlib.cbook import is_sequence_of_strings
3130
import matplotlib.lines as mlines
3231

3332
import warnings
@@ -40,8 +39,6 @@ class BlockingInput(object):
4039
"""
4140
def __init__(self, fig, eventslist=()):
4241
self.fig = fig
43-
if not is_sequence_of_strings(eventslist):
44-
raise ValueError("Requires a sequence of event name strings")
4542
self.eventslist = eventslist
4643

4744
def on_event(self, event):

lib/matplotlib/cbook/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,7 @@ def is_string_like(obj):
501501
return isinstance(obj, (six.string_types, np.str_, np.unicode_))
502502

503503

504+
@deprecated('2.1')
504505
def is_sequence_of_strings(obj):
505506
"""Returns true if *obj* is iterable and contains strings"""
506507
if not iterable(obj):

lib/matplotlib/lines.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
from . import artist, colors as mcolors, docstring, rcParams
1717
from .artist import Artist, allow_rasterization
1818
from .cbook import (
19-
iterable, is_numlike, ls_mapper, ls_mapper_r, is_hashable,
20-
STEP_LOOKUP_MAP)
19+
iterable, is_numlike, ls_mapper, ls_mapper_r, is_hashable, STEP_LOOKUP_MAP)
2120
from .markers import MarkerStyle
2221
from .path import Path
2322
from .transforms import Bbox, TransformedPath, IdentityTransform

lib/matplotlib/mathtext.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@
4444
ParserElement.enablePackrat()
4545

4646
from matplotlib.afm import AFM
47-
from matplotlib.cbook import (Bunch, get_realpath_and_stat,
48-
maxdict)
47+
from matplotlib.cbook import Bunch, get_realpath_and_stat, maxdict
4948
from matplotlib.ft2font import (FT2Image, KERNING_DEFAULT, LOAD_FORCE_AUTOHINT,
5049
LOAD_NO_HINTING)
5150
from matplotlib.font_manager import findfont, FontProperties, get_font

lib/matplotlib/tests/test_cbook.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,6 @@
1919
from matplotlib.cbook import delete_masked_points as dmp
2020

2121

22-
def test_is_sequence_of_strings():
23-
y = ['a', 'b', 'c']
24-
assert cbook.is_sequence_of_strings(y)
25-
26-
y = np.array(y, dtype=object)
27-
assert cbook.is_sequence_of_strings(y)
28-
29-
3022
def test_is_hashable():
3123
s = 'string'
3224
assert cbook.is_hashable(s)

lib/mpl_toolkits/mplot3d/axes3d.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2341,15 +2341,7 @@ def scatter(self, xs, ys, zs=0, zdir='z', s=20, c=None, depthshade=True,
23412341

23422342
s = np.ma.ravel(s) # This doesn't have to match x, y in size.
23432343

2344-
if c is not None:
2345-
cstr = isinstance(c, six.string_types) or cbook.is_sequence_of_strings(c)
2346-
if not cstr:
2347-
c = np.asanyarray(c)
2348-
if c.size == xs.size:
2349-
c = np.ma.ravel(c)
2350-
xs, ys, zs, s, c = cbook.delete_masked_points(xs, ys, zs, s, c)
2351-
else:
2352-
xs, ys, zs, s = cbook.delete_masked_points(xs, ys, zs, s)
2344+
xs, ys, zs, s, c = cbook.delete_masked_points(xs, ys, zs, s, c)
23532345

23542346
patches = Axes.scatter(self, xs, ys, s=s, c=c, *args, **kwargs)
23552347
if not cbook.iterable(zs):

0 commit comments

Comments
 (0)