def test_output_csv(self): outputData(self.data, self.OUTPUT_PATH) file = open(self.OUTPUT_PATH, "r") lines = file.readlines() file.close() goalLines = [ "03/23/2014,03/24/2014,03/25/2014\n", "100.0,230.0,60.0\n" ] self.assertEqual(lines, goalLines)
def main(): parser = argparse.ArgumentParser(description='Get a handle on your personal finances.') parser.add_argument( 'config', nargs=1, help='A config file specifying your finances.') parser.add_argument( '-o', '--output', nargs=1, default=["finances.csv"], help='Output file to write to.') parser.add_argument( '-d', '--days', nargs=1, type=int, default=[365], help='Number of days to calculate ahead of today.') args = parser.parse_args() configJson = loadConfigJson(args.config[0]) accounts = loadAccounts(configJson) balanceModifiers = loadBalanceModifiers(configJson) engine = Engine(accounts, balanceModifiers) startDate = datetime.date.today() endDate = startDate + datetime.timedelta(days=args.days[0]) data = engine.execute(startDate, endDate) outputData(data, args.output[0])
total += 1 return correct / total def runTests(): createPerceptrons() trainingData = getData('optdigits.train') for key in sorted(perceptrons.keys()): curAcc = runEpoch(trainingData, key) while curAcc > output.trainAcc[key] or output.numEpochs[key] < 5: output.trainAcc[key] = curAcc curAcc = runEpoch(trainingData, key) output.numEpochs[key] += 1 testData = getData('optdigits.test') for key in sorted(perceptrons.keys()): output.testAcc[key] = testPerceptrons(testData, key) if __name__ == "__main__": output.startDoc() runTests() output.outputData() output.reset(0.8) learningRate = 0.8 runTests() output.outputData() output.reset(0.05) learningRate = 0.05 runTests() output.outputData() output.endDoc()