So, it looks like the present release is OK and we don't need a bugfix release before we proceed with numpification--correct?

This will involve quite a bit of change in each file, so we should probably announce beforehand when we are going to work on a given file, so as to avoid collisions and duplication of effort. Personally, I expect to start with the shorter files I have worked on the most: contour, quiver, colorbar, colors. I don't mind attacking something like axes later. I'm not sure how much time I will be able to spend on this--certainly less than I would like--but fortunately it can be done piecemeal.

I have added some relevant instructions to the coding guide, based on
http://www.mail-archive.com/matplotlib-devel@lists.sourceforge.net/msg00791.html
and subsequent discussion.

I think that we ended up with:
import numpy as npy
...
a = npy.array([1,2,3])
b = npy.sin(a)
...etc.

The rationale is that this avoids confusion with existing use of nx to mean the numerix module, and it parallels the numpy internal use of NPY_ in C code.

John, you generalized this as follows:
  * when we do the cleanup, we should replace all the 'from numerix
import something' with 'import numpy as nx; nx.something' as above.
Where possible when cleaning a given module for numerix, we should
standardize the other imports.  Eg, instead of 'from cbook import
iterable' we should do 'import matplotlib.cbook as cbook;
cbook.iterable'  Let's use this convention where we use absolute
imports renamed to relative imports, and qualify all module functions
in the code with the module names.

The diff for the CODING_GUIDE is attached; please check to see if I got it right. It may go beyond, or not completely cover, previous discussions, and I committed it to get the review process going. Please discuss and/or change it as needed. It is important that we have a clear picture of the desired end result before we spend time making extensive changes in just about every module.

Question: is there a functional difference between
from matplotlib import cbook
and
import matplotlib.cbook as cbook?

Eric



Andrew Straw wrote:
Hi,

I just turned off the building of the Numeric and numarray extensions in setup.py. (As is always good practice, you may have to delete your build and install directories to insure the old extensions are not kept in place.)

I didn't clean up any infrastructure at this point, but I presume we want to start using numpy internally rather than the numerix layer. If that's true, we're free now to make use of all that numpy offers rather than the lowest-common-denominator approach we had been following! Sweet!

Andrew

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Index: CODING_GUIDE
===================================================================
--- CODING_GUIDE	(revision 3380)
+++ CODING_GUIDE	(working copy)
@@ -5,7 +5,7 @@
 
 == svn checkouts ==
 
-# checking out the main src 
+# checking out the main src
 svn co https://svn.sourceforge.net/svnroot/matplotlib/trunk/matplotlib matplotlib
 
 # checking out everything (toolkits, user's guide, htdocs, etc..)
@@ -38,9 +38,30 @@
   * If you have altered extension code, do you pass
     unit/memleak_hawaii.py?
 
+== Importing and name spaces ==
 
-== Naming and spacing conventions ==
+For numpy, use:
 
+    import numpy as npy
+    ...
+    a = npy.array([1,2,3])
+    ...
+
+For matplotlib main module, use:
+
+    import matplotlib as mpl
+    ...
+    mpl.rcParams['xtick.major.pad'] = 6
+
+For matplotlib modules, use:
+
+    import matplotlib.cbook as cbook
+    ...
+    if cbook.iterable(z):
+        ...
+
+== Naming, spacing, and formatting conventions ==
+
 In general, we want to hew as closely as possible to the standard
 coding guidelines for python written by Guido in
 http://www.python.org/dev/peps/pep-0008, though we do not do this
@@ -58,6 +79,22 @@
 should be used for indentation everywhere and if there is a file with
 tabs or more or less spaces it is a bug -- please fix it.
 
+Please avoid spurious invisible spaces at the ends of lines.
+(Tell your editor to strip whitespace from line ends when saving
+a file.)
+
+Keep docstrings uniformly indented as in the example below, with
+nothing to the left of the triple quotes.  The dedent() function
+is needed to remove excess indentation only if something will be
+interpolated into the docstring, again as in the example above.
+
+Limit line length to 80 characters.  If a logical line needs to be
+longer, use parentheses to break it; do not use an escaped
+newline.  It may be preferable to use a temporary variable
+to replace a single long line with two shorter and more
+readable lines.
+
+
 == Licenses ==
 
 matplotlib only uses BSD compatible code.  If you bring in code from
@@ -195,7 +232,6 @@
 matplotlib.axes.Axes.plot
 
     # in axes.py
-from cbook import dedent
 ...
     def plot(self, *args, **kwargs):
         """
@@ -210,7 +246,7 @@
         information
         """
         pass
-    plot.__doc__ = dedent(plot.__doc__) % artist.kwdocd
+    plot.__doc__ = cbook.dedent(plot.__doc__) % artist.kwdocd
 
 Note there is a problem for Artist __init__ methods, eg Patch.__init__
 which supports Patch kwargs, since the artist inspector cannot work
@@ -220,18 +256,3 @@
 point" requirement above; hopefully we'll find a more elegant solution
 before too long
 
-== Formatting (editor setup) ==
-
-Indentation is in units of 4 spaces.
-
-Please avoid hard tabs--use only spaces.
-
-Please avoid spurious invisible spaces at the ends of lines.
-(Tell your editor to strip whitespace from line ends when saving
-a file.)
-
-Keep docstrings uniformly indented as in the example above, with
-nothing to the left of the triple quotes.  The dedent() function
-is needed to remove excess indentation only if something will be
-interpolated into the docstring, again as in the example above.
-
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Reply via email to