|
From: <li...@us...> - 2008-11-01 14:57:04
|
Revision: 569
http://pyphant.svn.sourceforge.net/pyphant/?rev=569&view=rev
Author: liehr
Date: 2008-11-01 14:57:01 +0000 (Sat, 01 Nov 2008)
Log Message:
-----------
Enhanced list handling of FMFLoader2, extended example.fmf.
The FMFLoader2 returns lists of integer, float and complex whenever appropriate.
To reflect the new capabilities example.fmf has been extended.
Modified Paths:
--------------
trunk/doc/demo/example.fmf
trunk/src/workers/fmfile/fmfile/FMFLoader2.py
Modified: trunk/doc/demo/example.fmf
===================================================================
--- trunk/doc/demo/example.fmf 2008-11-01 14:56:44 UTC (rev 568)
+++ trunk/doc/demo/example.fmf 2008-11-01 14:57:01 UTC (rev 569)
@@ -4,21 +4,32 @@
creator: Andreas W. Liehr
created: 2008-10-29
place: Freiburger Materialforschungszentrum, Universität Freiburg, Deutschland
-[String Examples]
+ort: "Freiburger Materialforschungszentrum, Universität Freiburg, Deutschland"
+[Textual values]
word: Hello!
sentence: Hello World!
+timestamp: 2008-10-31 12:00:59.438151
comma separated list: world, die Welt, el mundo, monde
multiline: '''A multiline value,
that spans more than one line :-)
The line breaks are included in the value.'''
-[Numbers]
+Another multiline: """A multiline value,
+that spans more than one line :-)"""
+Enclosed quotation marks: """ Andreas says: "Hello World!" """
+[Numerical values]
#Note, that the 'key' is arbitrary, but has to be unique within a section
integer: 1
+list of integers: 1, 2, 3, 4, 5
float: 1.0
float with leading dot: .1
float with exponential: 1e-10
float with Exponential: -1.1E10
+list of floats: 1.0, .1, 1e-10, -1.1E10
complex: 1+2j
+Complex: 1+2J
+Complex number with zero real part : 2J
+Complex number with zero imaginary part: 1+0J
+list of complex: 1+2j, 1+2J
[Physical Quantities]
number: N = 2
voltage: U = 1V
@@ -47,7 +58,7 @@
[*data: T]
H_2 1 1. 1e1 1+0j nan inf
O_2 2 .2 2E1 2+.1j NaN INF
-O 2 2 .2 2E1 2+.1j NAN Inf
+O 2 2 .2 2E1 2+.1J NAN Inf
[*data definitions: M]
String: S
Complex: C
Modified: trunk/src/workers/fmfile/fmfile/FMFLoader2.py
===================================================================
--- trunk/src/workers/fmfile/fmfile/FMFLoader2.py 2008-11-01 14:56:44 UTC (rev 568)
+++ trunk/src/workers/fmfile/fmfile/FMFLoader2.py 2008-11-01 14:57:01 UTC (rev 569)
@@ -274,16 +274,29 @@
error = str2unit(error)
return (shortname, value, error)
except:
- try:
- return int(oldVal)
- except:
+ if type(oldVal)==type([]):
try:
- return float(oldVal)
+ return map(int,oldVal)
except:
- try:
- return complex(oldVal)
+ try:
+ return map(float,oldVal)
except:
- pass
+ try:
+ return map(complex,oldVal)
+ except:
+ pass
+ else:
+ try:
+ return int(oldVal)
+ except:
+ try:
+ return float(oldVal)
+ except:
+ try:
+ return complex(oldVal)
+ except:
+ pass
+
return oldVal
if config.has_key('*table definitions'):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|