<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def createSegments(self, cells):
 """ Create a segment on each of the specified cells. @param cells (numpy array) """

    segments = None

    for connections in self.connectionsBySource.itervalues():
      created = connections.createSegments(cells)

      if segments is None:
        segments = created
      else:
        # Sanity-check that the segment numbers are the same.
        np.testing.assert_equal(segments, created)

    return segments