Changeset 13523


Ignore:
Timestamp:
Sep 18, 2019 12:44:24 PM (3 months ago)
Author:
randersson
Message:

#5819 Changed to asserts to use standard assert. Replaced assertTrue with assert_ again which was previously changed by script 2to3. It appears that assertTrue is a non-existent function, thus this original change by 2to3 is a mystery.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/dev-5819/Python/src/tests_jmodelica/optimization/test_mpc.py

    r13461 r13523  
    183183            prev_value = value
    184184
    185         N.testing.assertTrue(largest_delta_quad<largest_delta)
     185        assert largest_delta_quad<largest_delta, "Value {} is not less than {}".format(largest_delta_quad, largest_delta)
    186186       
    187187    @testattr(casadi_base = True)
     
    231231            prev_value = value
    232232           
    233         N.testing.assertTrue(largest_delta<5)
     233        assert largest_delta<5, "Value {} is not less than {}".format(largest_delta, 5)
    234234       
    235235    @testattr(casadi_base = True)
     
    270270        MPC_object.update_state({'_start_c': self.c_0_A, '_start_T': 355})
    271271        MPC_object.sample()
    272         N.testing.assertTrue('Solve_Succeeded', MPC_object.collocator.
     272        N.testing.assert_('Solve_Succeeded', MPC_object.collocator.
    273273                                        solver_object.getStat('return_status'))
    274274
     
    357357        # Assert that problem was infeasible and that the returned input is
    358358        # the next input from the last succesful optimization
    359         N.testing.assertTrue('Infeasible_Problem_Detected', MPC_object.collocator.solver_object.getStat('return_status'))
     359        N.testing.assert_('Infeasible_Problem_Detected', MPC_object.collocator.solver_object.getStat('return_status'))
    360360 
    361361        N.testing.assert_almost_equal(u_k2[1](0)[0], result1['Tc'][4],decimal=10)
     
    365365        result2 = MPC_object.get_results_this_sample()
    366366
    367         N.testing.assertTrue(result1==result2)
     367        assert result1==result2, "UNEQUAL VALUES. result1={}\nresult2={}".format(result1, result2)
    368368       
    369369        # Assert that problem was infeasible yet again and that the returned
     
    371371        MPC_object.update_state({'_start_c': 900, '_start_T': 400})
    372372        u_k3 = MPC_object.sample()
    373         N.testing.assertTrue('Infeasible_Problem_Detected', MPC_object.collocator.
     373       
     374        N.testing.assert_('Infeasible_Problem_Detected', MPC_object.collocator.
    374375                                        solver_object.getStat('return_status'))
    375376 
     
    644645        u_k2 = MPC_object.sample()
    645646
    646         N.testing.assertTrue(MPC_object.collocator.warm_start)
     647        N.testing.assert_(MPC_object.collocator.warm_start)
    647648        wsip =\
    648649         MPC_object.collocator.solver_object.getOption('warm_start_init_point')
     
    650651        prl = MPC_object.collocator.solver_object.getOption('print_level')
    651652
    652         N.testing.assertTrue(wsip == 'yes')
     653        N.testing.assert_(wsip == 'yes')
    653654        N.testing.assert_equal(mu_init, 1e-3)
    654655        N.testing.assert_equal(prl,  0)
Note: See TracChangeset for help on using the changeset viewer.