Question on using FP numbers in python 2

Chris Angelico rosuav at gmail.com
Sat Feb 15 00:28:16 EST 2014


On Sat, Feb 15, 2014 at 4:07 PM, Gene Heskett <gheskett at 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



More information about the Python-list mailing list