General code conventions
Naming
Where possible, please try to use human-readable names for all principal variables and constants. These are my suggestions:
Use
camel case for important names. All class and exception names have uppercase first letter. e.g., "MapSystem"
Variable names have lowercase first letter. e.g., "inputVarList"
In the current code version, I have frequently used underscores as a separator in all-lowercase names. This may change so that I am more consistent with the above convention.
Capital letters for global constants. Underscores are more useful here. e.g., "E_COMPUTFAIL"
Class method names should generally use the same convention as functions, but should start with a single underscore when they are to be distinguished as "internal" (private) methods, or only for use by advanced users.
Module code conventions
Header
At this point, a strictly consistent revision numbering system is not worth the effort. I have kept the placeholder there for future use, nonetheless. My headers have the form
1 #! /usr/local/bin/python
2 #Author: Robert Clewley
3 #Date: 11 Jun 2005
4 #$Revision: 1.0.2 $
5 """Trajectory generator classes.
6
7 Robert Clewley, June 2005
8
9 """
Module imports
Standard PyDSTool modules that are used throughout a module should be imported using the convention "from <stdmodule> import *", so that the imported names are directly accessible without prefixing. Less commonly used, or minor, modules should be imported using "import <stdmodule>" so that the module name prefixes the imported names. The following are almost always required, in order that a module can communicate with the core code:
1 # PyDSTool imports
2 from utils import *
3 from common import *
4 from errors import *
5 from Interval import *
6 from Points import *
7 import Variable
8 import Trajectory
After these "internal" PyDSTool imports, these are typical imports:
1 # Other imports
2 from scipy_base import *
3 from numarray import array, arange, zeros, Float, Int, Complex, \
Float64, Int32, Complex64
4 import math
Module exports
Use the __all__ syntax to export only the primary names from a module. This avoids clutter when importers of the module use "from yourmodule import *"
Global declarations
Any global constants should be declared next.