[Numpy-discussion] adopting Python Style Guide for classes

Jarrod Millman millman@berkeley....
Tue Oct 2 00:37:58 CDT 2007


Hello,

NumPy and SciPy should conform with Guido's style guide as closely as possible:
http://www.python.org/dev/peps/pep-0008/
The only serious divergence that I am aware of between the NumPy and
SciPy codebase and the Python recommended standards is in class
naming.  According to Guido,  class names should use the CapWords
convention.  Most Python projects (eg, ETS, matploltlib) adhere to the
Python naming conventions and it is confusing that NumPy and SciPy
don't.

Currently, both NumPy and SciPy use either lower_underscore_separated
or CapWords for class names.  By my rough count, NumPy has about 752
classes using CapWords and 440 using  lower_underscore_separated.
While SciPy has about 256 classes using CapWords and 815 using
lower_underscore_separated.  Moreover, a far amount of the
lower_underscore_separated classes are tests.  That a number of
classes currently use CapWords despite the NumPy convention to use
lower_underscore_separated names may indicate it would make more sense
to switch to the Python convention.

I am hoping that most of you agree with the general principle of
bringing NumPy and SciPy into compliance with the standard naming
conventions.  I have already talked to a few people including Travis
about this switch and so far everyone supports the change in general.
Please let me know if you have any major objections to adopting the
Python class naming convention.

Once we have agreed to using CapWords for classes, we will need to
decide what to do about our existing class names.  Obviously, it is
important that we are careful to not break a lot of code just to bring
our class names up to standards.  So at the very least, we probably
won't be able to just change every class name until NumPy 1.1.0 is
released.

Here is what I propose for NumPy:
1.  Change the names of the TestCase class names to use CapWords.  I
just checked in a change to allow TestCase classes to be prefixed with
either 'test' or 'Test':
http://projects.scipy.org/scipy/numpy/changeset/4144
If no one objects, I plan to go through all the NumPy unit tests and
change their names to CapWords.  Ideally, I would like to get at least
this change in before NumPy 1.0.4.
2.  Any one adding a new class to NumPy would use CapWords.
3.  When we release NumPy 1.1, we will convert all (or almost all)
class names to CapWords.  There is no reason to worry about the exact
details of this conversion at this time.  I just would like to get a
sense whether, in general, this seems like a good direction to move
in.  If so, then after we get steps 1 and 2 completed we can start
discussing how to handle step 3.

Cheers,

-- 
Jarrod Millman
Computational Infrastructure for Research Labs
10 Giannini Hall, UC Berkeley
phone: 510.643.4014
http://cirl.berkeley.edu/


More information about the Numpy-discussion mailing list