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

Skip to content

Commit c2d44e9

Browse files
committed
added a modified version of erics importer
svn path=/trunk/matplotlib/; revision=3526
1 parent 55fa047 commit c2d44e9

2 files changed

Lines changed: 19 additions & 9 deletions

File tree

lib/matplotlib/__init__.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -886,4 +886,19 @@ def __init__(self, namespace):
886886
self.__dict__[modname.replace('matplotlib.', '')] = v
887887

888888

889+
class Importer:
890+
def __init__(self, modstr):
891+
"""
892+
import a bunch of matplotlib modules listed in modstr into a
893+
single namespace. Eg,
889894
895+
mpl = Importer('artist, cbook, lines, patches')
896+
print mpl.cbook.iterable(1)
897+
"""
898+
for name in modstr.split(','):
899+
name = name.strip()
900+
wholename = '.'.join(['matplotlib', name])
901+
basemod = __import__(wholename)
902+
mod = getattr(basemod, name)
903+
setattr(self, name, mod)
904+

lib/matplotlib/axes.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,10 @@
88
import matplotlib
99
rcParams = matplotlib.rcParams
1010

11-
from matplotlib import artist, agg, axis, cbook, collections, colors, \
12-
contour, dates, font_manager, image, legend, lines, mlab, cm, \
13-
patches, quiver, table, text, ticker, transforms
14-
15-
# put all the matplotlib modules in the local namespace into a single
16-
# namespace object to avoid ambiguity in references below, eg artist
17-
# becomes mpl.artist
18-
mpl = matplotlib.Namespace(locals())
19-
11+
# import a bunch of matplotlib modules into a single namespace
12+
mpl = matplotlib.Importer("""artist, agg, axis, cbook, collections, colors,
13+
contour, dates, font_manager, image, legend, lines, mlab, cm,
14+
patches, quiver, table, text, ticker, transforms""")
2015

2116
def delete_masked_points(*args):
2217
"""

0 commit comments

Comments
 (0)