Changeset 13464


Ignore:
Timestamp:
Sep 13, 2019 9:11:47 AM (3 months ago)
Author:
Christian Andersson
Message:

Updated a few more asserts to output a message and corrected a few more allclose issues. Related to ticket:5836

File:
1 edited

Legend:

Unmodified
Added
Removed
  • PyFMI/trunk/tests/test_fmi.py

    r13439 r13464  
    514514            B = func(use_structure_info=True, output_matrix=A)
    515515            assert A is B #Test that the returned matrix is actually the same as the input
    516             np.allclose(A.toarray(),B.toarray())
     516            assert np.allclose(A.toarray(),B.toarray())
    517517            A = func(use_structure_info=False)
    518518            B = func(use_structure_info=False, output_matrix=A)
    519519            assert A is B
    520             np.allclose(A,B)
     520            assert np.allclose(A,B)
    521521            C = func(use_structure_info=True, output_matrix=A)
    522522            assert A is not C
    523             np.allclose(C.toarray(), A)
     523            assert np.allclose(C.toarray(), A)
    524524            D = func(use_structure_info=False, output_matrix=C)
    525525            assert D is not C
    526             np.allclose(D, C.toarray())
     526            assert np.allclose(D, C.toarray())
    527527       
    528528        B = model._get_B(use_structure_info=True)
     
    565565        [state_dep, input_dep] = model.get_output_dependencies()
    566566       
    567         assert len(state_dep.keys()) == 0
    568         assert len(input_dep.keys()) == 0
     567        assert len(state_dep.keys()) == 0, len(state_dep.keys())
     568        assert len(input_dep.keys()) == 0, len(input_dep.keys())
    569569   
    570570    @testattr(stddist = True)
     
    576576        [state_dep, input_dep] = model.get_derivatives_dependencies()
    577577       
    578         assert len(state_dep.keys()) == 0
    579         assert len(input_dep.keys()) == 0
     578        assert len(state_dep.keys()) == 0, len(state_dep.keys())
     579        assert len(input_dep.keys()) == 0, len(input_dep.keys())
    580580   
    581581    @testattr(stddist = True)
     
    596596        model = FMUModelME2("CoupledClutches.fmu", os.path.join(file_path, "files", "FMUs", "XML", "ME2.0"), _connect_dll=False)
    597597       
    598         assert model.get_variable_unit("J1.w") == "rad/s"
    599         assert model.get_variable_unit("J1.phi") == "rad"
     598        assert model.get_variable_unit("J1.w") == "rad/s", model.get_variable_unit("J1.w")
     599        assert model.get_variable_unit("J1.phi") == "rad", model.get_variable_unit("J1.phi")
    600600       
    601601        nose.tools.assert_raises(FMUException, model.get_variable_unit, "clutch1.useHeatPort")
     
    607607        model = FMUModelME2("CoupledClutches.fmu", os.path.join(file_path, "files", "FMUs", "XML", "ME2.0"), _connect_dll=False)
    608608       
    609         assert model.get_variable_display_unit("J1.phi") == "deg"
     609        assert model.get_variable_display_unit("J1.phi") == "deg", model.get_variable_display_unit("J1.phi")
    610610        nose.tools.assert_raises(FMUException, model.get_variable_display_unit, "J1.w")
    611611
     
    625625       
    626626        enum = model.get_variable_declared_type("x")
    627         assert len(enum.items.keys()) == 2
     627        assert len(enum.items.keys()) == 2, len(enum.items.keys())
    628628        enum = model.get_variable_declared_type("home")
    629         assert len(enum.items.keys()) == 4
     629        assert len(enum.items.keys()) == 4, len(enum.items.keys())
    630630       
    631631        nose.tools.assert_raises(FMUException, model.get_variable_declared_type, "z")
     
    665665        for var in vars:
    666666            [r,i,b] = model.get_model_time_varying_value_references(filter=var)
    667             assert len(r) == 1
     667            assert len(r) == 1, len(r)
    668668       
    669669        [r,i,b] = model.get_model_time_varying_value_references(filter=list(vars.keys()))
    670         assert len(r) == 1
     670        assert len(r) == 1, len(r)
    671671   
    672672    @testattr(stddist = True)
     
    734734        sc_x = negated_alias.get_scalar_variable("x")
    735735       
    736         assert sc_x.name == "x"
    737         assert sc_x.value_reference >= 0
    738         assert sc_x.type == fmi.FMI2_REAL
    739         assert sc_x.variability == fmi.FMI2_CONTINUOUS
    740         assert sc_x.causality == fmi.FMI2_LOCAL
     736        assert sc_x.name == "x", sc_x.name
     737        assert sc_x.value_reference >= 0, sc_x.value_reference
     738        assert sc_x.type == fmi.FMI2_REAL, sc_x.type
     739        assert sc_x.variability == fmi.FMI2_CONTINUOUS, sc_x.variability
     740        assert sc_x.causality == fmi.FMI2_LOCAL, sc_x.causality
    741741
    742742        nose.tools.assert_raises(FMUException, negated_alias.get_scalar_variable, "not_existing")
     
    755755        model = FMUModelME1("CoupledClutches.fmu", os.path.join(file_path, "files", "FMUs", "XML", "ME1.0"), _connect_dll=False)
    756756       
    757         assert model.get_name() == "CoupledClutches"
     757        assert model.get_name() == "CoupledClutches", model.get_name()
    758758
    759759    @testattr(stddist = True)
     
    762762        model = FMUModelCS1("CoupledClutches.fmu", os.path.join(file_path, "files", "FMUs", "XML", "CS1.0"), _connect_dll=False)
    763763       
    764         assert model.get_name() == "CoupledClutches"
     764        assert model.get_name() == "CoupledClutches", model.get_name()
    765765       
    766766    @testattr(stddist = True)
     
    769769        model = FMUModelME2("CoupledClutches.fmu", os.path.join(file_path, "files", "FMUs", "XML", "ME2.0"), _connect_dll=False)
    770770       
    771         assert model.get_name() == "CoupledClutches"
     771        assert model.get_name() == "CoupledClutches", model.get_name()
    772772       
    773773    @testattr(stddist = True)
     
    776776        model = FMUModelCS2("CoupledClutches.fmu", os.path.join(file_path, "files", "FMUs", "XML", "CS2.0"), _connect_dll=False)
    777777       
    778         assert model.get_name() == "CoupledClutches"
     778        assert model.get_name() == "CoupledClutches", model.get_name()
Note: See TracChangeset for help on using the changeset viewer.