[SciPy-user] Using SciPy/NumPy optimization THANKS!

Alexander Michael lxander.m@gmail....
Thu Mar 1 07:19:45 CST 2007


On 2/28/07, Brandon Nuttall <bnuttall@uky.edu> wrote:
> Folks,
>
> Thanks to Alok Singhal and Robert Kern I have not only learned a great deal
> about SciPy and NumPy, but I have code that works. Thanks for the tip on
> not looping; it does make cleaner code. I have two issues: 1) there must be
> a better way to convert a list of data pairs to two arrays, 2) I'm not sure
> of a graceful way to transition from one plot to the next and then close.
>

To add to the cacophony of coding and style suggestions. The <>
operator is likely to be removed in the future, so you should use
'!='. My personal preference would be to move the plotting
functionality to a method so that initializing the data is separate
from acting on the data. I find this to be a helpful distinction as I
usually don't want to plot at the time of construction, but your
mileage may vary. Lastly, you can wrap the non-plotting portion of the
test function into a doctest
(<http://www.python.org/doc/lib/module-doctest.html>) which would then
both serve as an example in the code and as a correctness test which
is easy to check when other things change, like upgrades to numpy and
scipy. I find this to be immensely helpful.

Have fun!
Alex


More information about the SciPy-user mailing list