B
    	\                 @   sj   d dl ZddlmZmZ ddlmZ ddlmZm	Z	 G dd de
ZG d	d
 d
e
ZG dd deeZdS )    N   )BaseEstimatorClassifierMixin   )assert_true)_num_samplescheck_arrayc               @   s    e Zd ZdZdd Zdd ZdS )ArraySlicingWrapperz-
    Parameters
    ----------
    array
    c             C   s
   || _ d S )N)array)selfr
    r   4lib/python3.7/site-packages/sklearn/utils/mocking.py__init__   s    zArraySlicingWrapper.__init__c             C   s   t | j| S )N)MockDataFramer
   )r   Zaslicer   r   r   __getitem__   s    zArraySlicingWrapper.__getitem__N)__name__
__module____qualname____doc__r   r   r   r   r   r   r	      s   r	   c               @   s:   e Zd ZdZdd Zdd ZdddZd	d
 Zdd ZdS )r   z-
    Parameters
    ----------
    array
    c             C   s*   || _ || _|j| _|j| _t|| _d S )N)r
   valuesshapendimr	   Ziloc)r   r
   r   r   r   r      s
    zMockDataFrame.__init__c             C   s
   t | jS )N)lenr
   )r   r   r   r   __len__$   s    zMockDataFrame.__len__Nc             C   s   | j S )N)r
   )r   dtyper   r   r   	__array__'   s    zMockDataFrame.__array__c             C   s   t | j|jkS )N)r   r
   )r   otherr   r   r   __eq__-   s    zMockDataFrame.__eq__c             C   s
   | |k S )Nr   )r   r   r   r   r   __ne__0   s    zMockDataFrame.__ne__)N)	r   r   r   r   r   r   r   r   r   r   r   r   r   r      s   
r   c               @   s4   e Zd ZdZdddZdd Zdd	 Zdd
dZdS )CheckingClassifiera7  Dummy classifier to test pipelining and meta-estimators.

    Checks some property of X and y in fit / predict.
    This allows testing whether pipelines / cross-validation or metaestimators
    changed the input.

    Parameters
    ----------
    check_y
    check_X
    foo_param
    expected_fit_params
    Nr   c             C   s   || _ || _|| _|| _d S )N)check_ycheck_X	foo_paramexpected_fit_params)r   r    r!   r"   r#   r   r   r   r   B   s    zCheckingClassifier.__init__c             K   s   t |t |kst| jdk	r,| |s,t| jdk	rD| |sDttt|ddd| _| jrt	| jt	| }t
t |dkdt|  x<| D ]0\}}t
t |t |kd|t |t |f  qW | S )a0  
        Fit classifier

        Parameters
        ----------
        X : array-like, shape = [n_samples, n_features]
            Training vector, where n_samples is the number of samples and
            n_features is the number of features.

        y : array-like, shape = [n_samples] or [n_samples, n_output], optional
            Target relative to X for classification or regression;
            None for unsupervised learning.

        **fit_params : dict of string -> object
            Parameters passed to the ``fit`` method of the estimator
        NFT)Z	ensure_2dZallow_ndr   z&Expected fit parameter(s) %s not seen.z,Fit parameter %s has length %d; expected %d.)r   AssertionErrorr!   r    npuniquer   classes_r#   setr   listitems)r   XyZ
fit_paramsZmissingkeyvaluer   r   r   fitI   s     


zCheckingClassifier.fitc             C   s2   | j dk	r|  |st| jtjt|tjd S )zX
        Parameters
        -----------
        T : indexable, length n_samples
        N)r   )r!   r$   r'   r%   Zzerosr   int)r   Tr   r   r   predictl   s    
zCheckingClassifier.predictc             C   s   | j dkrd}nd}|S )a  
        Parameters
        ----------
        X : array-like, shape = [n_samples, n_features]
            Input data, where n_samples is the number of samples and
            n_features is the number of features.

        Y : array-like, shape = [n_samples] or [n_samples, n_output], optional
            Target relative to X for classification or regression;
            None for unsupervised learning.
        r   g      ?g        )r"   )r   r+   Yscorer   r   r   r4   v   s    
zCheckingClassifier.score)NNr   N)NN)r   r   r   r   r   r/   r2   r4   r   r   r   r   r   4   s    
#
r   )Znumpyr%   baser   r   Ztestingr   Z
validationr   r   objectr	   r   r   r   r   r   r   <module>   s   