Re: Python advocacy in scientific computation

2006-03-08 Thread Michael McNeil Forbes
Robert Kern <[EMAIL PROTECTED]> writes: > sturlamolden wrote: ... > > 5. Versioning control? For each program there is only one > > developer and a single or a handful users. ... > This is one thing that a lot of people seem to get wrong: version > control is not a burden on software development. I

Re: how to overload sqrt in a module?

2006-03-04 Thread Michael McNeil Forbes
On Fri, 3 Mar 2006, Steven D'Aprano wrote: > ... you can do this: > > import my_module > my_module.set_environment("math") # or cmath, or numeric, or whatever > > Your my_module will be like this: > > # Warning: untested code. > ENVIRON = None # global variables sometimes have their uses > > def

Re: how to overload sqrt in a module?

2006-03-04 Thread Michael McNeil Forbes
On Fri, 3 Mar 2006, david mugnai wrote: [snip] > > If I don't misunderstood the problem, you can define an "init" method for > your module_g > > (code not tested) > > module_g.py > --- > > _functions = {} > def init(mathmodule): > _function['sqrt'] = getattr(mathmodule, 'sqrt', None) > >

Re: how to overload sqrt in a module?

2006-03-02 Thread Michael McNeil Forbes
> On Thu, 2 Mar 2006 16:12:53 -0800, Michael McNeil Forbes wrote: > >> I would like to write a module that provides some mathematical functions >> on top of those defined in math, cmath etc. but I would like to make it >> work with "any" type that overloads th

Re: how to overload sqrt in a module?

2006-03-02 Thread Michael McNeil Forbes
>> Are there any other more generic solutions (without having to write >> "custom" functions like numpy.sqrt)? > > No. *Someone* always has to write those "custom" functions. In the case of > len() > and abs(), that someone was Guido. For numpy.sqrt(), that someone was Travis > Oliphant. For anyth

Re: how to overload sqrt in a module?

2006-03-02 Thread Michael McNeil Forbes
> Michael McNeil Forbes wrote: >> Here is one fairly ugly solution: >> >> module_g.py >> --- >> def g(x,math): >> return math.sqrt(x) >> >> >>>>> import math, cmath, module_g >>>>> module_g.g(2,math)

how to overload sqrt in a module?

2006-03-02 Thread Michael McNeil Forbes
I would like to write a module that provides some mathematical functions on top of those defined in math, cmath etc. but I would like to make it work with "any" type that overloads the math functions. Thus, I would like to write: module_f.py def f(x): """ Compute sqrt of x """ retu