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

Skip to content

Commit 283d602

Browse files
committed
ENH splitted the _cbook module in two: the used methods and the unused methods
1 parent 13a4577 commit 283d602

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+1375
-1383
lines changed

lib/matplotlib/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ def _get_configdir():
534534
else:
535535
if not _is_writable_dir(h):
536536
return _create_tmp_config_dir()
537-
from matplotlib._cbook import mkdirs
537+
from matplotlib.utils import mkdirs
538538
mkdirs(p)
539539

540540
return p

lib/matplotlib/animation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import itertools
2222
import contextlib
2323
import subprocess
24-
from matplotlib._cbook import iterable, is_string_like
24+
from matplotlib.utils import iterable, is_string_like
2525
from matplotlib import verbose
2626
from matplotlib import rcParams
2727

lib/matplotlib/artist.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import re
33
import warnings
44
import matplotlib
5-
import matplotlib._cbook as _cbook
5+
from matplotlib import utils
66
from matplotlib import docstring, rcParams
77
from transforms import Bbox, IdentityTransform, TransformedBbox, \
88
TransformedPath, Transform
@@ -767,7 +767,7 @@ def findobj(self, match=None, include_self=True):
767767
if match is None: # always return True
768768
def matchfunc(x):
769769
return True
770-
elif _cbook.issubclass_safe(match, Artist):
770+
elif utils.issubclass_safe(match, Artist):
771771
def matchfunc(x):
772772
return isinstance(x, match)
773773
elif callable(match):
@@ -804,7 +804,7 @@ def __init__(self, o):
804804
:class:`Artists` are of the same type) and it is your responsibility
805805
to make sure this is so.
806806
"""
807-
if _cbook.iterable(o) and len(o):
807+
if utils.iterable(o) and len(o):
808808
o = o[0]
809809

810810
self.oorig = o
@@ -1211,10 +1211,10 @@ def setp(obj, *args, **kwargs):
12111211
print(insp.pprint_setters(prop=args[0]))
12121212
return
12131213

1214-
if not _cbook.iterable(obj):
1214+
if not utils.iterable(obj):
12151215
objs = [obj]
12161216
else:
1217-
objs = _cbook.flatten(obj)
1217+
objs = utils.flatten(obj)
12181218

12191219
if len(args) % 2:
12201220
raise ValueError('The set args must be string, value pairs')
@@ -1231,7 +1231,7 @@ def setp(obj, *args, **kwargs):
12311231
funcName = "set_%s" % s
12321232
func = getattr(o, funcName)
12331233
ret.extend([func(val)])
1234-
return [x for x in _cbook.flatten(ret)]
1234+
return [x for x in utils.flatten(ret)]
12351235

12361236

12371237
def kwdoc(a):

lib/matplotlib/axes.py

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import matplotlib.artist as martist
1414
from matplotlib.artist import allow_rasterization
1515
import matplotlib.axis as maxis
16-
import matplotlib._cbook as _cbook
16+
import matplotlib.utils as utils
1717
import matplotlib.collections as mcoll
1818
import matplotlib.colors as mcolors
1919
import matplotlib.contour as mcontour
@@ -40,9 +40,9 @@
4040
from matplotlib import MatplotlibDeprecationWarning as mplDeprecation
4141
from matplotlib.container import BarContainer, ErrorbarContainer, StemContainer
4242

43-
iterable = _cbook.iterable
44-
is_string_like = _cbook.is_string_like
45-
is_sequence_of_strings = _cbook.is_sequence_of_strings
43+
iterable = utils.iterable
44+
is_string_like = utils.is_string_like
45+
is_sequence_of_strings = utils.is_sequence_of_strings
4646

4747

4848
def _string_to_bool(s):
@@ -345,8 +345,8 @@ class Axes(martist.Artist):
345345
"""
346346
name = "rectilinear"
347347

348-
_shared_x_axes = _cbook.Grouper()
349-
_shared_y_axes = _cbook.Grouper()
348+
_shared_x_axes = utils.Grouper()
349+
_shared_y_axes = utils.Grouper()
350350

351351
def __str__(self):
352352
return "Axes(%g,%g;%gx%g)" % tuple(self._position.bounds)
@@ -849,7 +849,7 @@ def cla(self):
849849
spine.cla()
850850

851851
self.ignore_existing_data_limits = True
852-
self.callbacks = _cbook.CallbackRegistry()
852+
self.callbacks = utils.CallbackRegistry()
853853

854854
if self._sharex is not None:
855855
# major and minor are class instances with
@@ -1381,24 +1381,24 @@ def get_legend(self):
13811381

13821382
def get_images(self):
13831383
"""return a list of Axes images contained by the Axes"""
1384-
return _cbook.silent_list('AxesImage', self.images)
1384+
return utils.silent_list('AxesImage', self.images)
13851385

13861386
def get_lines(self):
13871387
"""Return a list of lines contained by the Axes"""
1388-
return _cbook.silent_list('Line2D', self.lines)
1388+
return utils.silent_list('Line2D', self.lines)
13891389

13901390
def get_xaxis(self):
13911391
"""Return the XAxis instance"""
13921392
return self.xaxis
13931393

13941394
def get_xgridlines(self):
13951395
"""Get the x grid lines as a list of Line2D instances"""
1396-
return _cbook.silent_list('Line2D xgridline',
1397-
self.xaxis.get_gridlines())
1396+
return utils.silent_list('Line2D xgridline',
1397+
self.xaxis.get_gridlines())
13981398

13991399
def get_xticklines(self):
14001400
"""Get the xtick lines as a list of Line2D instances"""
1401-
return _cbook.silent_list('Text xtickline',
1401+
return utils.silent_list('Text xtickline',
14021402
self.xaxis.get_ticklines())
14031403

14041404
def get_yaxis(self):
@@ -1407,12 +1407,12 @@ def get_yaxis(self):
14071407

14081408
def get_ygridlines(self):
14091409
"""Get the y grid lines as a list of Line2D instances"""
1410-
return _cbook.silent_list('Line2D ygridline',
1410+
return utils.silent_list('Line2D ygridline',
14111411
self.yaxis.get_gridlines())
14121412

14131413
def get_yticklines(self):
14141414
"""Get the ytick lines as a list of Line2D instances"""
1415-
return _cbook.silent_list('Line2D ytickline',
1415+
return utils.silent_list('Line2D ytickline',
14161416
self.yaxis.get_ticklines())
14171417

14181418
#### Adding and tracking artists
@@ -2593,23 +2593,23 @@ def get_xmajorticklabels(self):
25932593
Get the xtick labels as a list of :class:`~matplotlib.text.Text`
25942594
instances.
25952595
"""
2596-
return _cbook.silent_list('Text xticklabel',
2596+
return utils.silent_list('Text xticklabel',
25972597
self.xaxis.get_majorticklabels())
25982598

25992599
def get_xminorticklabels(self):
26002600
"""
26012601
Get the x minor tick labels as a list of
26022602
:class:`matplotlib.text.Text` instances.
26032603
"""
2604-
return _cbook.silent_list('Text xticklabel',
2604+
return utils.silent_list('Text xticklabel',
26052605
self.xaxis.get_minorticklabels())
26062606

26072607
def get_xticklabels(self, minor=False):
26082608
"""
26092609
Get the x tick labels as a list of :class:`~matplotlib.text.Text`
26102610
instances.
26112611
"""
2612-
return _cbook.silent_list('Text xticklabel',
2612+
return utils.silent_list('Text xticklabel',
26132613
self.xaxis.get_ticklabels(minor=minor))
26142614

26152615
@docstring.dedent_interpd
@@ -2823,23 +2823,23 @@ def get_ymajorticklabels(self):
28232823
Get the major y tick labels as a list of
28242824
:class:`~matplotlib.text.Text` instances.
28252825
"""
2826-
return _cbook.silent_list('Text yticklabel',
2826+
return utils.silent_list('Text yticklabel',
28272827
self.yaxis.get_majorticklabels())
28282828

28292829
def get_yminorticklabels(self):
28302830
"""
28312831
Get the minor y tick labels as a list of
28322832
:class:`~matplotlib.text.Text` instances.
28332833
"""
2834-
return _cbook.silent_list('Text yticklabel',
2834+
return utils.silent_list('Text yticklabel',
28352835
self.yaxis.get_minorticklabels())
28362836

28372837
def get_yticklabels(self, minor=False):
28382838
"""
28392839
Get the y tick labels as a list of :class:`~matplotlib.text.Text`
28402840
instances
28412841
"""
2842-
return _cbook.silent_list('Text yticklabel',
2842+
return utils.silent_list('Text yticklabel',
28432843
self.yaxis.get_ticklabels(minor=minor))
28442844

28452845
@docstring.dedent_interpd
@@ -2979,7 +2979,7 @@ def start_pan(self, x, y, button):
29792979
Intended to be overridden by new projection types.
29802980
29812981
"""
2982-
self._pan_start = _cbook.Bunch(
2982+
self._pan_start = utils.Bunch(
29832983
lim=self.viewLim.frozen(),
29842984
trans=self.transData.frozen(),
29852985
trans_inverse=self.transData.inverted().frozen(),
@@ -4585,7 +4585,7 @@ def legend(self, *args, **kwargs):
45854585
raise TypeError('Invalid arguments to legend')
45864586

45874587
# Why do we need to call "flatten" here? -JJL
4588-
# handles = _cbook.flatten(handles)
4588+
# handles = utils.flatten(handles)
45894589

45904590
self.legend_ = mlegend.Legend(self, handles, labels, **kwargs)
45914591
return self.legend_
@@ -5226,7 +5226,7 @@ def pie(self, x, explode=None, labels=None, colors=None,
52265226
autotexts = []
52275227

52285228
i = 0
5229-
for frac, label, expl in _cbook.safezip(x, labels, explode):
5229+
for frac, label, expl in utils.safezip(x, labels, explode):
52305230
x, y = center
52315231
theta2 = theta1 + frac
52325232
thetam = 2 * math.pi * 0.5 * (theta1 + theta2)
@@ -5508,15 +5508,15 @@ def xywhere(xs, ys, mask):
55085508
iterable(xerr[0]) and iterable(xerr[1])):
55095509
# using list comps rather than arrays to preserve units
55105510
left = [thisx - thiserr for (thisx, thiserr)
5511-
in _cbook.safezip(x, xerr[0])]
5511+
in utils.safezip(x, xerr[0])]
55125512
right = [thisx + thiserr for (thisx, thiserr)
5513-
in _cbook.safezip(x, xerr[1])]
5513+
in utils.safezip(x, xerr[1])]
55145514
else:
55155515
# using list comps rather than arrays to preserve units
55165516
left = [thisx - thiserr for (thisx, thiserr)
5517-
in _cbook.safezip(x, xerr)]
5517+
in utils.safezip(x, xerr)]
55185518
right = [thisx + thiserr for (thisx, thiserr)
5519-
in _cbook.safezip(x, xerr)]
5519+
in utils.safezip(x, xerr)]
55205520

55215521
yo, _ = xywhere(y, right, everymask)
55225522
lo, ro = xywhere(left, right, everymask)
@@ -5556,15 +5556,15 @@ def xywhere(xs, ys, mask):
55565556
iterable(yerr[0]) and iterable(yerr[1])):
55575557
# using list comps rather than arrays to preserve units
55585558
lower = [thisy - thiserr for (thisy, thiserr)
5559-
in _cbook.safezip(y, yerr[0])]
5559+
in utils.safezip(y, yerr[0])]
55605560
upper = [thisy + thiserr for (thisy, thiserr)
5561-
in _cbook.safezip(y, yerr[1])]
5561+
in utils.safezip(y, yerr[1])]
55625562
else:
55635563
# using list comps rather than arrays to preserve units
55645564
lower = [thisy - thiserr for (thisy, thiserr)
5565-
in _cbook.safezip(y, yerr)]
5565+
in utils.safezip(y, yerr)]
55665566
upper = [thisy + thiserr for (thisy, thiserr)
5567-
in _cbook.safezip(y, yerr)]
5567+
in utils.safezip(y, yerr)]
55685568

55695569
xo, _ = xywhere(x, lower, everymask)
55705570
lo, uo = xywhere(lower, upper, everymask)
@@ -6084,7 +6084,7 @@ def scatter(self, x, y, s=20, c='b', marker='o', cmap=None, norm=None,
60846084
if c.size == x.size:
60856085
c = np.ma.ravel(c)
60866086

6087-
x, y, s, c = _cbook.delete_masked_points(x, y, s, c)
6087+
x, y, s, c = utils.delete_masked_points(x, y, s, c)
60886088

60896089
scales = s # Renamed for readability below.
60906090

@@ -6300,7 +6300,7 @@ def hexbin(self, x, y, C=None, gridsize=100, bins=None,
63006300

63016301
self._process_unit_info(xdata=x, ydata=y, kwargs=kwargs)
63026302

6303-
x, y, C = _cbook.delete_masked_points(x, y, C)
6303+
x, y, C = utils.delete_masked_points(x, y, C)
63046304

63056305
# Set the size of the hexagon grid
63066306
if iterable(gridsize):
@@ -8112,7 +8112,7 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None,
81128112

81138113
# Check whether bins or range are given explicitly. In that
81148114
# case use those values for autoscaling.
8115-
binsgiven = (_cbook.iterable(bins) or bin_range != None)
8115+
binsgiven = (utils.iterable(bins) or bin_range != None)
81168116

81178117
# If bins are not specified either explicitly or via range,
81188118
# we need to figure out the range required for all datasets,
@@ -8151,7 +8151,7 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None,
81518151

81528152
if cumulative:
81538153
slc = slice(None)
8154-
if _cbook.is_numlike(cumulative) and cumulative < 0:
8154+
if utils.is_numlike(cumulative) and cumulative < 0:
81558155
slc = slice(None, None, -1)
81568156

81578157
if normed:
@@ -8315,9 +8315,9 @@ def hist(self, x, bins=10, range=None, normed=False, weights=None,
83158315
self.autoscale_view()
83168316

83178317
if nx == 1:
8318-
return n[0], bins, _cbook.silent_list('Patch', patches[0])
8318+
return n[0], bins, utils.silent_list('Patch', patches[0])
83198319
else:
8320-
return n, bins, _cbook.silent_list('Lists of Patches', patches)
8320+
return n, bins, utils.silent_list('Lists of Patches', patches)
83218321

83228322
@docstring.dedent_interpd
83238323
def hist2d(self, x, y, bins=10, range=None, normed=False, weights=None,

0 commit comments

Comments
 (0)