def test_ids(self): from libcellml import Annotator, Parser annotator = Annotator() parser = Parser() model = parser.parseModel(file_contents("annotator/unique_ids.cellml")) annotator.setModel(model) self.assertEqual(24, len(annotator.ids()))
# end 3.f # The Unit item is an object it has methods. **TODO** # - units() to retreive the units the unit belongs to, and # - index() to retreive the index of this Unit within the parent. print('----------------------------------------------------------') print(' STEP 4: See who else is lurking in this pool ') print('----------------------------------------------------------') # Now that we've found Marco and fixed the duplicates of Polo, we'd like to know # what other ids are being used in this model. # 4.a # Use the Annotator.ids function to return a vector of id strings used in the model, and # print them to the terminal. print('The id strings used in the model are:') ids = annotator.ids() for id in ids: print(' - "{}"'.format(id)) # end 4.a # The hex strings printed are those which have been automatically generated by the assignId # function we can also see the 'marco' and 'polo' ids as expected. # 4.b # Use the duplicateIds function to return a vector of those ids which have been duplicated in # the model, and print them to the terminal. print('Duplicated id strings are:') duplicated_ids = annotator.duplicateIds() for id in duplicated_ids: print(' - "{}" occurs {} times'.format(id, annotator.itemCount(id)))