Changeset 2998


Ignore:
Timestamp:
Sep 6, 2010 2:21:53 AM (9 years ago)
Author:
wehart
Message:

Resolving #4060: parsing numbers with scientific notation.

Location:
coopr.pyomo/trunk/coopr/pyomo
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • coopr.pyomo/trunk/coopr/pyomo/data/parse_datacmds.py

    r2997 r2998  
    9494
    9595def t_WORD(t):
    96     r'[a-zA-Z_0-9][a-zA-Z_0-9\.\-]*'
     96    r'[a-zA-Z_0-9][a-zA-Z_0-9\.+\-]*'
    9797    t.type = reserved.get(t.value,'WORD')    # Check for reserved words
    9898    return t
  • coopr.pyomo/trunk/coopr/pyomo/tests/unit/test_param.py

    r2997 r2998  
    575575        self.model.B=Param(self.model.A)
    576576        self.instance = self.model.create("param.dat")
    577         #self.instance.A.pprint()
    578         #self.instance.B.pprint()
    579577        self.failUnlessEqual( self.instance.A.data(), set(['A','B','C']) )
     578
     579    def test_io9(self):
     580        OUTPUT=open("param.dat","w")
     581        print >>OUTPUT, "data;"
     582        print >>OUTPUT, "param : A : B :="
     583        print >>OUTPUT, "\"A\" 0.1"
     584        print >>OUTPUT, "\"B\" 1e-1"
     585        print >>OUTPUT, "\"b\" 1.4e-1"
     586        print >>OUTPUT, "\"C\" 1E-1"
     587        print >>OUTPUT, "\"c\" 1.4E-1"
     588        print >>OUTPUT, "\"D\" 1E+1"
     589        print >>OUTPUT, "\"d\" 1.4E+1"
     590        print >>OUTPUT, "\"AA\" -0.1"
     591        print >>OUTPUT, "\"BB\" -1e-1"
     592        print >>OUTPUT, "\"bb\" -1.4e-1"
     593        print >>OUTPUT, "\"CC\" -1E-1"
     594        print >>OUTPUT, "\"cc\" -1.4E-1"
     595        print >>OUTPUT, "\"DD\" -1E+1"
     596        print >>OUTPUT, "\"dd\" -1.4E+1;"
     597        print >>OUTPUT, "end;"
     598        OUTPUT.close()
     599        self.model.A=Set()
     600        self.model.B=Param(self.model.A)
     601        self.instance = self.model.create("param.dat")
     602        self.failUnlessEqual( self.instance.B['A'], 0.1)
     603        self.failUnlessEqual( self.instance.B['B'], 0.1)
     604        self.failUnlessEqual( self.instance.B['b'], 0.14)
     605        self.failUnlessEqual( self.instance.B['C'], 0.1)
     606        self.failUnlessEqual( self.instance.B['c'], 0.14)
     607        self.failUnlessEqual( self.instance.B['D'], 10)
     608        self.failUnlessEqual( self.instance.B['d'], 14)
     609        self.failUnlessEqual( self.instance.B['AA'], -0.1)
     610        self.failUnlessEqual( self.instance.B['BB'], -0.1)
     611        self.failUnlessEqual( self.instance.B['bb'], -0.14)
     612        self.failUnlessEqual( self.instance.B['CC'], -0.1)
     613        self.failUnlessEqual( self.instance.B['cc'], -0.14)
     614        self.failUnlessEqual( self.instance.B['DD'], -10)
     615        self.failUnlessEqual( self.instance.B['dd'], -14)
    580616
    581617
Note: See TracChangeset for help on using the changeset viewer.