def test_InitialEquilibrium_fail_bad_eqn(self): obj = EquationSolver() obj.RunEquationReduction = False # By forcing 't' into the variable list, no automatic creation of time variables obj.ParseString(""" x=foo exogenous t=[10.]*20 MaxTime=3""") obj.ExtractVariableList() obj.SetInitialConditions() Parameters.InitialEquilbriumMaxTime = 3 obj.MaxIterations = 2 with self.assertRaises(NameError): obj.CalculateInitialSteadyState()
def test_SolveStep_3(self): obj = EquationSolver() obj.RunEquationReduction = False # By forcing 't' into the variable list, no automatic creation of time variables obj.ParseString(""" x=t z=x(k-1) exogenous t=[10.]*20 MaxTime=3""") obj.ExtractVariableList() obj.SetInitialConditions() obj.MaxIterations = 0 with self.assertRaises(ConvergenceError): obj.SolveStep(1)
def test_FailLog0_maxiter(self): obj = EquationSolver() obj.RunEquationReduction = False # This equation will initially have a divide by zero error; the algorithm will step over that. # This is because the initial guess for Z = 0. # This test is used to hit the case where we do not converge obj.ParseString(""" z = t y = z w = y x = log10(0) exogenous t=[10., 11., 12.] MaxTime=2""") obj.ExtractVariableList() obj.SetInitialConditions() obj.MaxIterations = 1 #obj.SolveStep(1) with self.assertRaises(ValueError): obj.SolveStep(1)