From: Bill Dandreta <wjdandreta@at...> - 2005-11-01 22:25:46
Using matplotlib 0.84, python 2.4, scipy 0.3.2, numeric 23.7
I get errors when running date_demo_rrule.py.
Since the demo scripts are for educational purposes and primarily used
by newbies, I have a couple of suggestions.
1. Don't use import *, import the specific functions used in the demo.
I've had problems with this (especially in the interpreter) because many
Python modules use the same names in their global name space and it's
easy to inadvertently replace one function with another of the same name
which introduces bugs that can be difficult to find.
2. Don't import functions from submodules, instead use the submodule
name when calling the function. It makes it much clearer to see where
the function came from.
The set function seems to be broken (or it's a typo), I had to replace
it with the setp function to get the demo to run.
Below it the results of diff between my working version of the demo and
the original that won't run:
wjd@... ~/test $ diff date_demo_rrule.py
< from pylab import dates, YEARLY, drange, rand, subplot, plot_date,
> from pylab import *
> from matplotlib.dates import YEARLY, DateFormatter, \
> rrulewrapper, RRuleLocator, drange
< rule = dates.rrulewrapper(YEARLY, byeaster=1, interval=5)
< loc = dates.RRuleLocator(rule)
< formatter = dates.DateFormatter('%m/%d/%y')
> rule = rrulewrapper(YEARLY, byeaster=1, interval=5)
> loc = RRuleLocator(rule)
> formatter = DateFormatter('%m/%d/%y')
< setp(labels, rotation=30, fontsize=10)
> set(labels, rotation=30, fontsize=10)
From: John Hunter <jdhunter@ac...> - 2005-11-02 04:01:34
>>>>> "Bill" == Bill Dandreta <wjdandreta@...> writes:
Bill> Using matplotlib 0.84, python 2.4, scipy 0.3.2, numeric 23.7
Bill> I get errors when running date_demo_rrule.py.
What errors? The set/sep error alluded to below? This is actually
fixed in 0.84 and CVS. Unfortunately, the web site may not have been
updated. Grap the 0.84 zip or tar.gz file for the latest examples
dir, and I'll try and get the web site updated soonish.
Bill> Since the demo scripts are for educational purposes and
Bill> primarily used by newbies, I have a couple of suggestions.
Bill> 1. Don't use import *
Bill> 2. Don't import functions from submodules, instead use the
Bill> submodule name when calling the function. It makes it much
Bill> clearer to see where the function came from.
Reasonable suggestions all, and ones that have been brought up many
times before. I believe there is a balance between teaching and
convenience. For many new students, they just want the functions to
*be there* eg, rand, fft, psd, and don't want to sort out where they
come from. This is doubly or triply true considering the namespace
issues of Numeric, numarray, and scipy (quick, where does rand live in
numarray, scipy, Numeric, matplotlib and old scipy?). But I also
agree that it is healthy to force people to think about these issues
and learn the origins of these packages. So my rule of thumb is to
use namespaces when writing new examples, and to accept patches for
old ones. If you could resubmit your patch against matplotlib CVS I
would be happy to make the changes.