Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #20544

Re: format a measurement result and its error in "scientific" way

References (1 earlier) <CALwzidk=KX42EwZBe8jCJ9YQT_FNHG8GGU_ogNhtv7myBptSjQ@mail.gmail.com> <CADjSo4RpDwohyNFvudqTCX8vdOFd-sHMUZE0adkg6P=sU8jNwQ@mail.gmail.com> <CALwzidk2i40vAecq14f=_AeQM22CjQK-L_uf+44g7JHJYjxuPg@mail.gmail.com> <CADjSo4S1h_ucy2io6LqZr158FSJJMF5tFMOaTecB4-AjVTBfSg@mail.gmail.com> <CALwzid=ew=kzmoEFbWKLLKZADL7sqSMfXd-7SL5Nw+Sw0UFJYg@mail.gmail.com>
Date 2012-02-17 11:00 +0100
Subject Re: format a measurement result and its error in "scientific" way
From Daniel Fetchinson <fetchinson@googlemail.com>
Newsgroups comp.lang.python
Message-ID <mailman.5913.1329472829.27778.python-list@python.org> (permalink)

Show all headers | View raw


>> Thanks, it's simpler indeed, but gives me an error for value=1.267,
>> error=0.08:
>>
>> Traceback (most recent call last):
>>  File "/home/fetchinson/bin/format_error", line 26, in <module>
>>    print format_error( sys.argv[1], sys.argv[2] )
>>  File "/home/fetchinson/bin/format_error", line 9, in format_error
>>    error_scale += error.scaleb( -error_scale ).to_integral(  ).adjusted(
>>  )
>>  File "/usr/lib64/python2.6/decimal.py", line 3398, in scaleb
>>    ans = self._check_nans(other, context)
>>  File "/usr/lib64/python2.6/decimal.py", line 699, in _check_nans
>>    other_is_nan = other._isnan()
>> AttributeError: 'int' object has no attribute '_isnan'
>>
>> Which version of python are you using?
>
> 2.7.1.  At a guess, it's failing because scaleb() (which was new in
> 2.6) is buggily expecting a decimal argument, but adjusted() returns an int.
> Convert the results of the two adjusted() calls to decimals, and I
> think it should be fine.

Great, with python 2.7 it works indeed!

Cheers,
Daniel


-- 
Psss, psss, put it down! - http://www.cafepress.com/putitdown

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: format a measurement result and its error in "scientific" way Daniel Fetchinson <fetchinson@googlemail.com> - 2012-02-17 11:00 +0100

csiph-web