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


Groups > comp.lang.python > #66370

Re: Question on using FP numbers in python 2

Path csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'anyway.': 0.05; 'float': 0.07; 'gpl': 0.07; 'puts': 0.07; 'subject:Question': 0.07; 'boundaries': 0.09; 'bug.': 0.09; 'spaces': 0.09; 'subject:using': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'def': 0.12; 'gui': 0.12; "wouldn't": 0.14; 'comments:': 0.16; 'debugging,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'massively': 0.16; 'mixture': 0.16; 'reasonably': 0.16; 'sense,': 0.16; 'subject:python': 0.16; '(you': 0.16; 'sat,': 0.16; 'wrote:': 0.18; 'discussion': 0.18; 'file,': 0.19; "python's": 0.19; 'feb': 0.22; 'code,': 0.22; 'cc:addr:python.org': 0.22; 'software.': 0.24; 'cc:2**0': 0.24; '15,': 0.26; 'compare': 0.26; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'strongly': 0.30; 'especially': 0.30; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; 'code': 0.31; 'lines': 0.31; 'url:wiki': 0.31; 'boundary': 0.31; 'comments,': 0.31; 'decimal': 0.31; 'equivalent.': 0.31; 'piece': 0.31; 'subject:numbers': 0.31; 'skip:c 30': 0.32; 'another': 0.32; 'says': 0.33; 'ago': 0.33; 'maybe': 0.34; "can't": 0.35; 'more,': 0.35; 'requirement': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'really': 0.36; 'accuracy': 0.36; 'doubt': 0.36; 'entry': 0.36; 'url:org': 0.36; 'two': 0.37; 'level': 0.37; 'easily': 0.37; 'step': 0.37; 'being': 0.38; 'pm,': 0.38; 'little': 0.38; 'anything': 0.39; 'does': 0.39; 'sure': 0.39; 'manually': 0.60; 'most': 0.60; 'numbers': 0.61; "you're": 0.61; 'making': 0.63; 'afraid': 0.65; 'url:cgi-bin': 0.65; 'within': 0.65; 'here': 0.66; 'default': 0.69; 'money': 0.72; 'capability': 0.84; 'to:none': 0.92; 'hundred': 0.95
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=OqHP/kloXlAkCQmlaTEDTyl2cCibkI6yh6rd27UHr38=; b=ewevsoQOSIa5+P/r5KMIROwQS5736XXyrfUeYVKEDsdK5KFYH4ZhUIwNNHtkX4Zyhp zf7Pma8PQzE8ne1DMTrNVyyP/PY853Z2kVQQhb7hjBufJTqhyPBh+J4yd9iPa+v86uZ0 i5B8a/adZ1UCUKHlnFDr+7y5+vJbeRKEb5Zh5w64tSj/RKBCbjXldWz16X/ezsSanDgs REAOKKcQ/Nbg+pVfH1fE+jNR/WZQAE+zT8a37ylQ/259otv0k/IdPM+XxZO//oUv6a7I Lo7zjC7prC26dXCuq9LerBUoU9+146tHQWVfYO6tPSzM6cRdYzLJbAKuPAWEdvR88N5Y 5x2Q==
MIME-Version 1.0
X-Received by 10.66.129.133 with SMTP id nw5mr13389296pab.98.1392442096902; Fri, 14 Feb 2014 21:28:16 -0800 (PST)
In-Reply-To <201402150007.49667.gheskett@wdtv.com>
References <mailman.6953.1392434770.18130.python-list@python.org> <52feec65$0$29973$c3e8da3$5496439d@news.astraweb.com> <201402150007.49667.gheskett@wdtv.com>
Date Sat, 15 Feb 2014 16:28:16 +1100
Subject Re: Question on using FP numbers in python 2
From Chris Angelico <rosuav@gmail.com>
Cc "python-list@python.org" <python-list@python.org>
Content-Type text/plain; charset=UTF-8
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.6963.1392442106.18130.python-list@python.org> (permalink)
Lines 48
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1392442106 news.xs4all.nl 2887 [2001:888:2000:d::a6]:58926
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:66370

Show key headers only | View raw


On Sat, Feb 15, 2014 at 4:07 PM, Gene Heskett <gheskett@wdtv.com> wrote:
> Not extract, but let you get & look at the code, its the top entry on this
> page:
>
> <http://wiki.linuxcnc.org/cgi-bin/wiki.pl?Simple_LinuxCNC_G-
> Code_Generators#Counterbore_Software>

Interesting. At the top of the file, it says GPL3 or later; but then
it puts a requirement on making money off the software. I'm not sure
that's a good thing (what if someone lifts a small part of that code
out and into another GPL project?), and I'm not sure it's
legal/enforceable anyway.

The GUI creation code calls to mind the discussion we had a little
while ago about an alternative way to create a GUI in Python.
Especially compare the GTK2Table() function that I posited - I'm sure
it wouldn't be hard to make a Python (and Tkinter) equivalent.
Massively complicated code for laying out a grid/table.

But check out these comments:

    def GeneratePath(self):
         # If ToolDiameter > HoleDiameter then Complain
         # If ToolDiameter == HoleDiameter then Plunge to HoleDepth
         # If (ToolDiameter*1.25) <= HoleDiameter then Plunge to each
Level and Spiral out to HoleDiameter
        # If (ToolDiameter*1.25) > HoleDiameter then Spiral to each
Level and Spiral out to HoleDiameter

(Also, owwww! The GeneratePath function is indented with a mixture of
spaces and tabs. Most of it is indented "four spaces and then a tab",
but some lines use other mixtures. Ow ow ow!)

Does all that make sense, and are you seeing those boundaries
correctly? I strongly suspect you're not seeing a floating-point
error, but a deliberate piece of code and maybe some other form of
bug. I very much doubt the boundary is anything to do with going over
1" in diameter; the numbers you're working with here are easily within
Python's capability (you get roughly 15 decimal digits of accuracy
with the default float type).

I'm afraid I can't really help more, as I don't speak CNC. But have a
look at GeneratePath(); it does have comments, and for all of being
two hundred lines of code, it's reasonably segmented into sections.
Manually step through it, see where it's going wrong. Standard Python
debugging, nothing to do with floats AFAICT.

ChrisA

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


Thread

Question on using FP numbers in python 2 Gene Heskett <gheskett@wdtv.com> - 2014-02-14 22:25 -0500
  Re: Question on using FP numbers in python 2 Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-02-15 04:26 +0000
    Re: Question on using FP numbers in python 2 Gene Heskett <gheskett@wdtv.com> - 2014-02-15 00:07 -0500
      Re: Question on using FP numbers in python 2 Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-02-15 15:27 +0000
        Re: Question on using FP numbers in python 2 Gene Heskett <gheskett@wdtv.com> - 2014-02-15 12:27 -0500
    Re: Question on using FP numbers in python 2 Chris Angelico <rosuav@gmail.com> - 2014-02-15 16:28 +1100
  Re: Question on using FP numbers in python 2 Grant Edwards <invalid@invalid.invalid> - 2014-02-15 04:35 +0000
  Re: Question on using FP numbers in python 2 Gene Heskett <gheskett@wdtv.com> - 2014-02-15 00:50 -0500
  Re: Question on using FP numbers in python 2 Chris Angelico <rosuav@gmail.com> - 2014-02-15 17:08 +1100

csiph-web