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


Groups > comp.lang.python > #20529 > unrolled thread

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

Started byIan Kelly <ian.g.kelly@gmail.com>
First post2012-02-16 17:29 -0700
Last post2012-02-16 17:29 -0700
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: format a measurement result and its error in "scientific" way Ian Kelly <ian.g.kelly@gmail.com> - 2012-02-16 17:29 -0700

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

FromIan Kelly <ian.g.kelly@gmail.com>
Date2012-02-16 17:29 -0700
SubjectRe: format a measurement result and its error in "scientific" way
Message-ID<mailman.5905.1329438598.27778.python-list@python.org>
On Thu, Feb 16, 2012 at 3:21 PM, Daniel Fetchinson
<fetchinson@googlemail.com> wrote:
> 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.

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web