GTK broke things! Re: float does not parse '0.000000E+00'
Paolo Redaelli
redaelli at inc.it
Sun Jun 4 11:20:45 EDT 2000
I was WRONG!
GTK broke things in a way I can't even wonder HOW....
I attack here two version. One functions and the other not. Little
problem. The ONLY difference detween them is a "import gtk" at the
beginning. Delete this line and it functions!!!!
I wonder WHY? It should create a "namespace" gtk.something
=================
[paolo at aldebaran Telaio]$ python pyplot.working.py
Processing ['LCASE.001']
Case 1
Trying to parse '1' '0.000000E+00' '0.000000E+00'
Look for strange characthers [48, 46, 48, 48, 48, 48, 48, 48, 69, 43,
48, 48]
Parsed to '1' '0.0' '0.0'
Trying to parse '2' '0.000000E+00' '0.300000E+03'
Look for strange characthers [48, 46, 48, 48, 48, 48, 48, 48, 69, 43,
48, 48]
Parsed to '2' '0.0' '300.0'
Trying to parse '3' '0.500000E+03' '0.300000E+03'
Look for strange characthers [48, 46, 53, 48, 48, 48, 48, 48, 69, 43,
48, 51]
Parsed to '3' '500.0' '300.0'
Trying to parse '4' '0.500000E+03' '0.000000E+00'
Look for strange characthers [48, 46, 53, 48, 48, 48, 48, 48, 69, 43,
48, 51]
Parsed to '4' '500.0' '0.0'
Traceback (innermost last):
File "pyplot.working.py", line 85, in ?
c = CanvasExample()
NameError: CanvasExample
[paolo at aldebaran Telaio]$ python pyplot.working.py
Processing ['LCASE.001']
Case 1
Trying to parse '1' '0.000000E+00' '0.000000E+00'
Look for strange characthers [48, 46, 48, 48, 48, 48, 48, 48, 69, 43,
48, 48]
Parsed to '1' '0.0' '0.0'
Trying to parse '2' '0.000000E+00' '0.300000E+03'
Look for strange characthers [48, 46, 48, 48, 48, 48, 48, 48, 69, 43,
48, 48]
Parsed to '2' '0.0' '300.0'
Trying to parse '3' '0.500000E+03' '0.300000E+03'
Look for strange characthers [48, 46, 53, 48, 48, 48, 48, 48, 69, 43,
48, 51]
Parsed to '3' '500.0' '300.0'
Trying to parse '4' '0.500000E+03' '0.000000E+00'
Look for strange characthers [48, 46, 53, 48, 48, 48, 48, 48, 69, 43,
48, 51]
Parsed to '4' '500.0' '0.0'
[paolo at aldebaran Telaio]$ python pyplot.py
Processing ['LCASE.001']
Case 1
Trying to parse '1' '0.000000E+00' '0.000000E+00'
Look for strange characthers [48, 46, 48, 48, 48, 48, 48, 48, 69, 43,
48, 48]
Traceback (innermost last):
File "pyplot.py", line 86, in ?
t = Telaio()
File "pyplot.py", line 78, in __init__
x = string.atof(x)
ValueError: invalid literal for atof(): 0.000000E+00
[paolo at aldebaran Telaio]$ diff pyplot.working.py pyplot.py
10a11
> import gtk
80a82
> ## End reading rods
[paolo at aldebaran Telaio]$
=============================
--
______________________________
/ Paolo Redaelli \
| redaelli at inc.it |
| http://gnupaghe.netpedia.net |
\------------------------------/
-------------- next part --------------
1
4 3
1 0.000000E+00 0.000000E+00
2 0.000000E+00 0.300000E+03
3 0.500000E+03 0.300000E+03
4 0.500000E+03 0.000000E+00
1 1 2
2 2 3
3 3 4
1 0.300000E+03 0.000000E+00 0.100000E+01
0.000000E+00 0.000000E+00 0.000000E+00 0.250000E+04 -.146922E+03 0.652654E+04
0.150000E+02 0.478073E-01 -.395235E-04 0.250000E+04 -.146922E+03 0.668798E+04
0.300000E+02 0.956146E-01 -.174419E-03 0.250000E+04 -.146922E+03 0.720229E+04
0.450000E+02 0.143422E+00 -.429172E-03 0.250000E+04 -.146922E+03 0.806948E+04
0.600000E+02 0.191229E+00 -.828271E-03 0.250000E+04 -.146922E+03 0.928954E+04
0.750000E+02 0.239036E+00 -.139620E-02 0.250000E+04 -.146922E+03 0.108625E+05
0.900000E+02 0.286844E+00 -.215745E-02 0.250000E+04 -.146922E+03 0.127883E+05
0.105000E+03 0.334651E+00 -.313651E-02 0.250000E+04 -.146922E+03 0.150670E+05
0.120000E+03 0.382458E+00 -.435786E-02 0.250000E+04 -.146922E+03 0.176985E+05
0.135000E+03 0.430266E+00 -.584599E-02 0.250000E+04 -.146922E+03 0.206830E+05
0.150000E+03 0.478073E+00 -.762539E-02 0.250000E+04 -.146922E+03 0.240203E+05
0.165000E+03 0.525880E+00 -.972055E-02 0.250000E+04 -.146922E+03 0.277105E+05
0.180000E+03 0.573687E+00 -.121559E-01 0.250000E+04 -.146922E+03 0.317535E+05
0.195000E+03 0.621495E+00 -.149561E-01 0.250000E+04 -.146922E+03 0.361495E+05
0.210000E+03 0.669302E+00 -.181454E-01 0.250000E+04 -.146922E+03 0.408983E+05
0.225000E+03 0.717109E+00 -.217484E-01 0.250000E+04 -.146922E+03 0.460000E+05
0.240000E+03 0.764916E+00 -.257897E-01 0.250000E+04 -.146922E+03 0.514546E+05
0.255000E+03 0.812724E+00 -.302936E-01 0.250000E+04 -.146922E+03 0.572620E+05
0.270000E+03 0.860531E+00 -.352846E-01 0.250000E+04 -.146922E+03 0.634223E+05
0.285000E+03 0.908338E+00 -.407874E-01 0.250000E+04 -.146922E+03 0.699355E+05
0.300000E+03 0.956146E+00 -.468262E-01 0.250000E+04 -.146922E+03 0.768016E+05
2 0.500000E+03 0.100000E+01 0.000000E+00
0.000000E+00 -.956146E+00 0.105359E+06 0.000000E+00 -.810241E-12 0.118531E+15
0.250000E+02 -.956146E+00 0.354593E+09 0.000000E+00 -.250000E+03 0.118531E+15
0.500000E+02 -.956146E+00 0.553234E+09 0.000000E+00 -.500000E+03 0.118531E+15
0.750000E+02 -.956146E+00 0.615784E+09 0.000000E+00 -.750000E+03 0.118531E+15
0.100000E+03 -.956146E+00 0.561998E+09 0.000000E+00 -.100000E+04 0.118531E+15
0.125000E+03 -.956146E+00 0.411631E+09 0.000000E+00 -.125000E+04 0.118531E+15
0.150000E+03 -.956146E+00 0.184438E+09 0.000000E+00 -.150000E+04 0.118531E+15
0.175000E+03 -.956146E+00 -.998256E+08 0.000000E+00 -.175000E+04 0.118531E+15
0.200000E+03 -.956146E+00 -.421405E+09 0.000000E+00 -.200000E+04 0.118531E+15
0.225000E+03 -.956146E+00 -.760544E+09 0.000000E+00 -.225000E+04 0.118531E+15
0.250000E+03 -.956146E+00 -.109749E+10 0.000000E+00 -.250000E+04 0.118531E+15
0.275000E+03 -.956146E+00 -.141248E+10 0.000000E+00 -.275000E+04 0.118531E+15
0.300000E+03 -.956146E+00 -.168578E+10 0.000000E+00 -.300000E+04 0.118531E+15
0.325000E+03 -.956146E+00 -.189761E+10 0.000000E+00 -.325000E+04 0.118531E+15
0.350000E+03 -.956146E+00 -.202822E+10 0.000000E+00 -.350000E+04 0.118531E+15
0.375000E+03 -.956146E+00 -.205787E+10 0.000000E+00 -.375000E+04 0.118531E+15
0.400000E+03 -.956146E+00 -.196678E+10 0.000000E+00 -.400000E+04 0.118531E+15
0.425000E+03 -.956146E+00 -.173522E+10 0.000000E+00 -.425000E+04 0.118531E+15
0.450000E+03 -.956146E+00 -.134343E+10 0.000000E+00 -.450000E+04 0.118531E+15
0.475000E+03 -.956146E+00 -.771639E+09 0.000000E+00 -.475000E+04 0.118531E+15
0.500000E+03 -.956146E+00 -.105359E+06 0.000000E+00 -.500000E+04 0.118531E+15
3 0.300000E+03 0.000000E+00 -.100000E+01
0.000000E+00 0.000000E+00 -.129038E+07 0.000000E+00 0.000000E+00 0.000000E+00
0.150000E+02 0.000000E+00 -.156394E+10 0.000000E+00 0.000000E+00 0.161438E+03
0.300000E+02 0.000000E+00 -.243946E+10 0.000000E+00 0.000000E+00 0.675750E+03
0.450000E+02 0.000000E+00 -.271495E+10 0.000000E+00 0.000000E+00 0.154294E+04
0.600000E+02 0.000000E+00 -.247753E+10 0.000000E+00 0.000000E+00 0.276300E+04
0.750000E+02 0.000000E+00 -.181429E+10 0.000000E+00 0.000000E+00 0.433594E+04
0.900000E+02 0.000000E+00 -.812342E+09 0.000000E+00 0.000000E+00 0.626175E+04
0.105000E+03 0.000000E+00 0.441215E+09 0.000000E+00 0.000000E+00 0.854044E+04
0.120000E+03 0.000000E+00 0.185928E+10 0.000000E+00 0.000000E+00 0.111720E+05
0.135000E+03 0.000000E+00 0.335473E+10 0.000000E+00 0.000000E+00 0.141564E+05
0.150000E+03 0.000000E+00 0.484049E+10 0.000000E+00 0.000000E+00 0.174938E+05
0.165000E+03 0.000000E+00 0.622943E+10 0.000000E+00 0.000000E+00 0.211839E+05
0.180000E+03 0.000000E+00 0.743446E+10 0.000000E+00 0.000000E+00 0.252270E+05
0.195000E+03 0.000000E+00 0.836847E+10 0.000000E+00 0.000000E+00 0.296229E+05
0.210000E+03 0.000000E+00 0.894436E+10 0.000000E+00 0.000000E+00 0.343718E+05
0.225000E+03 0.000000E+00 0.907502E+10 0.000000E+00 0.000000E+00 0.394735E+05
0.240000E+03 0.000000E+00 0.867335E+10 0.000000E+00 0.000000E+00 0.449280E+05
0.255000E+03 0.000000E+00 0.765225E+10 0.000000E+00 0.000000E+00 0.507355E+05
0.270000E+03 0.000000E+00 0.592461E+10 0.000000E+00 0.000000E+00 0.568958E+05
0.285000E+03 0.000000E+00 0.340332E+10 0.000000E+00 0.000000E+00 0.634090E+05
0.300000E+03 0.000000E+00 0.129038E+07 0.000000E+00 0.000000E+00 0.702750E+05
-------------- next part --------------
#!/usr/bin/env python
## pyplot
## program to plot'n'show the results of "telaio", a fortran program
##
# Author: Jesper Skov <jskov at cygnus.co.uk>
# A rewite of the C canvas example in the GNOME Developer's Information
## Importing GUI specific stuffs
import GDK
import gtk
import glob # to look for all LCASE.* files
import string ## to process informations
from UserList import UserList ## to create lists that starts counting from 1
class Node:
def __init__(self,number,x,y):
self.number = number
self.x = x
self.y = y
class Rod:
def __init__(self, number, node1, node2):
self.number = number
self.node1 = node1
self.node2 = node2
self.sections = range(0,21) ## list of sections. Each section will be a list containg [position, u displacement, v displacement, n, t, m]. From index 0 to index 20
## Lista is a list with preallocated length that starts counting from 1. This is useful to avoid unnecessary mess within file processing expecially regarding the rods and nodes lists
class Lista(UserList):
def __init__(self):
UserList.__init__(self)
self.data = []
def __setattr__(self, attr, value):
if attr == "size" and value>0:
self.data = [None]*value
else:
self.__dict__[attr] = value
def __getitem__(self,index):
if index > 0:
return self.data[index-1]
else:
raise IndexError
def __setitem__(self,index,value):
self.data[index-1] = value
class LoadCase:
def __init__(self):
self.nodes = Lista() ## the list of nodes
self.rods = Lista() ## the list of rods
class Telaio:
def __init__(self):
## Loading all the load cases
## Looking for all LCASE.xxx files
self.filelist = glob.glob("LCASE*")
self.load_cases = [None] * len(self.filelist)
for filename in self.filelist:
print "Processing %s" % [filename]
file = open(filename)
case_n = int( string.split(filename,".")[1] )
print "Case",case_n
## Reading the trailing 1
file.readline()
## read nodes and rods numbers
number_list = string.split( file.readline() )
numbers = map(int, number_list)
nodes_n = numbers[0]
rods_n = numbers[1]
for node_i in range(0,nodes_n):
[node, x, y] = string.split( file.readline() )
node = int(node);
print "Trying to parse '%s' '%s' '%s'" % (node,x,y)
#print "Looking for strange characters:",map(ord,x)
print "Look for strange characthers",map(ord,x)
x = string.atof(x)
y = float(y)
print "Parsed to '%s' '%s' '%s'" % (node,x,y)
## Note: node_i is NOT used!
## End reading rods
## End reading files.
if __name__ == '__main__':
t = Telaio()
-------------- next part --------------
#!/usr/bin/env python
## pyplot
## program to plot'n'show the results of "telaio", a fortran program
##
# Author: Jesper Skov <jskov at cygnus.co.uk>
# A rewite of the C canvas example in the GNOME Developer's Information
## Importing GUI specific stuffs
import GDK
import glob # to look for all LCASE.* files
import string ## to process informations
from UserList import UserList ## to create lists that starts counting from 1
class Node:
def __init__(self,number,x,y):
self.number = number
self.x = x
self.y = y
class Rod:
def __init__(self, number, node1, node2):
self.number = number
self.node1 = node1
self.node2 = node2
self.sections = range(0,21) ## list of sections. Each section will be a list containg [position, u displacement, v displacement, n, t, m]. From index 0 to index 20
## Lista is a list with preallocated length that starts counting from 1. This is useful to avoid unnecessary mess within file processing expecially regarding the rods and nodes lists
class Lista(UserList):
def __init__(self):
UserList.__init__(self)
self.data = []
def __setattr__(self, attr, value):
if attr == "size" and value>0:
self.data = [None]*value
else:
self.__dict__[attr] = value
def __getitem__(self,index):
if index > 0:
return self.data[index-1]
else:
raise IndexError
def __setitem__(self,index,value):
self.data[index-1] = value
class LoadCase:
def __init__(self):
self.nodes = Lista() ## the list of nodes
self.rods = Lista() ## the list of rods
class Telaio:
def __init__(self):
## Loading all the load cases
## Looking for all LCASE.xxx files
self.filelist = glob.glob("LCASE*")
self.load_cases = [None] * len(self.filelist)
for filename in self.filelist:
print "Processing %s" % [filename]
file = open(filename)
case_n = int( string.split(filename,".")[1] )
print "Case",case_n
## Reading the trailing 1
file.readline()
## read nodes and rods numbers
number_list = string.split( file.readline() )
numbers = map(int, number_list)
nodes_n = numbers[0]
rods_n = numbers[1]
for node_i in range(0,nodes_n):
[node, x, y] = string.split( file.readline() )
node = int(node);
print "Trying to parse '%s' '%s' '%s'" % (node,x,y)
#print "Looking for strange characters:",map(ord,x)
print "Look for strange characthers",map(ord,x)
x = string.atof(x)
y = float(y)
print "Parsed to '%s' '%s' '%s'" % (node,x,y)
## Note: node_i is NOT used!
## End reading files.
if __name__ == '__main__':
t = Telaio()
More information about the Python-list
mailing list