Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!tudelft.nl!txtfeed1.tudelft.nl!feeder3.cambriumusenet.nl!feeder1.cambriumusenet.nl!feed.tweaknews.nl!194.109.133.85.MISMATCH!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'attribute': 0.07; 'indeed,': 0.07; 'python': 0.08; 'argument,': 0.09; 'failing': 0.09; 'received:209.85.216.53': 0.09; 'received:mail- qw0-f53.google.com': 0.09; 'subject:error': 0.09; '2.7': 0.13; "'int'": 0.16; 'from:addr:fetchinson': 0.16; 'from:name:daniel fetchinson': 0.16; 'int.': 0.16; 'psss,': 0.16; 'skip:) 10': 0.16; 'subject:result': 0.16; 'url:putitdown': 0.16; 'simpler': 0.18; 'thanks,': 0.19; '(which': 0.19; 'cheers,': 0.20; '(most': 0.21; 'header:In-Reply-To:1': 0.22; 'traceback': 0.24; 'convert': 0.25; 'subject:" ': 0.28; 'skip:" 30': 0.28; 'message- id:@mail.gmail.com': 0.29; 'fine.': 0.29; 'print': 0.29; 'subject:format': 0.30; 'error': 0.30; 'from:addr:googlemail.com': 0.31; 'version': 0.32; 'object': 0.33; 'file': 0.34; 'daniel': 0.34; 'last):': 0.34; 'to:addr:python-list': 0.35; 'two': 0.36; 'but': 0.37; 'received:google.com': 0.37; 'received:209.85': 0.38; 'think': 0.38; 'should': 0.38; 'received:209': 0.39; 'put': 0.40; 'to:addr:python.org': 0.40; 'results': 0.64; '26,': 0.73; 'subject:its': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=HTzlFwTGtEW45TJ1RxQtQLdsBfvVzk1DUvMOoq2lzBM=; b=uw7+20U/I/Wq1eIusBqvxXg1ON8IImISKMaOgozIfnxrpqRF9/B7QbkUl7X0ENSyeb 6L0cZwf7mMSGE0TGp0DrJlSPaPxHrhVUv+5+M94TGfCw68OaB+ef1gEZ1gylaiBHJI4W jgH3oMKvJG9Jwli/ZB3B+pxdpcqXAMzjtk+0M= MIME-Version: 1.0 In-Reply-To: References: Date: Fri, 17 Feb 2012 11:00:27 +0100 Subject: Re: format a measurement result and its error in "scientific" way From: Daniel Fetchinson To: Python Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 30 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1329472830 news.xs4all.nl 6866 [2001:888:2000:d::a6]:49070 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:20544 >> 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 >> 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