Modifying the value of a float-like object

Piet van Oostrum piet at cs.uu.nl
Wed Apr 15 13:41:37 CEST 2009


>>>>> Eric.Le.Bigot at spectro.jussieu.fr (ELB) wrote:

>ELB> To Dave A. and Piet: I appreciate your taking the time to make
>ELB> suggestions.  I understand that there is a hitch in the approach that
>ELB> you describe, which I would like to insist on: how do you handle
>ELB> functions that use math.sin(), for instance?  numpy does this kind of
>ELB> magic, but I'm not sure it's wise to spend time reproducing it.  I'd
>ELB> to not have to modify any calculation code, so that it is legible and
>ELB> general (in particular, so that it can work with Python floats).  And
>ELB> again, interval arithmetic fails to produce real standard deviations,
>ELB> because of correlations between uncertainties.

Mine does allow you to use math.sin(x) as you can see. Dave's also I
think. His solution is similar to mine but he puts the list stuff in it
whereas I came up with only the float.

In my solution I think you can mostly use normal formula's with the
Float objects, although there may be some functions that give problems
for example if they have explicit tests like type(x) == float. Why don't
you give it a try?
-- 
Piet van Oostrum <piet at cs.uu.nl>
URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4]
Private email: piet at vanoostrum.org



More information about the Python-list mailing list