Set a unique ID.

        If a UID of a given schema already exists in a record it will
        be overwritten, otherwise it will be appended to the record.

        Args:
            uid (string): unique identifier.
            schema (Optional[string]): schema of the unique identifier. If
                ``None``, the schema will be guessed based on the shape of
                ``uid``.

        Raises:
            SchemaUIDConflict: it UID and schema are not matching

def set_uid(self, uid, schema=None):
        """Set a unique ID.

        If a UID of a given schema already exists in a record it will
        be overwritten, otherwise it will be appended to the record.

        Args:
            uid (string): unique identifier.
            schema (Optional[string]): schema of the unique identifier. If
                ``None``, the schema will be guessed based on the shape of
                ``uid``.

        Raises:
            SchemaUIDConflict: it UID and schema are not matching
        """
        try:
            uid, schema = author_id_normalize_and_schema(uid, schema)
        except UnknownUIDSchema:
            # Explicit schema wasn't provided, and the UID is too little
            # to figure out the schema of it, this however doesn't mean
            # the UID is invalid
            pass

        self._ensure_field('ids', [])
        self.obj['ids'] = [id_ for id_ in self.obj['ids'] if id_.get('schema') != schema]
        self._add_uid(uid, schema)