def test_has_units(self): from libcellml import Model, Units # bool hasUnits(const std::string &name) name = 'loud' m = Model() u = Units() u.setName(name) m.addUnits(u) self.assertFalse(m.hasUnits('hi')) self.assertTrue(m.hasUnits(name)) # bool hasUnits(const UnitsPtr &units) self.assertTrue(m.hasUnits(u)) v = Units() self.assertFalse(m.hasUnits(v))
sodium_channel.removeParent() membrane.addComponent(sodium_channel) print_encapsulation_structure_to_terminal(model) # 2.c Validate the combined model. We expect to see errors from: # - missing units, as we have only added the component so far, # - illegal connections between equivalent variables, as now the environment # component and the sodiumChannel component are no longer siblings. validator.validateModel(model) print_errors_to_terminal(validator) # 2.d Add all of the units from the sodium channel model which are not already # present into the combined model. for u in range(0, sodium_channel_model.unitsCount()): unitName = sodium_channel_model.units(u).name() if not model.hasUnits(unitName): print("Adding units called {}".format(unitName)) model.addUnits(sodium_channel_model.units(u)) # 2.e Disconnect the sodiumChannel from its old environment component Variable.removeEquivalence( sodium_channel.variable("t"), sodium_channel_model.component("environment").variable("t")) Variable.removeEquivalence( sodium_channel.variable("V"), sodium_channel_model.component("environment").variable("V")) # 2.f Validate that there are no more errors in the combined model validator.validateModel(model) print_errors_to_terminal(validator)