def get_params(args, opts): """ Get params from conffile """ logger = logging.getLogger('fms') simconffile = get_simconffile(args) if os.path.splitext(simconffile)[-1] == '.xml': logger.debug("Calling XmlParamsParser on %s" % simconffile) params = XmlParamsParser(simconffile) else: logger.debug("Calling YamlParamsParser on %s" % simconffile) params = YamlParamsParser(simconffile) params['simconffile'] = simconffile params = apply_opts(params, opts) params.printparams() return params
def testDaylengthValue(self): """ Daylength is correctly read as an int """ xmlparamsfile = '%s/fullconfig.xml' % self.fixturesdir params = XmlParamsParser(xmlparamsfile) self.assertEqual(params['engines'][0]['daylength'], 10)
def testClearBooksAtEODDefaultValue(self): """ Engines clear books at end of day """ xmlparamsfile = '%s/minimalconfig.xml' % self.fixturesdir params = XmlParamsParser(xmlparamsfile) self.assertTrue(params['engines'][0]['clearbooksateod'])
def testDaylengthDefaultValue(self): """ Daylength should be 1 if missing """ xmlparamsfile = '%s/minimalconfig.xml' % self.fixturesdir params = XmlParamsParser(xmlparamsfile) self.assertEqual(params['engines'][0]['daylength'], 1)
def testWorldClassValue(self): """ World class is read correctly """ xmlparamsfile = '%s/minimalconfig.xml' % self.fixturesdir params = XmlParamsParser(xmlparamsfile) self.assertEqual(params['world']['classname'], 'NullWorld')
def testOrdersLogFileDefaultValue(self): """ OrdersLogFile shoud be None if missing """ xmlparamsfile = '%s/minimalconfig.xml' % self.fixturesdir params = XmlParamsParser(xmlparamsfile) self.assertEqual(params['orderslogfilename'], None)
def testOutputfileDefaultValue(self): """ Outputfile should be sys.stdout if missing """ xmlparamsfile = '%s/minimalconfig.xml' % self.fixturesdir params = XmlParamsParser(xmlparamsfile) self.assertEqual(params['outputfilename'], 'sys.stdout')
def testRandomSeedValue(self): """ Randomseed is read correctly """ xmlparamsfile = '%s/fullconfig.xml' % self.fixturesdir params = XmlParamsParser(xmlparamsfile) self.assertEqual(params['randomseed'], '12345678')
def testRandomseedDefaultValue(self): """ Randomseed should be None if missing """ xmlparamsfile = '%s/minimalconfig.xml' % self.fixturesdir params = XmlParamsParser(xmlparamsfile) self.assertEqual(params['randomseed'], None)
def testExperimentNameValue(self): """ Experiment name is correctly read """ xmlparamsfile = '%s/fullconfig.xml' % self.fixturesdir params = XmlParamsParser(xmlparamsfile) self.assertEqual(params['name'], 'Test Experiment')
def testMarketClassValue(self): """ Market param classname is read correctly """ xmlparamsfile = '%s/minimalconfig.xml' % self.fixturesdir params = XmlParamsParser(xmlparamsfile) self.assertEqual(params['engines'][0]['market']['classname'], 'DummyMarket')
def testEngineClassValue(self): """ Engine classname is read correctly """ xmlparamsfile = '%s/minimalconfig.xml' % self.fixturesdir params = XmlParamsParser(xmlparamsfile) self.assertEqual(params['engines'][0]['classname'], 'AsynchronousRandom')
def testOrderLogFileValue(self): """ OrdersLogFile might be read from config """ xmlparamsfile = '%s/fullconfig.xml' % self.fixturesdir params = XmlParamsParser(xmlparamsfile) self.assertEqual(params['orderslogfilename'], '%s/dummyoutput.log' % self.fixturesdir)
def testOuputfileValue(self): """ Outputfile might be read from config """ xmlparamsfile = '%s/fullconfig.xml' % self.fixturesdir params = XmlParamsParser(xmlparamsfile) self.assertEqual(params['outputfilename'], '%s/dummyoutput.csv' % self.fixturesdir)
def testExperimentNameDefaultValue(self): """ Experiment name is built from filename if missing """ xmlparamsfile = '%s/minimalconfig.xml' % self.fixturesdir params = XmlParamsParser(xmlparamsfile) self.assertEqual(params['name'], '%s/minimalconfig.xml experiment' % self.fixturesdir)