Changeset 13791


Ignore:
Timestamp:
Oct 21, 2019 4:44:36 PM (3 weeks ago)
Author:
randersson
Message:

#5819 Replaced all nose.tools.assert_almost_equal with similar method from numpy instead. Reason is that nosetests seems to fail due to bug:

TypeError: type numpy.ndarray doesn't define round method

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/dev-5819/Python/src/tests_jmodelica/simulation/test_assimulo_interface_fmi.py

    r13600 r13791  
    9999        #Assert that sparse handling has no impact on the number of steps
    100100        assert res1.solver.statistics["nsteps"] == res2.solver.statistics["nsteps"]
    101         nose.tools.assert_almost_equal(res1.final("J1.w"), res2.final("J1.w"), 3)
     101        N.testing.assert_almost_equal(res1.final("J1.w"), res2.final("J1.w"), 3)
    102102       
    103103    @testattr(stddist_base = True)
     
    329329        model = load_fmu("TimeEvents_TestSampling9.fmu")
    330330        model.initialize()
    331         res = model.simulate(0,1, options={"initialize":False});
     331        res = model.simulate(0,1, options={"initialize":False})
    332332        assert res.solver.statistics["ntimeevents"] == 10
    333333
     
    338338        opts["solver"] = "CVode"
    339339        opts["CVode_options"]["rtol"] = 1e-4
    340         res = model.simulate(0,1, options=opts);
    341         nose.tools.assert_almost_equal(model.get("s"), 2.8)
     340        res = model.simulate(0,1, options=opts)
     341        N.testing.assert_almost_equal(model.get("s"), 2.8)
    342342        assert res.solver.statistics["ntimeevents"] == 2     
    343343
     
    592592        opts["CVode_options"]["rtol"] = 1e-4
    593593        res = model.simulate(0,1, options=opts);
    594         nose.tools.assert_almost_equal(model.get("s"), 2.8)
     594        N.testing.assert_almost_equal(model.get("s"), 2.8)
    595595        assert res.solver.statistics["ntimeevents"] == 2               
    596596
     
    616616        var = res["freeMotionScalarInit.angle_2"]
    617617       
    618         nose.tools.assert_almost_equal(abs(max(var)), 0.00, 2)
    619         nose.tools.assert_almost_equal(abs(min(var)), 2.54, 2)
     618        N.testing.assert_almost_equal(abs(max(var)), 0.00, 2)
     619        N.testing.assert_almost_equal(abs(min(var)), 2.54, 2)
    620620
    621621class Test_Events:
     
    644644        res = model.simulate()
    645645       
    646         nose.tools.assert_almost_equal(res.final("s"), -1.0)
     646        N.testing.assert_almost_equal(res.final("s"), -1.0)
    647647   
    648648    @testattr(stddist_full = True)
     
    668668        model.initialize()
    669669       
    670         nose.tools.assert_almost_equal(model.get("mode"), 0.0)
    671         nose.tools.assert_almost_equal(model.get("sa"), 0.0)
     670        N.testing.assert_almost_equal(model.get("mode"), 0.0)
     671        N.testing.assert_almost_equal(model.get("sa"), 0.0)
    672672       
    673673    @testattr(stddist_base = True)
     
    676676        res = model.simulate()
    677677       
    678         nose.tools.assert_almost_equal(res["x[1]"][-1], 0)
    679         nose.tools.assert_almost_equal(res["x[2]"][-1], 0)
    680         nose.tools.assert_almost_equal(res["x[3]"][-1], 0)
    681         nose.tools.assert_almost_equal(res["x[4]"][-1], -0.406)
    682         nose.tools.assert_almost_equal(res["x[5]"][-1], -0.406)
    683         nose.tools.assert_almost_equal(res["x[6]"][-1], -0.406)
    684         nose.tools.assert_almost_equal(res["x[7]"][-1], 0.94)
     678        N.testing.assert_almost_equal(res["x[1]"][-1], 0)
     679        N.testing.assert_almost_equal(res["x[2]"][-1], 0)
     680        N.testing.assert_almost_equal(res["x[3]"][-1], 0)
     681        N.testing.assert_almost_equal(res["x[4]"][-1], -0.406)
     682        N.testing.assert_almost_equal(res["x[5]"][-1], -0.406)
     683        N.testing.assert_almost_equal(res["x[6]"][-1], -0.406)
     684        N.testing.assert_almost_equal(res["x[7]"][-1], 0.94)
    685685       
    686686    @testattr(stddist_base = True)
     
    689689        res = model.simulate(final_time=2.0)
    690690       
    691         nose.tools.assert_almost_equal(res["y"][0], 1.0)
    692         nose.tools.assert_almost_equal(res["w"][0], 0.0)
    693         nose.tools.assert_almost_equal(res["x"][-1], 2.0)
    694         nose.tools.assert_almost_equal(res["y"][-1],1.58385,4)
    695         nose.tools.assert_almost_equal(res["z"][-1], 0.0)
    696         nose.tools.assert_almost_equal(res["w"][-1], 1.0)
     691        N.testing.assert_almost_equal(res["y"][0], 1.0)
     692        N.testing.assert_almost_equal(res["w"][0], 0.0)
     693        N.testing.assert_almost_equal(res["x"][-1], 2.0)
     694        N.testing.assert_almost_equal(res["y"][-1],1.58385,4)
     695        N.testing.assert_almost_equal(res["z"][-1], 0.0)
     696        N.testing.assert_almost_equal(res["w"][-1], 1.0)
    697697       
    698698    @testattr(stddist_base = True)
     
    701701        model.initialize(tolerance=1e-1)
    702702       
    703         nose.tools.assert_almost_equal(model.get("x"), -1e-6)
     703        N.testing.assert_almost_equal(model.get("x"), -1e-6)
    704704   
    705705    @testattr(stddist_full = True)
     
    707707        model = load_fmu("EventIter_InitialPhasing1.fmu")
    708708        res = model.simulate(final_time=0.1)
    709         nose.tools.assert_almost_equal(res["b1"][0], 0.0)
    710         nose.tools.assert_almost_equal(res["b2"][0], 1.0)
     709        N.testing.assert_almost_equal(res["b1"][0], 0.0)
     710        N.testing.assert_almost_equal(res["b2"][0], 1.0)
    711711       
    712712    @testattr(stddist_base=True)
     
    714714        model = load_fmu("EventIter_EventIterDiscreteReals.fmu")
    715715        res = model.simulate(final_time=1.0)
    716         nose.tools.assert_almost_equal(res["T1"][0], 0.0)
    717         nose.tools.assert_almost_equal(res["start"][0], 1.0)
    718         nose.tools.assert_almost_equal(res["T2"][0], 0.0)
     716        N.testing.assert_almost_equal(res["T1"][0], 0.0)
     717        N.testing.assert_almost_equal(res["start"][0], 1.0)
     718        N.testing.assert_almost_equal(res["T2"][0], 0.0)
    719719
    720720class Test_Relations:
     
    741741        res = model.simulate(final_time=3.5, input=input_object,options=opts)
    742742       
    743         nose.tools.assert_almost_equal(N.interp(0.75,res["time"],res["y"]),0.5,places=2)
    744         nose.tools.assert_almost_equal(N.interp(2.25,res["time"],res["y"]),0.5,places=2)
     743        N.testing.assert_almost_equal(N.interp(0.75,res["time"],res["y"]),0.5,places=2)
     744        N.testing.assert_almost_equal(N.interp(2.25,res["time"],res["y"]),0.5,places=2)
    745745        nose.tools.assert_not_almost_equal(N.interp(0.25,res["time"],res["y"]),0.5,places=2)
    746746        nose.tools.assert_not_almost_equal(N.interp(2.75,res["time"],res["y"]),0.5,places=2)
    747747        nose.tools.assert_not_almost_equal(N.interp(0.75,res["time"],res["x"]),0.5,places=2)
    748748        nose.tools.assert_not_almost_equal(N.interp(2.25,res["time"],res["x"]),0.5,places=2)
    749         nose.tools.assert_almost_equal(N.interp(1.5,res["time"],res["y"]),0.5,places=2)
     749        N.testing.assert_almost_equal(N.interp(1.5,res["time"],res["y"]),0.5,places=2)
    750750       
    751751    @testattr(stddist_full = True)
     
    756756        res = model.simulate(final_time=3.5, input=input_object,options=opts)
    757757       
    758         nose.tools.assert_almost_equal(N.interp(0.75,res["time"],res["y"]),0.5,places=2)
    759         nose.tools.assert_almost_equal(N.interp(2.25,res["time"],res["y"]),0.5,places=2)
     758        N.testing.assert_almost_equal(N.interp(0.75,res["time"],res["y"]),0.5,places=2)
     759        N.testing.assert_almost_equal(N.interp(2.25,res["time"],res["y"]),0.5,places=2)
    760760        nose.tools.assert_not_almost_equal(N.interp(0.25,res["time"],res["y"]),0.5,places=2)
    761761        nose.tools.assert_not_almost_equal(N.interp(2.75,res["time"],res["y"]),0.5,places=2)
    762762        nose.tools.assert_not_almost_equal(N.interp(0.75,res["time"],res["x"]),0.5,places=2)
    763763        nose.tools.assert_not_almost_equal(N.interp(2.25,res["time"],res["x"]),0.5,places=2)
    764         nose.tools.assert_almost_equal(N.interp(1.5,res["time"],res["y"]),0.5,places=2)
     764        N.testing.assert_almost_equal(N.interp(1.5,res["time"],res["y"]),0.5,places=2)
    765765       
    766766    @testattr(stddist_full = True)
     
    771771        res = model.simulate(final_time=3.5, input=input_object,options=opts)
    772772       
    773         nose.tools.assert_almost_equal(N.interp(0.75,res["time"],res["y"]),0.5,places=2)
    774         nose.tools.assert_almost_equal(N.interp(2.25,res["time"],res["y"]),0.5,places=2)
     773        N.testing.assert_almost_equal(N.interp(0.75,res["time"],res["y"]),0.5,places=2)
     774        N.testing.assert_almost_equal(N.interp(2.25,res["time"],res["y"]),0.5,places=2)
    775775        nose.tools.assert_not_almost_equal(N.interp(0.25,res["time"],res["y"]),0.5,places=2)
    776776        nose.tools.assert_not_almost_equal(N.interp(2.75,res["time"],res["y"]),0.5,places=2)
    777777        nose.tools.assert_not_almost_equal(N.interp(0.75,res["time"],res["x"]),0.5,places=2)
    778778        nose.tools.assert_not_almost_equal(N.interp(2.25,res["time"],res["x"]),0.5,places=2)
    779         nose.tools.assert_almost_equal(N.interp(1.5,res["time"],res["y"]),0.5,places=2)
     779        N.testing.assert_almost_equal(N.interp(1.5,res["time"],res["y"]),0.5,places=2)
    780780       
    781781    @testattr(stddist_full = True)
     
    786786        res = model.simulate(final_time=3.5, input=input_object,options=opts)
    787787       
    788         nose.tools.assert_almost_equal(N.interp(0.75,res["time"],res["y"]),0.5,places=2)
    789         nose.tools.assert_almost_equal(N.interp(2.25,res["time"],res["y"]),0.5,places=2)
     788        N.testing.assert_almost_equal(N.interp(0.75,res["time"],res["y"]),0.5,places=2)
     789        N.testing.assert_almost_equal(N.interp(2.25,res["time"],res["y"]),0.5,places=2)
    790790        nose.tools.assert_not_almost_equal(N.interp(0.25,res["time"],res["y"]),0.5,places=2)
    791791        nose.tools.assert_not_almost_equal(N.interp(2.75,res["time"],res["y"]),0.5,places=2)
    792792        nose.tools.assert_not_almost_equal(N.interp(0.75,res["time"],res["x"]),0.5,places=2)
    793793        nose.tools.assert_not_almost_equal(N.interp(2.25,res["time"],res["x"]),0.5,places=2)
    794         nose.tools.assert_almost_equal(N.interp(1.5,res["time"],res["y"]),0.5,places=2)
     794        N.testing.assert_almost_equal(N.interp(1.5,res["time"],res["y"]),0.5,places=2)
    795795       
    796796    @testattr(stddist_full = True)
     
    800800        res = model.simulate(final_time=0.1)
    801801       
    802         nose.tools.assert_almost_equal(res.initial("x"),1.0,places=3)
    803         nose.tools.assert_almost_equal(res.initial("y"),0.0,places=3)
     802        N.testing.assert_almost_equal(res.initial("x"),1.0,places=3)
     803        N.testing.assert_almost_equal(res.initial("y"),0.0,places=3)
    804804       
    805805    @testattr(stddist_full = True)
     
    809809        res = model.simulate(final_time=0.1)
    810810       
    811         nose.tools.assert_almost_equal(res.initial("x"),0.0,places=3)
    812         nose.tools.assert_almost_equal(res.initial("y"),1.0,places=3)
     811        N.testing.assert_almost_equal(res.initial("x"),0.0,places=3)
     812        N.testing.assert_almost_equal(res.initial("y"),1.0,places=3)
    813813
    814814    @testattr(stddist_full = True)
     
    818818        res = model.simulate(final_time=10)
    819819       
    820         nose.tools.assert_almost_equal(N.interp(3.00,res["time"],res["der(v1)"]),1.0,places=3)
    821         nose.tools.assert_almost_equal(N.interp(3.40,res["time"],res["der(v1)"]),0.0,places=3)
    822         nose.tools.assert_almost_equal(N.interp(8.00,res["time"],res["der(v1)"]),0.0,places=3)
    823         nose.tools.assert_almost_equal(N.interp(8.25,res["time"],res["der(v1)"]),1.0,places=3)
    824         nose.tools.assert_almost_equal(N.interp(4.00,res["time"],res["der(v2)"]),1.0,places=3)
    825         nose.tools.assert_almost_equal(N.interp(4.20,res["time"],res["der(v2)"]),0.0,places=3)
    826         nose.tools.assert_almost_equal(N.interp(7.00,res["time"],res["der(v2)"]),0.0,places=3)
    827         nose.tools.assert_almost_equal(N.interp(7.20,res["time"],res["der(v2)"]),1.0,places=3)
     820        N.testing.assert_almost_equal(N.interp(3.00,res["time"],res["der(v1)"]),1.0,places=3)
     821        N.testing.assert_almost_equal(N.interp(3.40,res["time"],res["der(v1)"]),0.0,places=3)
     822        N.testing.assert_almost_equal(N.interp(8.00,res["time"],res["der(v1)"]),0.0,places=3)
     823        N.testing.assert_almost_equal(N.interp(8.25,res["time"],res["der(v1)"]),1.0,places=3)
     824        N.testing.assert_almost_equal(N.interp(4.00,res["time"],res["der(v2)"]),1.0,places=3)
     825        N.testing.assert_almost_equal(N.interp(4.20,res["time"],res["der(v2)"]),0.0,places=3)
     826        N.testing.assert_almost_equal(N.interp(7.00,res["time"],res["der(v2)"]),0.0,places=3)
     827        N.testing.assert_almost_equal(N.interp(7.20,res["time"],res["der(v2)"]),1.0,places=3)
    828828
    829829class Test_NonLinear_Systems:
     
    908908
    909909        for i,iv in enumerate(ivs):
    910             nose.tools.assert_almost_equal(fprime(iv) ,df[i], places=12) 
     910            N.testing.assert_almost_equal(fprime(iv) ,df[i], places=12) 
    911911           
    912912    @testattr(stddist_base = True)
     
    922922        sol_neg =-N.sqrt(1e-7)+1.5
    923923
    924         nose.tools.assert_almost_equal(run_model(sol_pos+1e-16) ,sol_pos)
    925         nose.tools.assert_almost_equal(run_model(sol_pos-1e-16) ,sol_pos)
    926         nose.tools.assert_almost_equal(run_model(sol_pos+1e-14) ,sol_pos)
    927         nose.tools.assert_almost_equal(run_model(sol_pos-1e-14) ,sol_pos)
    928        
    929         nose.tools.assert_almost_equal(run_model(sol_neg+1e-16) ,sol_neg)
    930         nose.tools.assert_almost_equal(run_model(sol_neg-1e-16) ,sol_neg)
    931         nose.tools.assert_almost_equal(run_model(sol_neg+1e-14) ,sol_neg)
    932         nose.tools.assert_almost_equal(run_model(sol_neg-1e-14) ,sol_neg)
     924        N.testing.assert_almost_equal(run_model(sol_pos+1e-16) ,sol_pos)
     925        N.testing.assert_almost_equal(run_model(sol_pos-1e-16) ,sol_pos)
     926        N.testing.assert_almost_equal(run_model(sol_pos+1e-14) ,sol_pos)
     927        N.testing.assert_almost_equal(run_model(sol_pos-1e-14) ,sol_pos)
     928       
     929        N.testing.assert_almost_equal(run_model(sol_neg+1e-16) ,sol_neg)
     930        N.testing.assert_almost_equal(run_model(sol_neg-1e-16) ,sol_neg)
     931        N.testing.assert_almost_equal(run_model(sol_neg+1e-14) ,sol_neg)
     932        N.testing.assert_almost_equal(run_model(sol_neg-1e-14) ,sol_neg)
    933933       
    934934    @testattr(stddist_base = True)
     
    940940        model.initialize()
    941941       
    942         nose.tools.assert_almost_equal(model.get("i"),-9.9760004108556469E-03)
     942        N.testing.assert_almost_equal(model.get("i"),-9.9760004108556469E-03)
    943943       
    944944    @testattr(stddist_base = True)
     
    951951        model.set("i_start",i)
    952952        model.initialize()
    953         nose.tools.assert_almost_equal(model.get("i"),i)
     953        N.testing.assert_almost_equal(model.get("i"),i)
    954954       
    955955        model.reset()
     
    957957        model.set("i_start", i+i*1e-15)
    958958        model.initialize()
    959         nose.tools.assert_almost_equal(model.get("i"),i)
     959        N.testing.assert_almost_equal(model.get("i"),i)
    960960       
    961961        model.reset()
     
    963963        model.set("i_start", i-i*1e-15)
    964964        model.initialize()
    965         nose.tools.assert_almost_equal(model.get("i"),i)
     965        N.testing.assert_almost_equal(model.get("i"),i)
    966966       
    967967       
     
    10071007        model.initialize()
    10081008       
    1009         nose.tools.assert_almost_equal(model.get("x") ,2.76929235)
     1009        N.testing.assert_almost_equal(model.get("x") ,2.76929235)
    10101010       
    10111011    @testattr(stddist_base = True)
     
    10151015        model.initialize()
    10161016       
    1017         nose.tools.assert_almost_equal(model.get("x"), 0.680716920494911)
    1018         nose.tools.assert_almost_equal(model.get("y"), 0.0)
     1017        N.testing.assert_almost_equal(model.get("x"), 0.680716920494911)
     1018        N.testing.assert_almost_equal(model.get("y"), 0.0)
    10191019       
    10201020    @testattr(stddist_base = True)
     
    10231023        model.set("_use_Brent_in_1d", False)
    10241024        model.initialize()
    1025         nose.tools.assert_almost_equal(model.get('state_a_p'), 17.78200351)
     1025        N.testing.assert_almost_equal(model.get('state_a_p'), 17.78200351)
    10261026       
    10271027    @testattr(stddist_base = True)
     
    10341034        model = load_fmu("NonLinear_EventIteration1.fmu")
    10351035        model.initialize()
    1036         nose.tools.assert_almost_equal(model.get('iter_var_1'), 872.98062403)
     1036        N.testing.assert_almost_equal(model.get('iter_var_1'), 872.98062403)
    10371037       
    10381038    @testattr(stddist_base = True)
     
    10401040        model = load_fmu("NonLinear_NonLinear6.fmu")
    10411041        model.initialize()
    1042         nose.tools.assert_almost_equal(model.get('x'), 1.0)
    1043         nose.tools.assert_almost_equal(model.get('z'), -1.0)
     1042        N.testing.assert_almost_equal(model.get('x'), 1.0)
     1043        N.testing.assert_almost_equal(model.get('z'), -1.0)
    10441044       
    10451045    @testattr(stddist_base = True)
     
    10471047        model = load_fmu("NonLinear_NonLinear7.fmu")
    10481048        model.initialize()
    1049         nose.tools.assert_almost_equal(model.get('x'), 1.0)
    1050         nose.tools.assert_almost_equal(model.get('z'), 1.0)
     1049        N.testing.assert_almost_equal(model.get('x'), 1.0)
     1050        N.testing.assert_almost_equal(model.get('z'), 1.0)
    10511051   
    10521052class Test_Singular_Systems:
     
    10771077       
    10781078        res = model.simulate(final_time=2)
    1079         nose.tools.assert_almost_equal(res.final('y') ,1.000000000)
     1079        N.testing.assert_almost_equal(res.final('y') ,1.000000000)
    10801080       
    10811081    @testattr(stddist_base = True)
     
    10851085       
    10861086        res = model.simulate(final_time=4)
    1087         nose.tools.assert_almost_equal(res.final('y') ,1.000000000)
    1088         nose.tools.assert_almost_equal(res.final('w') ,2.000000000)
     1087        N.testing.assert_almost_equal(res.final('y') ,1.000000000)
     1088        N.testing.assert_almost_equal(res.final('w') ,2.000000000)
    10891089       
    10901090    @testattr(stddist_base = True)
     
    11001100        x = res["x"]
    11011101        for i in range(4):
    1102             nose.tools.assert_almost_equal(x[i] ,0.000000000)
     1102            N.testing.assert_almost_equal(x[i] ,0.000000000)
    11031103        for i in range(4,8):
    1104             nose.tools.assert_almost_equal(x[i] ,0.0100000)
     1104            N.testing.assert_almost_equal(x[i] ,0.0100000)
    11051105   
    11061106    @testattr(stddist_base = True)
     
    11411141        model.initialize()
    11421142       
    1143         nose.tools.assert_almost_equal(model.get("x") ,1.000000000)
    1144         nose.tools.assert_almost_equal(model.get("y") ,2.000000000)
    1145         nose.tools.assert_almost_equal(model.get("z") ,0.000000000)
     1143        N.testing.assert_almost_equal(model.get("x") ,1.000000000)
     1144        N.testing.assert_almost_equal(model.get("y") ,2.000000000)
     1145        N.testing.assert_almost_equal(model.get("z") ,0.000000000)
    11461146       
    11471147    @testattr(stddist_base = True)
     
    11641164        model.initialize()
    11651165       
    1166         nose.tools.assert_almost_equal(model.get("x") ,1.000000000)
    1167         nose.tools.assert_almost_equal(model.get("y") ,200000.0000)
    1168         nose.tools.assert_almost_equal(model.get("z") ,0.000000000)
     1166        N.testing.assert_almost_equal(model.get("x") ,1.000000000)
     1167        N.testing.assert_almost_equal(model.get("y") ,200000.0000)
     1168        N.testing.assert_almost_equal(model.get("z") ,0.000000000)
    11691169       
    11701170    @testattr(stddist_base = True)
     
    11781178        model.initialize()
    11791179       
    1180         nose.tools.assert_almost_equal(model.get("x") ,1.000000000)
    1181         nose.tools.assert_almost_equal(model.get("y") ,2e-10)
    1182         nose.tools.assert_almost_equal(model.get("z") ,0.000000000)
     1180        N.testing.assert_almost_equal(model.get("x") ,1.000000000)
     1181        N.testing.assert_almost_equal(model.get("y") ,2e-10)
     1182        N.testing.assert_almost_equal(model.get("z") ,0.000000000)
    11831183       
    11841184    @testattr(stddist_base = True)
     
    11891189        model.initialize()
    11901190       
    1191         nose.tools.assert_almost_equal(model.get("x") ,5)
    1192         nose.tools.assert_almost_equal(model.get("y") ,0)
    1193         nose.tools.assert_almost_equal(model.get("z") ,0.000000000)
     1191        N.testing.assert_almost_equal(model.get("x") ,5)
     1192        N.testing.assert_almost_equal(model.get("y") ,0)
     1193        N.testing.assert_almost_equal(model.get("z") ,0.000000000)
    11941194   
    11951195    @testattr(stddist_base = True)
     
    12031203        res = model.simulate()
    12041204       
    1205         nose.tools.assert_almost_equal(res["z"][0] ,0.000000000)
    1206         nose.tools.assert_almost_equal(res["z"][-1] ,-1.000000000)
     1205        N.testing.assert_almost_equal(res["z"][0] ,0.000000000)
     1206        N.testing.assert_almost_equal(res["z"][-1] ,-1.000000000)
    12071207   
    12081208    @testattr(stddist_base = True)
     
    12171217        model = load_fmu("Singular_ZeroColumnJacobian.fmu");
    12181218        res = model.simulate();
    1219         nose.tools.assert_almost_equal(res["x"][0], -1)
     1219        N.testing.assert_almost_equal(res["x"][0], -1)
    12201220       
    12211221    @testattr(stddist_base = True)
     
    12231223        model = load_fmu("Singular_ZeroColumnJacobian2.fmu");
    12241224        res = model.simulate();
    1225         nose.tools.assert_almost_equal(res["x"][0], -1)
     1225        N.testing.assert_almost_equal(res["x"][0], -1)
    12261226
    12271227class Test_FMI_ODE_CS_2:
     
    12521252        input = ('onSwitch', step)
    12531253        res = model.simulate(final_time=0.8, options=opts, input=input)
    1254         nose.tools.assert_almost_equal(res.final("T"), 11.22494, 2)
     1254        N.testing.assert_almost_equal(res.final("T"), 11.22494, 2)
    12551255       
    12561256    @testattr(stddist_base = True)
     
    12681268        input = ('onSwitch', step)
    12691269        res = model.simulate(final_time=0.8, options=opts, input=input)
    1270         nose.tools.assert_almost_equal(res.final("T"), 20.67587, 2)
     1270        N.testing.assert_almost_equal(res.final("T"), 20.67587, 2)
    12711271       
    12721272    @testattr(stddist_full = True)
     
    12961296        res = model.simulate(final_time=1,options=opts)
    12971297       
    1298         nose.tools.assert_almost_equal(res.final("x"), 3.89, 2)
     1298        N.testing.assert_almost_equal(res.final("x"), 3.89, 2)
    12991299
    13001300class Test_FMI_ODE_CS:
     
    13371337        res = model.simulate(final_time=1,options=opts)
    13381338       
    1339         nose.tools.assert_almost_equal(res.final("x"), 3.89, 2)
     1339        N.testing.assert_almost_equal(res.final("x"), 3.89, 2)
    13401340       
    13411341    @testattr(stddist_full = True)
     
    13801380        res = model.simulate(input=input_object)
    13811381       
    1382         nose.tools.assert_almost_equal(res.final('onSwitch') ,1.000000000) 
     1382        N.testing.assert_almost_equal(res.final('onSwitch') ,1.000000000) 
    13831383       
    13841384        model.reset()
     
    13971397        res = model.simulate(input=input_object)
    13981398       
    1399         nose.tools.assert_almost_equal(res.final('y') ,1.000000000)
    1400         nose.tools.assert_almost_equal(res.final('u') ,1.000000000)
     1399        N.testing.assert_almost_equal(res.final('y') ,1.000000000)
     1400        N.testing.assert_almost_equal(res.final('u') ,1.000000000)
    14011401       
    14021402        model.reset()
     
    14061406        res = model.simulate(input=input_object)
    14071407       
    1408         nose.tools.assert_almost_equal(res.final('y') ,1.000000000)
    1409         nose.tools.assert_almost_equal(res.final('u') ,1.000000000)
     1408        N.testing.assert_almost_equal(res.final('y') ,1.000000000)
     1409        N.testing.assert_almost_equal(res.final('u') ,1.000000000)
    14101410   
    14111411    @testattr(stddist_full = True)
     
    14871487        res = model.simulate(final_time=10)
    14881488       
    1489         nose.tools.assert_almost_equal(res.initial('x') ,1.000000000)
    1490         nose.tools.assert_almost_equal(res.final('x'),-2.000000000)
    1491         nose.tools.assert_almost_equal(res.initial('y') ,-1.000000000)
    1492         nose.tools.assert_almost_equal(res.final('y'),-1.000000000)
    1493         nose.tools.assert_almost_equal(res.initial('z') ,1.000000000)
    1494         nose.tools.assert_almost_equal(res.final('z'),4.000000000)
     1489        N.testing.assert_almost_equal(res.initial('x') ,1.000000000)
     1490        N.testing.assert_almost_equal(res.final('x'),-2.000000000)
     1491        N.testing.assert_almost_equal(res.initial('y') ,-1.000000000)
     1492        N.testing.assert_almost_equal(res.final('y'),-1.000000000)
     1493        N.testing.assert_almost_equal(res.initial('z') ,1.000000000)
     1494        N.testing.assert_almost_equal(res.final('z'),4.000000000)
    14951495       
    14961496    @testattr(stddist_full = True)
     
    15031503        res = model.simulate(final_time=10)
    15041504       
    1505         nose.tools.assert_almost_equal(res.initial('x') ,-1.000000000)
    1506         nose.tools.assert_almost_equal(res.final('x'),-1.000000000)
     1505        N.testing.assert_almost_equal(res.initial('x') ,-1.000000000)
     1506        N.testing.assert_almost_equal(res.final('x'),-1.000000000)
    15071507       
    15081508    @testattr(stddist_full = True)
     
    15151515        res = model.simulate(final_time=10, options={"solver": "Radau5ODE"})
    15161516       
    1517         nose.tools.assert_almost_equal(res.initial('x') ,1.000000000)
    1518         nose.tools.assert_almost_equal(res.final('x'),-2.000000000)
    1519         nose.tools.assert_almost_equal(res.initial('y') ,-1.000000000)
    1520         nose.tools.assert_almost_equal(res.final('y'),-1.000000000)
    1521         nose.tools.assert_almost_equal(res.initial('z') ,1.000000000)
    1522         nose.tools.assert_almost_equal(res.final('z'),4.000000000)
     1517        N.testing.assert_almost_equal(res.initial('x') ,1.000000000)
     1518        N.testing.assert_almost_equal(res.final('x'),-2.000000000)
     1519        N.testing.assert_almost_equal(res.initial('y') ,-1.000000000)
     1520        N.testing.assert_almost_equal(res.final('y'),-1.000000000)
     1521        N.testing.assert_almost_equal(res.initial('z') ,1.000000000)
     1522        N.testing.assert_almost_equal(res.final('z'),4.000000000)
    15231523
    15241524class Test_FMI_ODE:
     
    16891689        res = model.simulate(final_time=10)
    16901690       
    1691         nose.tools.assert_almost_equal(res.initial('x') ,1.000000000)
    1692         nose.tools.assert_almost_equal(res.final('x'),-2.000000000)
    1693         nose.tools.assert_almost_equal(res.initial('y') ,-1.000000000)
    1694         nose.tools.assert_almost_equal(res.final('y'),-1.000000000)
    1695         nose.tools.assert_almost_equal(res.initial('z') ,1.000000000)
    1696         nose.tools.assert_almost_equal(res.final('z'),4.000000000)
     1691        N.testing.assert_almost_equal(res.initial('x') ,1.000000000)
     1692        N.testing.assert_almost_equal(res.final('x'),-2.000000000)
     1693        N.testing.assert_almost_equal(res.initial('y') ,-1.000000000)
     1694        N.testing.assert_almost_equal(res.final('y'),-1.000000000)
     1695        N.testing.assert_almost_equal(res.initial('z') ,1.000000000)
     1696        N.testing.assert_almost_equal(res.final('z'),4.000000000)
    16971697       
    16981698    @testattr(stddist_full = True)
     
    17051705        res = model.simulate(final_time=10)
    17061706       
    1707         nose.tools.assert_almost_equal(res.initial('x') ,-1.000000000)
    1708         nose.tools.assert_almost_equal(res.final('x'),-1.000000000)
     1707        N.testing.assert_almost_equal(res.initial('x') ,-1.000000000)
     1708        N.testing.assert_almost_equal(res.final('x'),-1.000000000)
    17091709       
    17101710    @testattr(stddist_full = True)
     
    17711771        #sol = self._bounceSim._sol_real
    17721772       
    1773         #nose.tools.assert_almost_equal(sol[0][0],1.000000000)
    1774         #nose.tools.assert_almost_equal(sol[0][1],0.000000000)
    1775         #nose.tools.assert_almost_equal(sol[0][2],0.000000000)
    1776         #nose.tools.assert_almost_equal(sol[0][3],-9.81000000)
     1773        #N.testing.assert_almost_equal(sol[0][0],1.000000000)
     1774        #N.testing.assert_almost_equal(sol[0][1],0.000000000)
     1775        #N.testing.assert_almost_equal(sol[0][2],0.000000000)
     1776        #N.testing.assert_almost_equal(sol[0][3],-9.81000000)
    17771777       
    17781778    @testattr(stddist_full = True)
     
    17861786        rhs = self._bounceSim.rhs(t,y)
    17871787       
    1788         nose.tools.assert_almost_equal(rhs[0],1.00000000)
    1789         nose.tools.assert_almost_equal(rhs[1],-9.8100000)
     1788        N.testing.assert_almost_equal(rhs[0],1.00000000)
     1789        N.testing.assert_almost_equal(rhs[1],-9.8100000)
    17901790
    17911791   
     
    18001800        event = self._bounceSim.g(t,y,None)
    18011801       
    1802         nose.tools.assert_almost_equal(event[0],1.00000000)
     1802        N.testing.assert_almost_equal(event[0],1.00000000)
    18031803       
    18041804        y = N.array([0.5,1.0])
    18051805        event = self._bounceSim.g(t,y,None)
    18061806       
    1807         nose.tools.assert_almost_equal(event[0],0.50000000)
     1807        N.testing.assert_almost_equal(event[0],0.50000000)
    18081808
    18091809       
     
    18391839        self._bounceSim.handle_event(solver, None)
    18401840
    1841         nose.tools.assert_almost_equal(solver.y[0],1.00000000)
    1842         nose.tools.assert_almost_equal(solver.y[1],-0.70000000)
     1841        N.testing.assert_almost_equal(solver.y[0],1.00000000)
     1842        N.testing.assert_almost_equal(solver.y[1],-0.70000000)
    18431843       
    18441844        #Further testing of the handle_event function is needed.
     
    18681868        res = model.simulate(final_time=10, options=opts)
    18691869   
    1870         nose.tools.assert_almost_equal(res.initial('x'), 1.000000, 4)
    1871         nose.tools.assert_almost_equal(res.initial('y'), 0.000000, 4)
    1872         nose.tools.assert_almost_equal(res.final('x'), 0.27510283167449501, 4)
    1873         nose.tools.assert_almost_equal(res.final('y'), -0.96141480746068897, 4)
     1870        N.testing.assert_almost_equal(res.initial('x'), 1.000000, 4)
     1871        N.testing.assert_almost_equal(res.initial('y'), 0.000000, 4)
     1872        N.testing.assert_almost_equal(res.final('x'), 0.27510283167449501, 4)
     1873        N.testing.assert_almost_equal(res.final('y'), -0.96141480746068897, 4)
    18741874       
    18751875    @testattr(windows_base = True)
     
    19271927        solver = res.solver
    19281928       
    1929         nose.tools.assert_almost_equal(solver.t, 1.856045, places=3)   
     1929        N.testing.assert_almost_equal(solver.t, 1.856045, places=3)   
    19301930       
    19311931    @testattr(windows_full = True)
     
    19391939        solver = res.solver
    19401940       
    1941         nose.tools.assert_almost_equal(solver.t, 1.856045, places=3)       
     1941        N.testing.assert_almost_equal(solver.t, 1.856045, places=3)       
    19421942
    19431943    @testattr(noncompliantfmi = True)
     
    19741974        sim_res = model.simulate(final_time=10)
    19751975
    1976         nose.tools.assert_almost_equal(sim_res.initial('x'), 2.00000, 4)
    1977         nose.tools.assert_almost_equal(sim_res.final('x'), 10.000000, 4)
    1978         nose.tools.assert_almost_equal(sim_res.final('y'), 3.0000000, 4)
    1979         nose.tools.assert_almost_equal(sim_res.final('z'), 2.0000000, 4)
     1976        N.testing.assert_almost_equal(sim_res.initial('x'), 2.00000, 4)
     1977        N.testing.assert_almost_equal(sim_res.final('x'), 10.000000, 4)
     1978        N.testing.assert_almost_equal(sim_res.final('y'), 3.0000000, 4)
     1979        N.testing.assert_almost_equal(sim_res.final('z'), 2.0000000, 4)
    19801980       
    19811981        fmu_name = compile_fmu('EventIter.EventStartIter', os.path.join(path_to_mos,'EventIter.mo'))
     
    19851985        sim_res = model.simulate(final_time=10)
    19861986
    1987         nose.tools.assert_almost_equal(sim_res.initial('x'), 1.00000, 4)
    1988         nose.tools.assert_almost_equal(sim_res.initial('y'), -1.00000, 4)
    1989         nose.tools.assert_almost_equal(sim_res.initial('z'), 1.00000, 4)
    1990         nose.tools.assert_almost_equal(sim_res.final('x'), -2.000000, 4)
    1991         nose.tools.assert_almost_equal(sim_res.final('y'), -1.0000000, 4)
    1992         nose.tools.assert_almost_equal(sim_res.final('z'), 4.0000000, 4)
     1987        N.testing.assert_almost_equal(sim_res.initial('x'), 1.00000, 4)
     1988        N.testing.assert_almost_equal(sim_res.initial('y'), -1.00000, 4)
     1989        N.testing.assert_almost_equal(sim_res.initial('z'), 1.00000, 4)
     1990        N.testing.assert_almost_equal(sim_res.final('x'), -2.000000, 4)
     1991        N.testing.assert_almost_equal(sim_res.final('y'), -1.0000000, 4)
     1992        N.testing.assert_almost_equal(sim_res.final('z'), 4.0000000, 4)
    19931993   
    19941994    @testattr(stddist_base = True)
     
    20042004        res = bounce.simulate(start_time=2.,final_time=5.,options=opts)
    20052005
    2006         nose.tools.assert_almost_equal(res.initial('h'),1.000000,5)
    2007         nose.tools.assert_almost_equal(res.final('h'),-0.98048862,4)
    2008         nose.tools.assert_almost_equal(res.final('time'),5.000000,5)
     2006        N.testing.assert_almost_equal(res.initial('h'),1.000000,5)
     2007        N.testing.assert_almost_equal(res.final('h'),-0.98048862,4)
     2008        N.testing.assert_almost_equal(res.final('time'),5.000000,5)
    20092009       
    20102010   
     
    20222022        res = bounce.simulate(final_time=3., options=opts)
    20232023       
    2024         nose.tools.assert_almost_equal(res.initial('h'),1.000000,5)
    2025         nose.tools.assert_almost_equal(res.final('h'),-0.9804523,5)
    2026         nose.tools.assert_almost_equal(res.final('time'),3.000000,5)
     2024        N.testing.assert_almost_equal(res.initial('h'),1.000000,5)
     2025        N.testing.assert_almost_equal(res.final('h'),-0.9804523,5)
     2026        N.testing.assert_almost_equal(res.final('time'),3.000000,5)
    20272027       
    20282028        #Writing after
     
    20352035        res = bounce.simulate(final_time=3., options=opt)
    20362036       
    2037         nose.tools.assert_almost_equal(res.initial('h'),1.000000,5)
    2038         nose.tools.assert_almost_equal(res.final('h'),-0.9804523,5)
    2039         nose.tools.assert_almost_equal(res.final('time'),3.000000,5)
     2037        N.testing.assert_almost_equal(res.initial('h'),1.000000,5)
     2038        N.testing.assert_almost_equal(res.final('h'),-0.9804523,5)
     2039        N.testing.assert_almost_equal(res.final('time'),3.000000,5)
    20402040       
    20412041        #Test with predefined FMUModel
     
    20442044        res = model.simulate(final_time=3.,options=opts)
    20452045
    2046         nose.tools.assert_almost_equal(res.initial('h'),1.000000,5)
    2047         nose.tools.assert_almost_equal(res.final('h'),-0.9804523,5)
    2048         nose.tools.assert_almost_equal(res.final('time'),3.000000,5)
     2046        N.testing.assert_almost_equal(res.initial('h'),1.000000,5)
     2047        N.testing.assert_almost_equal(res.final('h'),-0.9804523,5)
     2048        N.testing.assert_almost_equal(res.final('time'),3.000000,5)
    20492049
    20502050
     
    20612061        res = bounce.simulate(final_time=3., options=opts)
    20622062
    2063         nose.tools.assert_almost_equal(res.solver.rtol, 1e-4, 6)
     2063        N.testing.assert_almost_equal(res.solver.rtol, 1e-4, 6)
    20642064        assert res.solver.iter == 'Newton'
    20652065       
    2066         nose.tools.assert_almost_equal(res.initial('h'),1.000000,5)
    2067         nose.tools.assert_almost_equal(res.final('h'),-0.9804523,5)
    2068         nose.tools.assert_almost_equal(res.final('time'),3.000000,5)
     2066        N.testing.assert_almost_equal(res.initial('h'),1.000000,5)
     2067        N.testing.assert_almost_equal(res.final('h'),-0.9804523,5)
     2068        N.testing.assert_almost_equal(res.final('time'),3.000000,5)
    20692069       
    20702070        #Writing continuous
     
    20742074            options={'initialize':True,'CVode_options':{'iter':'FixedPoint','rtol':1e-6,'atol':1e-6}})
    20752075   
    2076         nose.tools.assert_almost_equal(res.solver.rtol, 0.00000100, 7)
     2076        N.testing.assert_almost_equal(res.solver.rtol, 0.00000100, 7)
    20772077        assert res.solver.iter == 'FixedPoint'
    20782078       
    2079         nose.tools.assert_almost_equal(res.initial('h'),1.000000,5)
    2080         nose.tools.assert_almost_equal(res.final('h'),-0.98018113,5)
    2081         nose.tools.assert_almost_equal(res.final('time'),3.000000,5)
     2079        N.testing.assert_almost_equal(res.initial('h'),1.000000,5)
     2080        N.testing.assert_almost_equal(res.final('h'),-0.98018113,5)
     2081        N.testing.assert_almost_equal(res.final('time'),3.000000,5)
    20822082
    20832083    @testattr(stddist_base = True)
     
    20952095        res = bounce.simulate(final_time=3., options=opts)
    20962096       
    2097         nose.tools.assert_almost_equal(res.initial('h'),1.000000,5)
    2098         nose.tools.assert_almost_equal(res.final('h'),-0.9804523,5)
     2097        N.testing.assert_almost_equal(res.initial('h'),1.000000,5)
     2098        N.testing.assert_almost_equal(res.final('h'),-0.9804523,5)
    20992099       
    21002100        bounce.reset()
    21012101        #bounce.initialize()
    21022102       
    2103         nose.tools.assert_almost_equal(bounce.get('h'), 1.00000,5)
     2103        N.testing.assert_almost_equal(bounce.get('h'), 1.00000,5)
    21042104       
    21052105        res = bounce.simulate(final_time=3.,options=opts)
    21062106
    2107         nose.tools.assert_almost_equal(res.initial('h'),1.000000,5)
    2108         nose.tools.assert_almost_equal(res.final('h'),-0.9804523,5)
    2109    
     2107        N.testing.assert_almost_equal(res.initial('h'),1.000000,5)
     2108        N.testing.assert_almost_equal(res.final('h'),-0.9804523,5)
     2109   
Note: See TracChangeset for help on using the changeset viewer.