def test_UnitDefinition_getUnit(self):
   mole = libsbml.Unit(2,4)
   litre = libsbml.Unit(2,4)
   second = libsbml.Unit(2,4)
   mole.setKind(libsbml.UnitKind_forName("mole"))
   litre.setKind(libsbml.UnitKind_forName("litre"))
   second.setKind(libsbml.UnitKind_forName("second"))
   mole.setScale(-3)
   litre.setExponent(-1)
   second.setExponent(-1)
   self.UD.addUnit(mole)
   self.UD.addUnit(litre)
   self.UD.addUnit(second)
   _dummyList = [ mole ]; _dummyList[:] = []; del _dummyList
   _dummyList = [ litre ]; _dummyList[:] = []; del _dummyList
   _dummyList = [ second ]; _dummyList[:] = []; del _dummyList
   self.assert_( self.UD.getNumUnits() == 3 )
   mole = self.UD.getUnit(0)
   litre = self.UD.getUnit(1)
   second = self.UD.getUnit(2)
   self.assert_( mole.getKind() == libsbml.UNIT_KIND_MOLE )
   self.assert_( litre.getKind() == libsbml.UNIT_KIND_LITRE )
   self.assert_( second.getKind() == libsbml.UNIT_KIND_SECOND )
   self.assert_( mole.getScale() == -3 )
   self.assert_( litre.getExponent() == -1 )
   self.assert_( second.getExponent() == -1 )
   pass  
Exemple #2
0
 def test_Unit_copyConstructor(self):
   o1 = libsbml.Unit(2,4)
   o1.setKind(libsbml.UNIT_KIND_MOLE)
   self.assert_( o1.getKind() == libsbml.UNIT_KIND_MOLE )
   o2 = libsbml.Unit(o1)
   self.assert_( o2.getKind() == libsbml.UNIT_KIND_MOLE )
   self.assert_( o2.getParentSBMLObject() == o1.getParentSBMLObject() )
   o2 = None
   o1 = None
   pass  
Exemple #3
0
 def test_Unit_assignmentOperator(self):
   o1 = libsbml.Unit(2,4)
   o1.setKind(libsbml.UNIT_KIND_MOLE)
   self.assert_( o1.getKind() == libsbml.UNIT_KIND_MOLE )
   o2 = libsbml.Unit(2,4)
   o2 = o1
   self.assert_( o2.getKind() == libsbml.UNIT_KIND_MOLE )
   self.assert_( o2.getParentSBMLObject() == o1.getParentSBMLObject() )
   o2 = None
   o1 = None
   pass  
 def test_UnitDefinition_isVariantOfSubstancePerTime_3(self):
   ud = libsbml.UnitDefinition(2,2)
   dim = libsbml.Unit(2,2)
   dim.setKind(libsbml.UnitKind_forName("dimensionless"))
   perTime = ud.createUnit()
   perTime.setKind(libsbml.UnitKind_forName("second"))
   perTime.setExponent(-1)
   u = ud.createUnit()
   self.assertEqual( False, ud.isVariantOfSubstancePerTime() )
   u.setKind(libsbml.UNIT_KIND_GRAM)
   u.setExponent(1)
   self.assertEqual( True, ud.isVariantOfSubstancePerTime() )
   u.setScale(-1)
   perTime.setScale(-1)
   self.assertEqual( True, ud.isVariantOfSubstancePerTime() )
   u.setMultiplier(2)
   self.assertEqual( True, ud.isVariantOfSubstancePerTime() )
   u.setOffset(3)
   self.assertEqual( True, ud.isVariantOfSubstancePerTime() )
   u.setExponent(-3)
   self.assertEqual( False, ud.isVariantOfSubstancePerTime() )
   u.setExponent(1)
   perTime.setExponent(-3)
   self.assertEqual( False, ud.isVariantOfSubstancePerTime() )
   perTime.setExponent(-1)
   ud.addUnit(dim)
   self.assertEqual( True, ud.isVariantOfSubstancePerTime() )
   _dummyList = [ ud ]; _dummyList[:] = []; del _dummyList
   _dummyList = [ dim ]; _dummyList[:] = []; del _dummyList
   pass  
 def test_UnitDefinition_isVariantOfSubstancePerTime_2(self):
     dim = libsbml.Unit(2, 4)
     dim.setKind(libsbml.UnitKind_forName("dimensionless"))
     perTime = self.UD.createUnit()
     perTime.setKind(libsbml.UnitKind_forName("second"))
     perTime.setExponent(-1)
     u = self.UD.createUnit()
     self.assertEqual(False, self.UD.isVariantOfSubstancePerTime())
     u.setKind(libsbml.UNIT_KIND_ITEM)
     u.setExponent(1)
     self.assertEqual(True, self.UD.isVariantOfSubstancePerTime())
     u.setScale(-1)
     perTime.setScale(-1)
     self.assertEqual(True, self.UD.isVariantOfSubstancePerTime())
     u.setMultiplier(2)
     self.assertEqual(True, self.UD.isVariantOfSubstancePerTime())
     u.setOffset(3)
     self.assertEqual(True, self.UD.isVariantOfSubstancePerTime())
     u.setExponent(-3)
     self.assertEqual(False, self.UD.isVariantOfSubstancePerTime())
     u.setExponent(1)
     perTime.setExponent(-3)
     self.assertEqual(False, self.UD.isVariantOfSubstancePerTime())
     perTime.setExponent(-1)
     self.UD.addUnit(dim)
     self.assertEqual(True, self.UD.isVariantOfSubstancePerTime())
     _dummyList = [dim]
     _dummyList[:] = []
     del _dummyList
     pass
Exemple #6
0
 def test_L3_Unit_createWithNS(self):
     xmlns = libsbml.XMLNamespaces()
     xmlns.add("http://www.sbml.org", "testsbml")
     sbmlns = libsbml.SBMLNamespaces(3, 1)
     sbmlns.addNamespaces(xmlns)
     u = libsbml.Unit(sbmlns)
     self.assert_(u.getTypeCode() == libsbml.SBML_UNIT)
     self.assert_(u.getMetaId() == "")
     self.assert_(u.getNotes() == None)
     self.assert_(u.getAnnotation() == None)
     self.assert_(u.getLevel() == 3)
     self.assert_(u.getVersion() == 1)
     self.assert_(u.getNamespaces() != None)
     self.assert_(u.getNamespaces().getLength() == 2)
     self.assert_(u.getKind() == libsbml.UNIT_KIND_INVALID)
     self.assertEqual(True, isnan(u.getExponentAsDouble()))
     self.assertEqual(True, isnan(u.getMultiplier()))
     self.assertEqual(False, u.isSetKind())
     self.assertEqual(False, u.isSetExponent())
     self.assertEqual(False, u.isSetMultiplier())
     self.assertEqual(False, u.isSetScale())
     _dummyList = [u]
     _dummyList[:] = []
     del _dummyList
     pass
Exemple #7
0
 def test_Unit(self):
     u = libsbml.Unit(2, 4)
     self.assertEqual(False, (u.hasRequiredAttributes()))
     u.setKind(libsbml.UNIT_KIND_MOLE)
     self.assertEqual(True, u.hasRequiredAttributes())
     u = None
     pass
 def test_UnitDefinition_addUnit(self):
   u = libsbml.Unit(2,4)
   u.setKind(libsbml.UNIT_KIND_MOLE)
   self.UD.addUnit(u)
   self.assert_( self.UD.getNumUnits() == 1 )
   _dummyList = [ u ]; _dummyList[:] = []; del _dummyList
   pass  
Exemple #9
0
 def test_Unit_setMultiplier2(self):
     c = libsbml.Unit(2, 2)
     i = c.setMultiplier(4)
     self.assert_(i == libsbml.LIBSBML_OPERATION_SUCCESS)
     self.assert_(c.getMultiplier() == 4)
     _dummyList = [c]
     _dummyList[:] = []
     del _dummyList
     pass
Exemple #10
0
 def test_UnitDefinition_addUnit3(self):
   m = libsbml.UnitDefinition(2,2)
   p = libsbml.Unit(1,2)
   p.setKind(libsbml.UNIT_KIND_MOLE)
   i = m.addUnit(p)
   self.assert_( i == libsbml.LIBSBML_LEVEL_MISMATCH )
   self.assert_( m.getNumUnits() == 0 )
   _dummyList = [ p ]; _dummyList[:] = []; del _dummyList
   _dummyList = [ m ]; _dummyList[:] = []; del _dummyList
   pass  
Exemple #11
0
 def test_Unit_parent_add(self):
     ud = libsbml.UnitDefinition(2, 4)
     u = libsbml.Unit(2, 4)
     u.setKind(libsbml.UNIT_KIND_MOLE)
     ud.addUnit(u)
     u = None
     self.assert_(ud.getNumUnits() == 1)
     lo = ud.getListOfUnits()
     self.assert_(lo == ud.getUnit(0).getParentSBMLObject())
     self.assert_(ud == lo.getParentSBMLObject())
     ud = None
     pass
Exemple #12
0
 def test_UnitDefinition_addUnit1(self):
   m = libsbml.UnitDefinition(2,2)
   p = libsbml.Unit(2,2)
   i = m.addUnit(p)
   self.assert_( i == libsbml.LIBSBML_INVALID_OBJECT )
   p.setKind(libsbml.UNIT_KIND_MOLE)
   i = m.addUnit(p)
   self.assert_( i == libsbml.LIBSBML_OPERATION_SUCCESS )
   self.assert_( m.getNumUnits() == 1 )
   _dummyList = [ p ]; _dummyList[:] = []; del _dummyList
   _dummyList = [ m ]; _dummyList[:] = []; del _dummyList
   pass  
 def test_L3_Unit_hasRequiredAttributes(self):
   u = libsbml.Unit(3,1)
   self.assertEqual( False, u.hasRequiredAttributes() )
   u.setKind(libsbml.UNIT_KIND_MOLE)
   self.assertEqual( False, u.hasRequiredAttributes() )
   u.setExponent(0)
   self.assertEqual( False, u.hasRequiredAttributes() )
   u.setMultiplier(0.45)
   self.assertEqual( False, u.hasRequiredAttributes() )
   u.setScale(2)
   self.assertEqual( True, u.hasRequiredAttributes() )
   _dummyList = [ u ]; _dummyList[:] = []; del _dummyList
   pass  
 def test_internal_consistency_check_99905_unit(self):
   d = libsbml.SBMLDocument(2,4)
   u = libsbml.Unit(2,4)
   d.setLevelAndVersion(2,2,False)
   m = d.createModel()
   ud = m.createUnitDefinition()
   ud.setId("ud")
   u.setKind(libsbml.UNIT_KIND_MOLE)
   u.setSBOTerm(9)
   ud.addUnit(u)
   errors = d.checkInternalConsistency()
   self.assert_( errors == 0 )
   d = None
   pass  
Exemple #15
0
 def test_Unit_ancestor_add(self):
   ud = libsbml.UnitDefinition(2,4)
   u = libsbml.Unit(2,4)
   u.setKind(libsbml.UNIT_KIND_MOLE)
   ud.addUnit(u)
   u = None
   self.assert_( ud.getNumUnits() == 1 )
   lo = ud.getListOfUnits()
   obj = ud.getUnit(0)
   self.assert_( obj.getAncestorOfType(libsbml.SBML_UNIT_DEFINITION) == ud )
   self.assert_( obj.getAncestorOfType(libsbml.SBML_LIST_OF) == lo )
   self.assert_( obj.getAncestorOfType(libsbml.SBML_DOCUMENT) == None )
   self.assert_( obj.getAncestorOfType(libsbml.SBML_COMPARTMENT) == None )
   ud = None
   pass  
Exemple #16
0
 def test_Unit_createWithNS(self):
   xmlns = libsbml.XMLNamespaces()
   xmlns.add( "http://www.sbml.org", "testsbml")
   sbmlns = libsbml.SBMLNamespaces(2,1)
   sbmlns.addNamespaces(xmlns)
   object = libsbml.Unit(sbmlns)
   self.assert_( object.getTypeCode() == libsbml.SBML_UNIT )
   self.assert_( object.getMetaId() == "" )
   self.assert_( object.getNotes() == None )
   self.assert_( object.getAnnotation() == None )
   self.assert_( object.getLevel() == 2 )
   self.assert_( object.getVersion() == 1 )
   self.assert_( object.getNamespaces() != None )
   self.assert_( object.getNamespaces().getLength() == 2 )
   _dummyList = [ object ]; _dummyList[:] = []; del _dummyList
   pass  
 def test_internal_consistency_check_99924(self):
   d = libsbml.SBMLDocument(2,4)
   u = libsbml.Unit(2,4)
   d.setLevelAndVersion(1,2,False)
   m = d.createModel()
   c = m.createCompartment()
   c.setId("cc")
   ud = m.createUnitDefinition()
   ud.setId("ud")
   u.setKind(libsbml.UNIT_KIND_MOLE)
   u.setMultiplier(9)
   ud.addUnit(u)
   errors = d.checkInternalConsistency()
   self.assert_( errors == 0 )
   d = None
   pass  
Exemple #18
0
 def test_Unit_set_get(self):
   u = libsbml.Unit(2,4)
   self.assert_( u.getKind() == libsbml.UNIT_KIND_INVALID )
   self.assert_( u.getExponent() == 1 )
   self.assert_( u.getScale() == 0 )
   self.assert_( u.getMultiplier() == 1.0 )
   self.assertEqual( False, u.isSetKind() )
   u.setKind(libsbml.UNIT_KIND_WATT)
   self.assert_( u.getKind() == libsbml.UNIT_KIND_WATT )
   u.setExponent(3)
   self.assert_( u.getExponent() == 3 )
   u.setScale(4)
   self.assert_( u.getScale() == 4 )
   u.setMultiplier(3.2)
   self.assert_( u.getMultiplier() == 3.2 )
   _dummyList = [ u ]; _dummyList[:] = []; del _dummyList
   pass  
 def test_UnitDefinition_isVariantOfSubstance_1(self):
   dim = libsbml.Unit(2,4)
   dim.setKind(libsbml.UnitKind_forName("dimensionless"))
   u = self.UD.createUnit()
   self.assertEqual( False, self.UD.isVariantOfSubstance() )
   u.setKind(libsbml.UNIT_KIND_MOLE)
   u.setExponent(1)
   self.assertEqual( True, self.UD.isVariantOfSubstance() )
   u.setScale(-1)
   self.assertEqual( True, self.UD.isVariantOfSubstance() )
   u.setMultiplier(2)
   self.assertEqual( True, self.UD.isVariantOfSubstance() )
   u.setOffset(3)
   self.assertEqual( True, self.UD.isVariantOfSubstance() )
   u.setExponent(-3)
   self.assertEqual( False, self.UD.isVariantOfSubstance() )
   u.setExponent(1)
   self.UD.addUnit(dim)
   self.assertEqual( True, self.UD.isVariantOfSubstance() )
   pass  
Exemple #20
0
 def test_SBMLDocument_setLevelAndVersion_Error(self):
     d = libsbml.SBMLDocument()
     d.setLevelAndVersion(2, 1, True)
     m1 = libsbml.Model(2, 1)
     u = libsbml.Unit(2, 1)
     u.setKind(libsbml.UnitKind_forName("mole"))
     u.setOffset(3.2)
     ud = libsbml.UnitDefinition(2, 1)
     ud.setId("ud")
     ud.addUnit(u)
     m1.addUnitDefinition(ud)
     d.setModel(m1)
     self.assert_(d.setLevelAndVersion(2, 2, True) == False)
     self.assert_(d.setLevelAndVersion(2, 3, True) == False)
     self.assert_(d.setLevelAndVersion(1, 2, True) == False)
     self.assert_(d.setLevelAndVersion(1, 1, True) == False)
     _dummyList = [d]
     _dummyList[:] = []
     del _dummyList
     pass
 def test_UnitDefinition_isVariantOfVolume_2(self):
   dim = libsbml.Unit(2,4)
   dim.setKind(libsbml.UnitKind_forName("dimensionless"))
   u = self.UD.createUnit()
   self.assertEqual( False, self.UD.isVariantOfVolume() )
   u.setKind(libsbml.UNIT_KIND_METRE)
   u.setExponent(3)
   self.assertEqual( True, self.UD.isVariantOfVolume() )
   u.setScale(100)
   self.assertEqual( True, self.UD.isVariantOfVolume() )
   u.setMultiplier(5)
   self.assertEqual( True, self.UD.isVariantOfVolume() )
   u.setOffset(-5)
   self.assertEqual( True, self.UD.isVariantOfVolume() )
   u.setExponent(2)
   self.assertEqual( False, self.UD.isVariantOfVolume() )
   u.setExponent(3)
   self.UD.addUnit(dim)
   self.assertEqual( True, self.UD.isVariantOfVolume() )
   pass  
Exemple #22
0
 def test_Unit_setOffset2(self):
     U1 = libsbml.Unit(2, 1)
     i = U1.setOffset(2.0)
     self.assert_(i == libsbml.LIBSBML_OPERATION_SUCCESS)
     self.assert_(U1.getOffset() == 2)
     pass
 def setUp(self):
   self.U = libsbml.Unit(3,1)
   if (self.U == None):
     pass    
   pass  
    def test_Unit_constructor(self):
        s = None
        try:
            s = libsbml.Unit(1, 1)
            s = libsbml.Unit(1, 2)
            s = libsbml.Unit(2, 1)
            s = libsbml.Unit(2, 2)
            s = libsbml.Unit(2, 3)
            s = libsbml.Unit(2, 4)
            s = libsbml.Unit(3, 1)
            s = libsbml.Unit(self.SN11)
            s = libsbml.Unit(self.SN12)
            s = libsbml.Unit(self.SN21)
            s = libsbml.Unit(self.SN22)
            s = libsbml.Unit(self.SN23)
            s = libsbml.Unit(self.SN24)
            s = libsbml.Unit(self.SN31)
        except ValueError:
            inst = sys.exc_info()[1]
            s = None
        pass
        self.assert_(s != None)

        msg = ""

        try:
            s = libsbml.Unit(9, 9)
        except ValueError:
            inst = sys.exc_info()[1]
            msg = inst.args[0]
        pass
        self.assertEqual(msg, self.ERR_MSG)

        msg = ""

        try:
            s = libsbml.Unit(self.SN99)
        except ValueError:
            inst = sys.exc_info()[1]
            msg = inst.args[0]
        pass
        self.assertEqual(msg, self.ERR_MSG)
 def test_Unit(self):
   u = libsbml.Unit(2,4)
   self.assertEqual( True, u.hasRequiredElements() )
   u = None
   pass