def set(
            self, 
            key: str, 
            value: object,
        ) -> 'Individual':
        """
        Set an individual's data or metadata based on a key and value.

        Parameters
        ----------
        key : str
            Key of the data for which to set.
        value : object
            Value of the data for which to set.
        
        Returns
        -------
        out : Individual
            A reference to the ``Individual`` for which values were set.
        """
        if hasattr(self, key):
            setattr(self, key, value)
        else:
            self.data[key] = value
        return self

        Set an individual's data or metadata based on a key and value.

        Parameters
        ----------
        key : str
            Key of the data for which to set.
        value : object
            Value of the data for which to set.
        
        Returns
        -------
        out : Individual
            A reference to the ``Individual`` for which values were set.
        
pymoo/core/individual.py