
[c           @` sO  d  Z  d d l m Z m Z m Z m Z d d l Z d d l Z d d l	 m
 Z
 d d l m Z d d l m Z d d l m Z m Z m Z d d	 l m Z d
 d l m Z y d d l m Z e Z Wn e k
 r e Z n Xe j d g f e j d g f e j d g f e j d g f e j  d g f g Z! e j" d g f e j# d d g f e j$ d d g f g Z% d e& f d     YZ' d e& f d     YZ( d e& f d     YZ) d e f d     YZ* d e& f d     YZ+ d e& f d     YZ, d e f d     YZ- d e& f d     YZ. d e f d     YZ/ d    Z0 d!   Z1 d"   Z2 d S(#   uD   
This module tests fitting and model evaluation with various inputs
i    (   t   absolute_importt   unicode_literalst   divisiont   print_functionN(   t   assert_allclosei   (   t   models(   t   fitting(   t   Modelt   FittableModelt   Fittable1DModel(   t	   Parameteri   (   t   range(   t   optimizei   t   TestInputTypec           B` sS   e  Z d  Z d   Z e j j d e  d    Z e j j d e	  d    Z
 RS(   u   
    This class tests that models accept numbers, lists and arrays.

    Add new models to one of the lists above to test for this.
    c         C` sq   d |  _  d |  _ t j d d d  |  _ t j d d d  |  _ t j d  d  d  d  f \ |  _ |  _ d  S(   Ng333333@g@i   i
   g?i   (	   t   xt   yt   npt   aranget   x1t   y1t   mgridt   y2t   x2(   t   self(    (    s@   lib/python2.7/site-packages/astropy/modeling/tests/test_input.pyt   setup_class0   s
    		u   modelu   paramsc         C` s7   | |   } | |  j   | |  j  | |  j  d  S(   N(   R   R   R   (   R   t   modelt   paramst   m(    (    s@   lib/python2.7/site-packages/astropy/modeling/tests/test_input.pyt   test_input1D7   s    c         C` sI   | |   } | |  j  |  j  | |  j |  j  | |  j |  j  d  S(   N(   R   R   R   R   R   R   (   R   R   R   R   (    (    s@   lib/python2.7/site-packages/astropy/modeling/tests/test_input.pyt   test_input2D>   s    (   u   modelu   params(   u   modelu   params(   t   __name__t
   __module__t   __doc__R   t   pytestt   markt   parametrizet   model1d_paramsR   t   model2d_paramsR   (    (    (    s@   lib/python2.7/site-packages/astropy/modeling/tests/test_input.pyR   )   s   	t   TestFittingc           B` s   e  Z d  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 e j j d	  d
    Z e j j d	  d    Z e j j d	  d    Z e j j d	  d    Z RS(   u/   Test various input options to fitting routines.c         C` sA   t  j d  |  _ t  j d  d  d  d  f \ |  _ |  _ d  S(   Ni
   (   R   R   R   R   R   R   (   R   (    (    s@   lib/python2.7/site-packages/astropy/modeling/tests/test_input.pyR   I   s    c         C` s   t  j d d d d g  } t j d  } d d d d g | _ | |  j  } t j   } | | |  j |  } t | j | d d d S(	   u   1 set 1D x, 1pseti    i   i   t   atoli
   iNgHz>(	   R   t   arrayR   t   Polynomial1Dt
   parametersR   R   t   LinearLSQFitterR   (   R   t   expectedt   p1R   t   pfitR   (    (    s@   lib/python2.7/site-packages/astropy/modeling/tests/test_input.pyt   test_linear_fitter_1setM   s    c         C` s  t  j d d g d d g d d g d d g g  } t j d d d } d d d d d d d	 d	 g | _ i  } x+ t d
  D] } | | g | | j | <q| Wt j d d d | } | |  j d t } t	 j
   } | | |  j |  } t | j | d d d S(   u%   1 set 1D x, 2 sets 1D y, 2 param_setsi    i   i   i   t   n_modelsg        g      ?g       @g      @i   t   model_set_axisR'   i
   iNgHz>(   R   R(   R   R)   R*   R   t   param_namesR   t   FalseR   R+   R   t
   param_sets(   R   R,   R-   R   t   iR   R.   R   (    (    s@   lib/python2.7/site-packages/astropy/modeling/tests/test_input.pyt   test_linear_fitter_NsetX   s    3!c         C` s   t  j d d d d g g  j } t j d  } d d d d g | _ | |  j  } t j   } | | |  j |  } t	 | j
 | d	 d d S(   u7   1 pset, 1 set 1D x, 1 set 1D y, Chebyshev 1D polynomialg@g@g    C@gq@i   i    i   i   R'   i
   iNg{Gz?(   R   R(   t   TR   t   Chebyshev1DR*   R   R   R+   R   R4   (   R   R,   t   ch1R   R.   R   (    (    s@   lib/python2.7/site-packages/astropy/modeling/tests/test_input.pyt   test_linear_fitter_1dchebg   s    c         C` s   t  j d d d d g g  j } t j d  } d d d d g | _ | |  j  } t j   } | | |  j |  } t	 | j
 | d	 d d S(   uH   
        1 pset, 1 set 1D x, 1 set 1D y, Legendre 1D polynomial
        g    @g   @g    m@gv@i   i   i   i   R'   i
   iNg-q=(   R   R(   R7   R   t
   Legendre1DR*   R   R   R+   R   R4   (   R   R,   t   leg1R   R.   R   (    (    s@   lib/python2.7/site-packages/astropy/modeling/tests/test_input.pyt   test_linear_fitter_1dlegendv   s    c         C` s   t  j d  } d d d d d d g | _ d d d d d d g } | |  j |  j  } t j   } | | |  j |  j |  } t | j | d d
 t | |  j |  j  | d d d  S(   Ni   i    i   i   i   i   R'   i
   ig-q=g-q=(   R   t   Polynomial2DR*   R   R   R   R+   R   (   R   t   p2R,   t   zR.   R   (    (    s@   lib/python2.7/site-packages/astropy/modeling/tests/test_input.pyt   test_linear_fitter_1set2d   s    c         C` sn   t  j t  Y t j d  } | |  j  } t j d d d } t j   } | | |  j |  } Wd QXd S(   u   
        A ValueError is raised if a 1 data set (1d x, 1d y) is fit
        with a model with multiple parameter sets.
        i   R0   i   N(   R!   t   raisest
   ValueErrorR   R)   R   R   R+   (   R   R-   R   R.   R   (    (    s@   lib/python2.7/site-packages/astropy/modeling/tests/test_input.pyt   test_wrong_numpset   s    c         C` s   t  j d d g d d g d d g d d g d d g d d g g  } t j d d d } i  } x+ t d	  D] } d | g | | j | <qm Wt j d d
 d | } | |  j d
 t } t j	   } | | |  j |  } t
 | j | d d d S(   u;   A case of 1 set of x and multiple sets of y and parameters.g      ?i    i   i   i   i   i   R0   i   R1   R'   i
   iNgHz>(   R   R(   R   R)   R   R2   R   R3   R   R+   R   R4   (   R   R,   R-   R   R5   R   R.   R   (    (    s@   lib/python2.7/site-packages/astropy/modeling/tests/test_input.pyt   test_wrong_pset   s    				u   not HAS_SCIPYc         C` sh   t  j d d d d d } | |  j  } t j   } | | |  j |  } t | j d d d g  d S(   u.   1 set 1D x, 1 set 1D y, 1 pset NonLinearFitteri
   t   meani   t   stddevg?N(   R   t
   Gaussian1DR   R   t   LevMarLSQFitterR   R*   (   R   t   g1R   t   gfitR   (    (    s@   lib/python2.7/site-packages/astropy/modeling/tests/test_input.pyt   test_nonlinear_lsqt_1set_1d   s
    c         C` s   t  j t  n t j d d g d d d g d d d g d	 d
 } | |  j d t } t j   } | | |  j |  } Wd QXd S(   u5   1 set 1D x, 1 set 1D y, 2 param_sets, NonLinearFittergffffff$@i
   RF   i   g	@RG   gq=
ףp?g?R0   i   R1   N(	   R!   RB   RC   R   RH   R   R3   R   RI   (   R   RJ   R   RK   R   (    (    s@   lib/python2.7/site-packages/astropy/modeling/tests/test_input.pyt   test_nonlinear_lsqt_Nset_1d   s    *	c         C` s   t  j d d d d d d d d d	 d
 d } | |  j |  j  } t j   } | | |  j |  j |  } t | j d d d d d	 d g  d S(   u.   1 set 2d x, 1set 2D y, 1 pset, NonLinearFitteri
   t   x_meani   t   y_meani   t   x_stddevg333333?t   y_stddevg?t   thetai    N(   R   t
   Gaussian2DR   R   R   RI   R   R*   (   R   t   g2R@   RK   R   (    (    s@   lib/python2.7/site-packages/astropy/modeling/tests/test_input.pyt   test_nonlinear_lsqt_1set_2d   s    c         C` s   t  j t   t j d d g d d g d d g d d d g d d d g d d	 d	 g d
 d } | |  j j   |  j j    } t j	   } | | |  j |  j |  } Wd QXd S(   u4   1 set 2d x, 1set 2D y, 2 param_sets, NonLinearFitteri
   i   i   RP   g333333?RQ   g?RR   i    R0   i   N(
   R!   RB   RC   R   RS   R   t   flattenR   R   RI   (   R   RT   R@   RK   R   (    (    s@   lib/python2.7/site-packages/astropy/modeling/tests/test_input.pyt   test_nonlinear_lsqt_Nset_2d   s    0!!(   R   R   R    R   R/   R6   R:   R=   RA   RD   RE   R!   R"   t   skipifRL   RM   RU   RW   (    (    (    s@   lib/python2.7/site-packages/astropy/modeling/tests/test_input.pyR&   F   s   						
		
t   TestEvaluationc           B` s_   e  Z d  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d	   Z RS(
   us   
    Test various input options to model evaluation

    TestFitting actually covers evaluation of polynomials
    c         C` sA   t  j d  |  _ t  j d  d  d  d  f \ |  _ |  _ d  S(   Ni   i
   (   R   R   R   R   R   R   (   R   (    (    s@   lib/python2.7/site-packages/astropy/modeling/tests/test_input.pyR      s    c         C` s   t  j d d g d d g d d g d d } | |  j d t } t j | d d d  f | d	 d d  f j   t j g   k  s t  d S(
   uY   
        This case covers:
            N param sets , 1 set 1D x --> N 1D y data
        i
   i   g?R0   i   R1   i    Ni   (	   R   RH   R   R3   R   t   allt   nonzeroR(   t   AssertionError(   R   RJ   R   (    (    s@   lib/python2.7/site-packages/astropy/modeling/tests/test_input.pyt   test_non_linear_NYset   s    -c         C` s   t  j d d g d d g d d g d d } t j |  j |  j g  } | |  } t | d d  d f | d d  d f d	 d d S(   uU   
        This case covers: N param sets , N sets 1D x --> N N sets 1D y data
        i
   i   g?R0   i   Ni    i   R'   ig-q=(   R   RH   R   R(   R   R   (   R   RJ   t   xxR   (    (    s@   lib/python2.7/site-packages/astropy/modeling/tests/test_input.pyt   test_non_linear_NXYset   s    -c         C` s7   t  j d  } | |  j  } | j d k s3 t  d S(   u    1 data set, 1 pset, Polynomial1Di   i   N(   i   (   R   R)   R   t   shapeR\   (   R   R-   R   (    (    s@   lib/python2.7/site-packages/astropy/modeling/tests/test_input.pyt   test_p1_1set_1pset   s    c         C` s   t  j d d d } | t j |  j |  j g  j d d } | j d k sT t  t | d d d  f | d	 d d  f d
 d d S(   u'   N data sets, N param_sets, Polynomial1Di   R0   i   R1   ii   i    Ni   R'   i
   i(   i   i   g-q=(	   R   R)   R   R(   R   R7   R`   R\   R   (   R   R-   R   (    (    s@   lib/python2.7/site-packages/astropy/modeling/tests/test_input.pyt   test_p1_nset_npset  s    *c         C` s=   t  j d  } | |  j |  j  } | j d k s9 t  d S(   u#   1 pset, 1 2D data set, Polynomial2Di   i
   N(   i
   i
   (   R   R>   R   R   R`   R\   (   R   R?   R@   (    (    s@   lib/python2.7/site-packages/astropy/modeling/tests/test_input.pyt   test_p2_1set_1pset  s    c         C` ss   t  j d d d } t j |  j |  j g  } t j |  j |  j g  } | | |  } | j d k so t  d S(   u$   N param_sets, N 2D data sets, Poly2di   R0   i   i
   N(   i   i
   i
   (   R   R>   R   R(   R   R   R`   R\   (   R   R?   R^   t   yyR@   (    (    s@   lib/python2.7/site-packages/astropy/modeling/tests/test_input.pyt   test_p2_nset_npset  s
    c         C` s  t  j |  j |  j g  j } d | d <d | d <d | d <t j d d d } | | d d	 } | d
 d
  d f } | d
 d
  d f } t j d  } t | |  | d d
 d
  f d d t j d  } t | |  | d d
 d
  f d d d
 S(   uS   
        Polynomial evaluation of multiple data sets with different domain
        id   i    i   ic   i   i   R0   R1   iNR'   i
   i(   i    i    (   i   i    (   i   i    g-q=g-q=(   R   R(   R   R7   R   R)   R   (   R   R^   R-   Rd   R   R   (    (    s@   lib/python2.7/site-packages/astropy/modeling/tests/test_input.pyt   test_nset_domain  s    


)c         C` sr   t  j d d g d d g g  } t j d d d d | } t  j d  d  d  d  f \ } } | | |  d  S(   Ng      ?g?i   g      @g      @t
   cov_matrixi
   (   R   R(   R   RS   R   (   R   t   covt   gR   R   (    (    s@   lib/python2.7/site-packages/astropy/modeling/tests/test_input.pyt   test_evaluate_gauss2d-  s    !%(   R   R   R    R   R]   R_   Ra   Rb   Rc   Re   Rf   Rj   (    (    (    s@   lib/python2.7/site-packages/astropy/modeling/tests/test_input.pyRY      s   		
	
						t
   TModel_1_1c           B` s)   e  Z e   Z e   Z e d     Z RS(   c         C` s   |  | | S(   N(    (   R   R-   R?   (    (    s@   lib/python2.7/site-packages/astropy/modeling/tests/test_input.pyt   evaluate8  s    (   R   R   R
   R-   R?   t   staticmethodRl   (    (    (    s@   lib/python2.7/site-packages/astropy/modeling/tests/test_input.pyRk   4  s   		t&   TestSingleInputSingleOutputSingleModelc           B` sV   e  Z d  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 RS(	   u  
    A suite of tests to check various cases of parameter and input combinations
    on models with n_input = n_output = 1 on a toy model with n_models=1.

    Many of these tests mirror test cases in
    ``astropy.modeling.tests.test_parameters.TestParameterInitialization``,
    except that this tests how different parameter arrangements interact with
    different types of model inputs.
    c         C` sa   t  d d  } | d  } t | t  s0 t  t j |  d k sK t  | d k s] t  d S(   uO   
        Scalar parameters with a scalar input should return a scalar.
        i   i
   id   i    io   N(   Rk   t
   isinstancet   floatR\   R   t   ndim(   R   t   tR   (    (    s@   lib/python2.7/site-packages/astropy/modeling/tests/test_input.pyt#   test_scalar_parameters_scalar_inputH  s
    c         C` s   t  d d  } | t j d  d  } t | t j  s@ t  t j |  d k s[ t  t j | d d d d d	 g k  s t  d
 S(   u   
        Scalar parameters should broadcast with an array input to result in an
        array output of the same shape as the input.
        i   i
   i   id   i   io   i   i7  i  N(   i   (   Rk   R   R   Ro   t   ndarrayR\   R`   RZ   (   R   Rr   R   (    (    s@   lib/python2.7/site-packages/astropy/modeling/tests/test_input.pyt%   test_scalar_parameters_1d_array_inputS  s
    c         C` s   t  d d  } | t j d  j d d  d  } t | t j  sL t  t j |  d k sg t  t j | d d d	 g d
 d d g g k  s t  d S(   u   
        Scalar parameters should broadcast with an array input to result in an
        array output of the same shape as the input.
        i   i
   i   i   i   id   i   io   i   i7  i  i  N(   i   i   (	   Rk   R   R   t   reshapeRo   Rt   R\   R`   RZ   (   R   Rr   R   (    (    s@   lib/python2.7/site-packages/astropy/modeling/tests/test_input.pyt%   test_scalar_parameters_2d_array_input_  s    %c         C` s   t  d d  } | t j d  j d d d  d  } t | t j  sO t  t j |  d k sj t  t j | d d g d	 d
 g d d g g d d g d d g d d g g g k  s t  d S(   u   
        Scalar parameters should broadcast with an array input to result in an
        array output of the same shape as the input.
        i   i
   i   i   i   id   i   io   i   i7  i  i  ic  i  i+  i  i  iW  N(   i   i   i   (	   Rk   R   R   Rv   Ro   Rt   R\   R`   RZ   (   R   Rr   R   (    (    s@   lib/python2.7/site-packages/astropy/modeling/tests/test_input.pyt%   test_scalar_parameters_3d_array_inputl  s    ('c         C` s   t  d d g d d g  } | d  } t | t j  s? t  t j |  d	 k sZ t  t j | d d g k  s{ t  d S(
   u   
        Array parameters should all be broadcastable with each other, and with
        a scalar input the output should be broadcast to the maximum dimensions
        of the parameters.
        i   i   i
   i   id   io   iz   N(   i   (   Rk   Ro   R   Rt   R\   R`   RZ   (   R   Rr   R   (    (    s@   lib/python2.7/site-packages/astropy/modeling/tests/test_input.pyt%   test_1d_array_parameters_scalar_inputy  s
    c         C` s   t  d d g d d g  } | d d g  } t j |  d k sH t  t j | d d g k  si t  | d g d g g  } t j |  d k s t  t j | d d	 g d
 d g g k  s t  t j t   | d d d g  } Wd QXd S(   ue   
        When given an array input it must be broadcastable with all the
        parameters.
        i   i   i
   i   id   i   io   i   iz   i   i,  N(   i   (   i   i   (   Rk   R   R`   R\   RZ   R!   RB   RC   (   R   Rr   R   R   t   y3(    (    s@   lib/python2.7/site-packages/astropy/modeling/tests/test_input.pyt'   test_1d_array_parameters_1d_array_input  s    !-c      	   C` s  t  d d g d d g g d d g d d g g  } | d	 d
 g d d g g  } t j |  d  k sl t  t j | d d g d d g g k  s t  | d	 g g d
 g g g d g g d g g g g  } t j |  d! k s t  t j | d d g d d g g d d g d d g g g d d g d d g g d d g d d g g g g k  s_t  t j t  ) | d	 d
 d g d d d g g  } Wd QXd S("   ue   
        When given an array input it must be broadcastable with all the
        parameters.
        i   i   i   i   i
   i   i   i(   id   i   i,  i  io   i   iM  i  iz   i   i   i   i   i   i7  iB  iX  i  i  i  i  iX  N(   i   i   (   i   i   i   i   (   Rk   R   R`   R\   RZ   R!   RB   RC   (   R   Rr   R   R   Rz   (    (    s@   lib/python2.7/site-packages/astropy/modeling/tests/test_input.pyt'   test_2d_array_parameters_2d_array_input  s    3-6*c      	   C` s  t  d d d g d d d g g d d d	 g d
 d d g g g d d d g  } | d d d g  } t j |  d8 k s~ t  t | d d d g d d d g g d d d g d d d g g g  | d g g g d g g g d g g g g  } t j |  d9 k st  t | d d d  g d d! d" g g d d# d$ g d d% d& g g g d' d d( g d) d d* g g d+ d d, g d- d d. g g g d/ d0 d g d1 d2 d g g d3 d4 d g d5 d6 d g g g g  d7 S(:   ue   
        When given an array input it must be broadcastable with all the
        parameters.
        g{Gz?g{Gz?gQ?g{Gz?g?gQ?gQ?g{Gz?g
ףp=
?g?g)\(?gQ?i   i   i   i
   i   i   gQ&@gQ6@gp=
׃@@gGz&@g6@gHz@@gp=
#&@gGz6@gQ@@g333333&@g\(6@g(\@@g
ףp=
(@g(\*@g(@gQ*@g)\((@gGz.*@gQ8(@g=
ףp=*@g(\5@gHz7@g
ףp=
5@g(\7@gR5@gףp=
7@g5@gQ7@g(\?@g(\@@g
ףp=
?@gfffff@@gR?@g
ףp=
@@g?@gGz@@N(   i   i   i   (   i   i   i   i   (   Rk   R   R`   R\   R   (   R   Rr   R   R   (    (    s@   lib/python2.7/site-packages/astropy/modeling/tests/test_input.pyt*   test_mixed_array_parameters_1d_array_input  s*    !"0(   R   R   R    Rs   Ru   Rw   Rx   Ry   R{   R|   R}   (    (    (    s@   lib/python2.7/site-packages/astropy/modeling/tests/test_input.pyRn   =  s   								t#   TestSingleInputSingleOutputTwoModelc           B` sV   e  Z d  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 RS(	   u  
    A suite of tests to check various cases of parameter and input combinations
    on models with n_input = n_output = 1 on a toy model with n_models=2.

    Many of these tests mirror test cases in
    ``astropy.modeling.tests.test_parameters.TestParameterInitialization``,
    except that this tests how different parameter arrangements interact with
    different types of model inputs.

    With n_models=2 all outputs should have a first dimension of size 2 (unless
    defined with model_set_axis != 0).
    c         C` sm   t  d d g d d g d d } | d  } t j |  d
 k sH t  t j | d d g k  si t  d	 S(   u   
        Scalar parameters with a scalar input should return a 1-D array with
        size equal to the number of models.
        i   i   i
   i   R0   id   io   iz   N(   i   (   Rk   R   R`   R\   RZ   (   R   Rr   R   (    (    s@   lib/python2.7/site-packages/astropy/modeling/tests/test_input.pyRs     s    !c         C` sk  t  d d g d d g d d } t j t   | t j d  d  } Wd QX| d d	 g  } t j |  d k s} t  t j | d
 d g k  s t  | d d	 g d t	 } t j |  d k s t  t j | d
 d g d d g g k  s t  | d d	 d g d t	 } t j |  d k s4t  t j | d
 d d g d d d g g k  sgt  d S(   u   
        The dimension of the input should match the number of models unless
        model_set_axis=False is given, in which case the input is copied across
        all models.
        i   i   i
   i   R0   i   id   Ni   io   i   R1   i   iz   i,  i   i7  iB  (   i   (   i   i   (   i   i   (
   Rk   R!   RB   RC   R   R   R`   R\   RZ   R3   (   R   Rr   R   R   R   Rz   (    (    s@   lib/python2.7/site-packages/astropy/modeling/tests/test_input.pyRu     s    !!-c         C` s/  t  d d g d d g d d } | t j d  j d d  d  } t j |  d k sa t  t j | d	 d
 d g d d d g g k  s t  | t j d  j d d  d d t } t j |  d k s t  t j | d	 d
 d g d d d g g d d d g d d d g g g k  s+t  d S(   u   
        The dimension of the input should match the number of models unless
        model_set_axis=False is given, in which case the input is copied across
        all models.
        i   i   i
   i   R0   i   i   id   i   io   i   iB  i  i
  R1   i7  i  i  i   iz   i   N(   i   i   (   i   i   i   (   Rk   R   R   Rv   R`   R\   RZ   R3   (   R   Rr   R   R   (    (    s@   lib/python2.7/site-packages/astropy/modeling/tests/test_input.pyRw     s    !%+$c         C` s$  t  d d g d d g d d } t j d  j d d d  d } | |  } t j |  d k sj t  t j | d	 d
 g d d g d d g g d d g d d g d d g g g k  s t  | | d t } t j |  d k s t  t j | t j | d	 | d g  k  s t  d S(   u   
        The dimension of the input should match the number of models unless
        model_set_axis=False is given, in which case the input is copied across
        all models.
        i   i   i
   i   R0   i   i   id   i   io   i   i7  i  i  in  i  i6  i  i  ib  R1   i   N(   i   i   i   (   i   i   i   i   (	   Rk   R   R   Rv   R`   R\   RZ   R3   R(   (   R   Rr   t   dataR   R   (    (    s@   lib/python2.7/site-packages/astropy/modeling/tests/test_input.pyRx     s    !"'0c         C` s   t  d d d g d d d g g d d d	 g d
 d d g g d d } | d  } t j |  d k sl t  t j | d d d g d d d g g k  s t  d S(   u   
        Array parameters should all be broadcastable with each other, and with
        a scalar input the output should be broadcast to the maximum dimensions
        of the parameters.
        i   i   i   i   i   i   i
   i   i   i(   i2   i<   R0   id   io   iz   i   i   i   i   N(   i   i   (   Rk   R   R`   R\   RZ   (   R   Rr   R   (    (    s@   lib/python2.7/site-packages/astropy/modeling/tests/test_input.pyRy   *  s
    'c      	   C` sk  t  d d d g d d d g g d d d	 g d
 d d g g d d } t j t   | d d d g  } Wd QX| d d g  } t j |  d k s t  t j | d d d g d d d g g k  s t  t j t   | d d g d t } Wd QX| d d d g d t } t j |  d k s4t  t j | d d d g d d d g g k  sgt  d S(   u   
        When the input is an array, if model_set_axis=False then it must
        broadcast with the shapes of the parameters (excluding the
        model_set_axis).

        Otherwise all dimensions must be broadcastable.
        i   i   i   i   i   i   i
   i   i   i(   i2   i<   R0   id   i   i,  Nio   iz   i   i   i   i
  R1   i   iM  i   in  (   i   i   (   i   i   (	   Rk   R!   RB   RC   R   R`   R\   RZ   R3   (   R   Rr   R   R   (    (    s@   lib/python2.7/site-packages/astropy/modeling/tests/test_input.pyR{   8  s    	'3c      	   C` s  t  d d g d d g g d d g d d g g g d	 d
 g d d g g d d g d d g g g d d } | d d g d d g g  } t j |  d( k s t  t j | d d g d d g g d d g d d g g g k  s t  t j t  ) | d d d g d d d g g  } Wd  QX| d d g d d g g d d g d  d! g g g  } t j |  d) k srt  t j | d d g d" d# g g d$ d% g d& d' g g g k  st  d  S(*   Ni   i   i   i   i   i   i   i   i
   i   i   i(   i2   i<   iF   iP   R0   id   i   i,  i  io   i   i   i   ic  i  iy  i  i  iX  i  i   iM  i  i+  i  i	  ix  (   i   i   i   (   i   i   i   (   Rk   R   R`   R\   RZ   R!   RB   RC   (   R   Rr   R   R   (    (    s@   lib/python2.7/site-packages/astropy/modeling/tests/test_input.pyR|   T  s    00	'*6c         C` s  t  d d d g d d d g g d d d	 g d
 d d g g g d d d g d d d g g d d } t j t   | d d d g  } Wd  QX| d d d g d t } t j |  d$ k s t  t | d d d g d d d g g d d d  g d! d" d# g g g  d  S(%   Ng{Gz?g{Gz?gQ?g{Gz?g?gQ?gQ?g{Gz?g
ףp=
?g?g)\(?gQ?i   i   i   i   i   i   R0   i
   i   i   R1   gQ&@gQ6@gp=
׃@@gGz&@g6@gHz@@gp=
#,@gGz9@gQB@g333333,@g\(9@g(\B@(   i   i   i   (	   Rk   R!   RB   RC   R3   R   R`   R\   R   (   R   Rr   R   (    (    s@   lib/python2.7/site-packages/astropy/modeling/tests/test_input.pyR}   e  s    '!(   R   R   R    Rs   Ru   Rw   Rx   Ry   R{   R|   R}   (    (    (    s@   lib/python2.7/site-packages/astropy/modeling/tests/test_input.pyR~     s   							t
   TModel_1_2c           B` s>   e  Z d Z d Z e   Z e   Z e   Z e d    Z	 RS(   u   xu   yu   zc         C` s   |  | | |  | | | f S(   N(    (   R   R-   R?   t   p3(    (    s@   lib/python2.7/site-packages/astropy/modeling/tests/test_input.pyRl   {  s    (   u   x(   u   yu   z(
   R   R   t   inputst   outputsR
   R-   R?   R   Rm   Rl   (    (    (    s@   lib/python2.7/site-packages/astropy/modeling/tests/test_input.pyR   s  s   			t&   TestSingleInputDoubleOutputSingleModelc           B` sV   e  Z d  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 RS(	   u  
    A suite of tests to check various cases of parameter and input combinations
    on models with n_input = 1 but n_output = 2 on a toy model with n_models=1.

    As of writing there are not enough controls to adjust how outputs from such
    a model should be formatted (currently the shapes of outputs are assumed to
    be directly associated with the shapes of corresponding inputs when
    n_inputs == n_outputs).  For now, the approach taken for cases like this is
    to assume all outputs should have the same format.
    c         C` s   t  d d d  } | d  \ } } t | t  s9 t  t | t  sN t  t j |  t j |  k ow d k n s t  | d k s t  | d k s t  d S(	   uO   
        Scalar parameters with a scalar input should return a scalar.
        i   i
   i  id   i    io   iW  N(   R   Ro   Rp   R\   R   Rq   (   R   Rr   R   R@   (    (    s@   lib/python2.7/site-packages/astropy/modeling/tests/test_input.pyRs     s    4c         C` s   t  d d d  } | t j d  d  \ } } t | t j  sI t  t | t j  sa t  t j |  t j |  k o d k n s t  t j | d d d d	 d
 g k  s t  t j | | d k  s t  d S(   u   
        Scalar parameters should broadcast with an array input to result in an
        array output of the same shape as the input.
        i   i
   i  i   id   i   io   i   i7  i  N(   i   (   R   R   R   Ro   Rt   R\   R`   RZ   (   R   Rr   R   R@   (    (    s@   lib/python2.7/site-packages/astropy/modeling/tests/test_input.pyRu     s    4*c         C` s   t  d d d  } | t j d  j d d  d  \ } } t | t j  sU t  t | t j  sm t  t j |  t j |  k o d k n s t  t j | d d	 d
 g d d d g g k  s t  t j | | d k  s t  d S(   u   
        Scalar parameters should broadcast with an array input to result in an
        array output of the same shape as the input.
        i   i
   i  i   i   i   id   i   io   i   i7  i  i  N(   i   i   (	   R   R   R   Rv   Ro   Rt   R\   R`   RZ   (   R   Rr   R   R@   (    (    s@   lib/python2.7/site-packages/astropy/modeling/tests/test_input.pyRw     s    +4c         C` s  t  d d d  } | t j d  j d d d  d  \ } } t | t j  sX t  t | t j  sp t  t j |  t j |  k o d k n s t  t j | d d	 g d
 d g d d g g d d g d d g d d g g g k  s t  t j | | d k  st  d S(   u   
        Scalar parameters should broadcast with an array input to result in an
        array output of the same shape as the input.
        i   i
   i  i   i   i   id   i   io   i   i7  i  i  ic  i  i+  i  i  iW  N(   i   i   i   (	   R   R   R   Rv   Ro   Rt   R\   R`   RZ   (   R   Rr   R   R@   (    (    s@   lib/python2.7/site-packages/astropy/modeling/tests/test_input.pyRx     s    .4'0c         C` s   t  d d g d d g d d g  } | d  \ } } t | t j  sN t  t | t j  sf t  t j |  t j |  k o d k n s t  t j | d d	 g k  s t  t j | d
 d g k  s t  d S(   u   
        Array parameters should all be broadcastable with each other, and with
        a scalar input the output should be broadcast to the maximum dimensions
        of the parameters.
        i   i   i
   i   i  i  id   io   iz   iW  iJ  N(   i   (   R   Ro   R   Rt   R\   R`   RZ   (   R   Rr   R   R@   (    (    s@   lib/python2.7/site-packages/astropy/modeling/tests/test_input.pyRy     s    $4!c         C` s  t  d d g d d g d d g  } | d d g  \ } } t j |  t j |  k oe d k n sp t  t j | d	 d
 g k  s t  t j | d d g k  s t  | d g d g g  \ } } t j |  t j |  k o d k n st  t j | d	 d g d d
 g g k  s1t  t j | d d g d d g g k  s^t  t j t    | d d d g  \ } } Wd QXd S(   ue   
        When given an array input it must be broadcastable with all the
        parameters.
        i   i   i
   i   i  i  id   i   io   i   iW  i  iz   i   iJ  i  i,  N(   i   (   i   i   (   R   R   R`   R\   RZ   R!   RB   RC   (   R   Rr   R   t   z1R   t   z2Rz   t   z3(    (    s@   lib/python2.7/site-packages/astropy/modeling/tests/test_input.pyR{     s    $4!!4--c      	   C` s  t  d d g d d g g d d g d d g g d	 d
 g d d g g  } | d d g d d g g  \ } } t j |  t j |  k o d4 k n s t  t j | d d g d d g g k  s t  t j | d d g d d g g k  s t  | d g g d g g g d g g d g g g g  \ } } t j |  t j |  k o_d5 k n sjt  t j | d d g d d g g d d g d d g g g d d  g d d! g g d" d# g d$ d g g g g k  st  t j | d d% g d& d' g g d( d g d) d* g g g d+ d, g d d- g g d. d/ g d0 d g g g g k  sTt  t j t  / | d d d g d d1 d2 g g  \ } } Wd3 QXd3 S(6   ue   
        When given an array input it must be broadcastable with all the
        parameters.
        i   i   i   i   i
   i   i   i(   i  i  i  i  id   i   i,  i  io   i   iM  i  iW  i  i  i\  iz   i   i   i   i   i   i7  iB  iX  i  i  i  iJ  i=  i0  i  i  i  i  i	  i  i  iv	  ii  i  iX  N(   i   i   (   i   i   i   i   (   R   R   R`   R\   RZ   R!   RB   RC   (   R   Rr   R   R   R   R   Rz   R   (    (    s@   lib/python2.7/site-packages/astropy/modeling/tests/test_input.pyR|     s$    -$4--<4**c      	   C` s  t  d d d g d d d g g d d d	 g d
 d d g g g d d d g d d d g  } | d d d g  \ } } t j |  t j |  k o d_ k n s t  t | d d d g d d d g g d d d g d d  d! g g g  t | d" d# d$ g d% d& d' g g d( d) d* g d+ d, d- g g g  | d g g g d g g g d g g g g  \ } } t j |  t j |  k od` k n st  t | d d. d/ g d d0 d1 g g d d2 d3 g d d4 d5 g g g d6 d d7 g d8 d d9 g g d: d d; g d< d  d= g g g d> d? d g d@ dA d g g dB dC d g dD dE d! g g g g  t | d" dF dG g d% dH dI g g d( dJ dK g d+ dL dM g g g dN d# dO g dP d& dQ g g dR d) dS g dT d, dU g g g dV dW d$ g dX dY d' g g dZ d[ d* g d\ d] d- g g g g  d^ S(a   ue   
        When given an array input it must be broadcastable with all the
        parameters.
        g{Gz?g{Gz?gQ?g{Gz?g?gQ?gQ?g{Gz?g
ףp=
?g?g)\(?gQ?i   i   i   id   i   i,  i
   i   i   gQ&@gQ6@gp=
׃@@gGz&@g6@gHz@@gp=
#&@gGz6@gQ@@g333333&@g\(6@g(\@@gq=
ף[@gq=
ףk@gGzt@g(\[@gk@g)\t@gGz[@g(\k@g=
ףpt@gfffff[@gQk@gRt@g
ףp=
(@g(\*@g(@gQ*@g)\((@gGz.*@gQ8(@g=
ףp=*@g(\5@gHz7@g
ףp=
5@g(\7@gR5@gףp=
7@g5@gQ7@g(\?@g(\@@g
ףp=
?@gfffff@@gR?@g
ףp=
@@g?@gGz@@gq=
ףj@gGzs@gj@g)\s@g(\j@g=
ףps@gQj@gRs@gq=
ף@^@gGz0t@g(\B^@g)\0t@gGzD^@g=
ףp1t@gfffffF^@gR1t@gQ``@gq=
ף m@gzGa`@gm@g
ףp=b`@g(\m@g33333c`@gQm@N(   i   i   i   (   i   i   i   i   (   R   R   R`   R\   R   (   R   Rr   R   R   R   R   (    (    s@   lib/python2.7/site-packages/astropy/modeling/tests/test_input.pyR}     sJ    4!"64(   R   R   R    Rs   Ru   Rw   Rx   Ry   R{   R|   R}   (    (    (    s@   lib/python2.7/site-packages/astropy/modeling/tests/test_input.pyR     s   
							t   TInputFormatterc           B` s)   e  Z d  Z d Z d Z e d    Z RS(   u6   
    A toy model to test input/output formatting.
    u   xu   yc         C` s
   |  | f S(   N(    (   R   R   (    (    s@   lib/python2.7/site-packages/astropy/modeling/tests/test_input.pyRl   >  s    (   u   xu   y(   u   xu   y(   R   R   R    R   R   Rm   Rl   (    (    (    s@   lib/python2.7/site-packages/astropy/modeling/tests/test_input.pyR   6  s   c          C` s.   t    }  |  d d  } | d k s* t  d  S(   Ni   i   (   i   i   (   R   R\   (   R   t   result(    (    s@   lib/python2.7/site-packages/astropy/modeling/tests/test_input.pyt   test_format_input_scalarsC  s    	c          C` sY   t    }  |  d d g d d g  } t | t j d d g  t j d d g  f  d  S(   Ni   i   (   R   R   R   R(   (   R   R   (    (    s@   lib/python2.7/site-packages/astropy/modeling/tests/test_input.pyt   test_format_input_arraysI  s    	c          C` s\   t    }  t j d d g g  j t j d d g g  j f } |  |   } t | |  d  S(   Ni   i   (   R   R   R(   R7   R   (   R   t   inputR   (    (    s@   lib/python2.7/site-packages/astropy/modeling/tests/test_input.pyt#   test_format_input_arrays_transposedO  s    	6(3   R    t
   __future__R    R   R   R   R!   t   numpyR   t   numpy.testingR   t    R   R   t   coreR   R   R	   R*   R
   t   extern.six.movesR   t   scipyR   t   Truet	   HAS_SCIPYt   ImportErrorR3   R)   R;   R8   t   Shiftt   ScaleR$   R>   t
   Legendre2Dt   Chebyshev2DR%   t   objectR   R&   RY   Rk   Rn   R~   R   R   R   R   R   R   (    (    (    s@   lib/python2.7/site-packages/astropy/modeling/tests/test_input.pyt   <module>   sD   "

W			