code: def merge_vertices(self, digits=None):
          
          if len(self.vertices) == 0:
              return
          if digits is None:
              digits = util.decimal_to_digits(tol.merge * self.scale,
                                              min_digits=1)
  
          unique, inverse = grouping.unique_rows(self.vertices,
                                                 digits=digits)
          self.vertices = self.vertices[unique]
  
          entities_ok = np.ones(len(self.entities), dtype=np.bool)
  
          for index, entity in enumerate(self.entities):
              # what kind of entity are we dealing with
              kind = type(entity).__name__
  
              # entities that don't need runs merged
              # don't screw up control- point- knot relationship
              if kind in 'BSpline Bezier Text':
                  entity.points = inverse[entity.points]
                  continue
              # if we merged duplicate vertices, the entity may
              # have multiple references to the same vertex
              points = grouping.merge_runs(inverse[entity.points])
              # if there are three points and two are identical fix it
              if kind == 'Line':
                  if len(points) == 3 and points[0] == points[-1]:
                      points = points[:2]
                  elif len(points) < 2:
                      # lines need two or more vertices
                      entities_ok[index] = False
              elif kind == 'Arc' and len(points) != 3:
                  # three point arcs need three points
                  entities_ok[index] = False
  
              # store points in entity
              entity.points = points
  
          # remove degenerate entities
          self.entities = self.entities[entities_ok]
docs: Merges vertices which are identical and replace references.
  
          Parameters
          --------------
          digits : None, or int
            How many digits to consider when merging vertices
  
          Alters
          -----------
          self.entities : entity.points re- referenced
          self.vertices : duplicates removed