U
    3dY                     @   s   dddZ dddZd S )Nc                 C   sv   |dkrDt | dr*t | jdr*| j }qVdd t| jd D }nt |drV| }tt|t|krrtd|S )a(  Check feature names.

    Parameters
    ----------
    X : array-like of shape (n_samples, n_features)
        Input data.

    feature_names : None or array-like of shape (n_names,), dtype=str
        Feature names to check or `None`.

    Returns
    -------
    feature_names : list of str
        Feature names validated. If `feature_names` is `None`, then a list of
        feature names is provided, i.e. the column names of a pandas dataframe
        or a generic list of feature names (e.g. `["x0", "x1", ...]`) for a
        NumPy array.
    Ncolumnstolistc                 S   s   g | ]}d | qS )x ).0ir   r   @/tmp/pip-unpacked-wheel-zrfo1fqw/sklearn/inspection/_pd_utils.py
<listcomp>   s     z(_check_feature_names.<locals>.<listcomp>   z,feature_names should not contain duplicates.)hasattrr   r   rangeshapelenset
ValueError)Xfeature_namesr   r   r   _check_feature_names   s    
r   c              
   C   sh   t | trd|dkr"td| dz|| W S  tk
rb } ztd| d|W 5 d}~X Y nX | S )a  Get feature index.

    Parameters
    ----------
    fx : int or str
        Feature index or name.

    feature_names : list of str, default=None
        All feature names from which to search the indices.

    Returns
    -------
    idx : int
        Feature index.
    Nz+Cannot plot partial dependence for feature z since the list of feature names was not provided, neither as column names of a pandas data-frame nor via the feature_names parameter.zFeature z not in feature_names)
isinstancestrr   index)Zfxr   er   r   r   _get_feature_index$   s    

$r   )N)N)r   r   r   r   r   r   <module>   s   
#