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

Skip to content

Commit 9f0e939

Browse files
committed
Tidy up the matplotlib.__init__ documentation.
1 parent 6dd6a75 commit 9f0e939

File tree

3 files changed

+65
-32
lines changed

3 files changed

+65
-32
lines changed
Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,37 @@
11
The top level :mod:`matplotlib` module
22
======================================
33

4-
.. automodule:: matplotlib
5-
:members: rc, rcdefaults, use
6-
:undoc-members:
7-
:show-inheritance:
4+
5+
.. py:currentmodule:: matplotlib
6+
7+
.. autofunction:: use
8+
9+
.. autofunction:: get_backend
10+
11+
.. py:data:: matplotlib.rcParams
12+
13+
An instance of :class:`RcParams` for handling default matplotlib values.
14+
15+
.. autofunction:: rc
16+
17+
.. autofunction::rcdefaults
18+
19+
.. autofunction::rc_file
20+
21+
.. autofunction::rc_context
22+
23+
.. autofunction:: matplotlib_fname
24+
25+
.. autofunction::rc_file_defaults
26+
27+
.. autofunction::interactive
28+
29+
.. autofunction::is_interactive
30+
31+
.. autoclass:: RcParams
32+
33+
.. autofunction:: rc_params
34+
35+
.. autofunction:: rc_params_from_file
36+
37+
.. autoclass:: rc_context

doc/sphinxext/gen_gallery.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,10 @@ def gen_gallery(app, doctree):
151151
fh.close()
152152

153153
for key in app.builder.status_iterator(
154-
iter(thumbnails.keys()), "generating thumbnails... ",
155-
length=len(thumbnails)):
156-
image.thumbnail(key, thumbnails[key], 0.3)
154+
iter(thumbnails.keys()), "generating thumbnails... ",
155+
length=len(thumbnails)):
156+
if out_of_date(key, thumbnails[key]):
157+
image.thumbnail(key, thumbnails[key], 0.3)
157158

158159

159160
def setup(app):

lib/matplotlib/__init__.py

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,7 @@ def _get_configdir():
549549
configdir = os.environ.get('MPLCONFIGDIR')
550550
if configdir is not None:
551551
if not os.path.exists(configdir):
552+
from matplotlib.cbook import mkdirs
552553
mkdirs(configdir)
553554
if not _is_writable_dir(configdir):
554555
return _create_tmp_config_dir()
@@ -631,9 +632,9 @@ def get_example_data(fname):
631632

632633
def get_py2exe_datafiles():
633634
datapath = get_data_path()
634-
head, tail = os.path.split(datapath)
635+
_, tail = os.path.split(datapath)
635636
d = {}
636-
for root, dirs, files in os.walk(datapath):
637+
for root, _, files in os.walk(datapath):
637638
# Need to explicitly remove cocoa_agg files or py2exe complains
638639
# NOTE I dont know why, but do as previous version
639640
if 'Matplotlib.nib' in files:
@@ -647,7 +648,7 @@ def get_py2exe_datafiles():
647648

648649
def matplotlib_fname():
649650
"""
650-
Return the path to the rc file
651+
Return the path to the rc file used by matplotlib.
651652
652653
Search order:
653654
@@ -656,9 +657,7 @@ def matplotlib_fname():
656657
* HOME/.matplotlib/matplotlibrc
657658
* MATPLOTLIBDATA/matplotlibrc
658659
659-
660660
"""
661-
662661
oldname = os.path.join(os.getcwd(), '.matplotlibrc')
663662
if os.path.exists(oldname):
664663
try:
@@ -820,13 +819,14 @@ def find_all(self, pattern):
820819

821820

822821
def rc_params(fail_on_error=False):
823-
'Return the default params updated from the values in the rc file'
824-
822+
"""Return a :class:`matplotlib.RcParams` instance from the
823+
default matplotlib rc file.
824+
"""
825825
fname = matplotlib_fname()
826826
if not os.path.exists(fname):
827827
# this should never happen, default in mpl-data should always be found
828828
message = 'could not find rc file; returning defaults'
829-
ret = RcParams([ (key, default) for key, (default, converter) in \
829+
ret = RcParams([(key, default) for key, (default, _) in \
830830
defaultParams.iteritems() ])
831831
warnings.warn(message)
832832
return ret
@@ -835,29 +835,31 @@ def rc_params(fail_on_error=False):
835835

836836

837837
def rc_params_from_file(fname, fail_on_error=False):
838-
"""Load and return params from fname."""
839-
838+
"""Return a :class:`matplotlib.RcParams` instance from the
839+
contents of the given filename.
840+
"""
840841
cnt = 0
841842
rc_temp = {}
842843
with open(fname) as fd:
843844
for line in fd:
844845
cnt += 1
845-
strippedline = line.split('#',1)[0].strip()
846+
strippedline = line.split('#', 1)[0].strip()
846847
if not strippedline: continue
847-
tup = strippedline.split(':',1)
848-
if len(tup) !=2:
849-
warnings.warn('Illegal line #%d\n\t%s\n\tin file "%s"'%\
848+
tup = strippedline.split(':', 1)
849+
if len(tup) != 2:
850+
warnings.warn('Illegal line #%d\n\t%s\n\tin file "%s"' % \
850851
(cnt, line, fname))
851852
continue
852853
key, val = tup
853854
key = key.strip()
854855
val = val.strip()
855856
if key in rc_temp:
856-
warnings.warn('Duplicate key in file "%s", line #%d'%(fname,cnt))
857+
warnings.warn('Duplicate key in file "%s", line #%d' % \
858+
(fname, cnt))
857859
rc_temp[key] = (val, line, cnt)
858860

859-
ret = RcParams([ (key, default) for key, (default, converter) in \
860-
defaultParams.iteritems() ])
861+
ret = RcParams([(key, default) for key, (default, _) in \
862+
defaultParams.iteritems()])
861863

862864
for key in ('verbose.level', 'verbose.fileo'):
863865
if key in rc_temp:
@@ -1033,20 +1035,20 @@ class rc_context(object):
10331035
10341036
This allows one to do::
10351037
1036-
>>> with mpl.rc_context(fname='screen.rc'):
1037-
... plt.plot(x, a)
1038-
... with mpl.rc_context(fname='print.rc'):
1039-
... plt.plot(x, b)
1040-
... plt.plot(x, c)
1038+
with mpl.rc_context(fname='screen.rc'):
1039+
plt.plot(x, a)
1040+
with mpl.rc_context(fname='print.rc'):
1041+
plt.plot(x, b)
1042+
plt.plot(x, c)
10411043
10421044
The 'a' vs 'x' and 'c' vs 'x' plots would have settings from
10431045
'screen.rc', while the 'b' vs 'x' plot would have settings from
10441046
'print.rc'.
10451047
10461048
A dictionary can also be passed to the context manager::
10471049
1048-
>>> with mpl.rc_context(rc={'text.usetex': True}, fname='screen.rc'):
1049-
... plt.plot(x, a)
1050+
with mpl.rc_context(rc={'text.usetex': True}, fname='screen.rc'):
1051+
plt.plot(x, a)
10501052
10511053
The 'rc' dictionary takes precedence over the settings loaded from
10521054
'fname'. Passing a dictionary only is also valid.
@@ -1133,7 +1135,7 @@ def use(arg, warn=True, force=False):
11331135
reload(sys.modules['matplotlib.backends'])
11341136

11351137
def get_backend():
1136-
"Returns the current backend."
1138+
"""Return the name of the current backend."""
11371139
return rcParams['backend']
11381140

11391141
def interactive(b):

0 commit comments

Comments
 (0)