SourceForge logo
SourceForge logo
Menu

[matplotlib-devel] numpification and imports

From: John H. <jd...@gm...> - 2007年07月13日 20:06:46
I just removed the last vestiges of the numerix extension code layer.
The conditional imports are gone from the extension code, the -D flags
are gone from the compile, as is the _ns_ module naming scheme. This
is a fairly major change, so please blow away your install and build
dirs after updating to r3513
I also numpified axes.py, by far the biggest and most complicated
module, and fixed all of the imports as we discussed in an earlier
thread. One problem I ran into. With the proposed
from matplotlib import lines # and friends
there is a lot of possibility for name clashes. Eg, in some places we
also have a variable names "lines", which isn't life threatening but
certainly can lead to confusion and bugs. Or for module legend, we
also have an Axes function.legend. I decided to go with a foolish
consistency that was unambiguous:
from matplotlib import artist as mpl_artist
from matplotlib import agg as mpl_agg
from matplotlib import axis as mpl_axis
from matplotlib import cbook as mpl_cbook
from matplotlib import collections as mpl_collections
from matplotlib import colors as mpl_colors
from matplotlib import contour as mpl_contour
and then
mpl_cbook.iterable # and so on
Because the mpl_ prefix occurs nowhere else, we can easily change this
to whatever we want with a single search replace.
I also added a module mpl which simply imports all the modules, so API
or pylab users can
 >>> from pylab import mpl
or
 >>> from matplotlib import mpl
and have all of the API in one place (mpl.dates, mpl.figure,
mpl.ticker, etc...) -- nice with tab completion an online help in
ipython when you aren't sure where to find something....
I was hoping we could use this in the matplotlib code itself. Eg if
axes could import mpl, then we could replace the somewhat ugly
mpl_cbook with the nice and pretty mpl.cbook, but there is the problem
of recursive imports. Is there a way to do this with some python
magic, so that one "mpl" API module could serve all of the modules?
Something in the back of my mind is telling me there is something in
EGGS with an api module..... Any ideas?
JDH

View entire thread

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /