John Hunter wrote:
In tweaking mlab.psd(), I'm noticing there is a lot of overlap between
the keyword args for psd() and csd(). In fact, csd() doesn't document
them itself, but just references psd(). Additionally, the csd() and
psd() Axes methods duplicate these docs, with a few additional
parameters. Would it be a good thing to restructure the duplicated docs
into it's own string that can be incorporated when necessary? Or is
this kind of "monkey patching" of the docs something we're trying to
No, this is something we are doing more of lately (eg see the contour
docs) but the psd, csd, cohere predated this docstring manipulation.
So feel free to consolidate.
I've done psd and csd so far. I might get to cohere (and spectrogram)
later. It got a little ugly doing the axes methods, since you can only
use a single dictionary for string replacement.
On a separate note, there is *A LOT* of code duplication between psd()
and csd() in mlab. It's bugged me while I've been doing these tweaks,
but the problem was that csd() would end up doing an extra FFT vs. the
same call to psd. I think I might finally have a solution:
1) Have psd(x) call csd(x,x)
2) Have csd() check if y is x, and if so, avoid doing the extra work.
Would this be an acceptable solution to reduce code duplication?
On a separate note, once I get done with these tweaks, are there any
objections to submitting something based on this to scipy?
Graduate Research Assistant
School of Meteorology
University of Oklahoma