ó
šßÈ[c           @` s~  d  Z  d d l m Z m Z m Z m Z d d l Z d d l Z d d l Z d d l	 Z	 d d l
 Z d d l m Z d d l m Z m Z d d l m Z m Z d d l m Z d d	 l m Z d
 d l m Z d
 d l m Z d d d g Z d e f d „  ƒ  YZ d e e f d „  ƒ  YZ d e f d „  ƒ  YZ d „  Z  e! d „ Z" d „  Z# d „  Z$ d e f d „  ƒ  YZ% d „  Z& d S(   u¦   
This module defines two classes that deal with parameters.

It is unlikely users will need to work with these classes directly, unless they
define their own models.
i    (   t   absolute_importt   unicode_literalst   divisiont   print_functionNi   (   t   units(   t   Quantityt
   UnitsError(   t
   isiterablet   OrderedDescriptor(   t   six(   t   zipi   (   t   array_repr_oneline(   t   get_inputs_and_paramsu	   Parameteru   InputParameterErroru   ParameterErrort   ParameterErrorc           B` s   e  Z d  Z RS(   uD   Generic exception class for all exceptions pertaining to Parameters.(   t   __name__t
   __module__t   __doc__(    (    (    s:   lib/python2.7/site-packages/astropy/modeling/parameters.pyR       s   t   InputParameterErrorc           B` s   e  Z d  Z RS(   u:   Used for incorrect input parameter values and definitions.(   R   R   R   (    (    (    s:   lib/python2.7/site-packages/astropy/modeling/parameters.pyR   $   s   t   ParameterDefinitionErrorc           B` s   e  Z d  Z RS(   u3   Exception in declaration of class-level Parameters.(   R   R   R   (    (    (    s:   lib/python2.7/site-packages/astropy/modeling/parameters.pyR   (   s   c         C` s   t  |  ƒ r` y t j |  d t j ƒ}  Wqü t t f k
 r\ t d j t |  ƒ ƒ ƒ ‚ qü Xnœ t	 |  t
 ƒ rr nŠ t	 |  t j ƒ r™ t |  j ƒ  ƒ }  nc t	 |  t j t j f ƒ rÃ t |  ƒ }  n9 t	 |  t ƒ rá t d ƒ ‚ n t d j t |  ƒ ƒ ƒ ‚ |  S(   u+   Convert a parameter to float or float arrayt   dtypeu0   Parameter of {0} could not be converted to floatu7   Expected parameter to be of numerical type, not booleanu3   Don't know how to convert parameter of {0} to float(   R   t   npt
   asanyarrayt   floatt	   TypeErrort
   ValueErrorR   t   formatt   typet
   isinstanceR   t   ndarrayt   itemt   numberst   Numbert   numbert   bool(   t   value(    (    s:   lib/python2.7/site-packages/astropy/modeling/parameters.pyt   _tofloat,   s(    c         ` s%   t  j ˆ  ƒ ‡  ‡ f d †  ƒ } | S(   Nc         ` sg   |  j  d  k r t S|  j d  k	 r: t |  j |  j ƒ } n	 |  j } ˆ rV ˆ  | | ƒ Sˆ  | | ƒ Sd  S(   N(   t   _modelt   Nonet   NotImplementedt   unitR   R"   (   t   selft   valt
   self_value(   t   opt	   reflected(    s:   lib/python2.7/site-packages/astropy/modeling/parameters.pyt   wrapperM   s    	(   t	   functoolst   wraps(   R+   R,   R-   (    (   R+   R,   s:   lib/python2.7/site-packages/astropy/modeling/parameters.pyt   _binary_arithmetic_operationL   s    !c         ` s"   t  j ˆ  ƒ ‡  f d †  ƒ } | S(   Nc         ` s{   |  j  d  k r> ˆ  t j k r7 t |  j |  ƒ j | ƒ St Sn  |  j d  k	 re t	 |  j
 |  j ƒ } n	 |  j
 } ˆ  | | ƒ S(   N(   R$   R%   t   operatort   ltt   supert	   __class__t   __lt__R&   R'   R   R"   (   R(   R)   R*   (   R+   (    s:   lib/python2.7/site-packages/astropy/modeling/parameters.pyR-   a   s    	(   R.   R/   (   R+   R-   (    (   R+   s:   lib/python2.7/site-packages/astropy/modeling/parameters.pyt   _binary_comparison_operation`   s    c         ` s"   t  j ˆ  ƒ ‡  f d †  ƒ } | S(   Nc         ` sM   |  j  d  k r t S|  j d  k	 r: t |  j |  j ƒ } n	 |  j } ˆ  | ƒ S(   N(   R$   R%   R&   R'   R   R"   (   R(   R*   (   R+   (    s:   lib/python2.7/site-packages/astropy/modeling/parameters.pyR-   x   s    	(   R.   R/   (   R+   R-   (    (   R+   s:   lib/python2.7/site-packages/astropy/modeling/parameters.pyt   _unary_arithmetic_operationw   s    t	   Parameterc           B` s°  e  Z d  Z d- Z d Z d Z d d d. d. d. d. e e d. d. d. d. d „ Z d „  Z	 d	 „  Z
 d
 „  Z d „  Z d „  Z d „  Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z e j d „  ƒ Z e d „  ƒ Z e j d „  ƒ Z e d „ Z e d „  ƒ Z e j d „  ƒ Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z e j d „  ƒ Z e d „  ƒ Z e j d „  ƒ Z e d „  ƒ Z e j d „  ƒ Z e d „  ƒ Z e j d  „  ƒ Z e d! „  ƒ Z e j d" „  ƒ Z e d# „  ƒ Z d. d. d. d. d. d. e e d. d. d. d$ „ Z e d% „  ƒ Z  d& „  Z! d' „  Z" d( „  Z# e$ d) „  ƒ Z% d. d* „ Z& d+ „  Z' e' Z( e) e* j+ ƒ Z, e) e* j+ d, e- ƒZ. e) e* j/ ƒ Z0 e) e* j/ d, e- ƒZ1 e) e* j2 ƒ Z3 e) e* j2 d, e- ƒZ4 e) e* j5 ƒ Z6 e) e* j5 d, e- ƒZ7 e) e* j8 ƒ Z9 e) e* j8 d, e- ƒZ: e) e* j8 ƒ Z; e) e* j8 d, e- ƒZ< e= e* j> ƒ Z? e= e* j@ ƒ ZA e= e* jB ƒ ZC e= e* jD ƒ ZE e= e* jF ƒ ZG e= e* jH ƒ ZI eJ e* jK ƒ ZL eJ e* jM ƒ ZN RS(/   u  
    Wraps individual parameters.

    This class represents a model's parameter (in a somewhat broad sense).  It
    acts as both a descriptor that can be assigned to a class attribute to
    describe the parameters accepted by an individual model (this is called an
    "unbound parameter"), or it can act as a proxy for the parameter values on
    an individual model instance (called a "bound parameter").

    Parameter instances never store the actual value of the parameter directly.
    Rather, each instance of a model stores its own parameters parameter values
    in an array.  A *bound* Parameter simply wraps the value in a Parameter
    proxy which provides some additional information about the parameter such
    as its constraints.  In other words, this is a high-level interface to a
    model's adjustable parameter values.

    *Unbound* Parameters are not associated with any specific model instance,
    and are merely used by model classes to determine the names of their
    parameters and other information about each parameter such as their default
    values and default constraints.

    See :ref:`modeling-parameters` for more details.

    Parameters
    ----------
    name : str
        parameter name

        .. warning::

            The fact that `Parameter` accepts ``name`` as an argument is an
            implementation detail, and should not be used directly.  When
            defining a new `Model` class, parameter names are always
            automatically defined by the class attribute they're assigned to.
    description : str
        parameter description
    default : float or array
        default value to use for this parameter
    unit : `~astropy.units.Unit`
        if specified, the parameter will be in these units, and when the
        parameter is updated in future, it should be set to a
        :class:`~astropy.units.Quantity` that has equivalent units.
    getter : callable
        a function that wraps the raw (internal) value of the parameter
        when returning the value through the parameter proxy (eg. a
        parameter may be stored internally as radians but returned to the
        user as degrees)
    setter : callable
        a function that wraps any values assigned to this parameter; should
        be the inverse of getter
    fixed : bool
        if True the parameter is not varied during fitting
    tied : callable or False
        if callable is supplied it provides a way to link the value of this
        parameter to another parameter (or some other arbitrary function)
    min : float
        the lower bound of a parameter
    max : float
        the upper bound of a parameter
    bounds : tuple
        specify min and max as a single tuple--bounds may not be specified
        simultaneously with min or max
    model : `Model` instance
        binds the the `Parameter` instance to a specific model upon
        instantiation; this should only be used internally for creating bound
        Parameters, and should not be used for `Parameter` descriptors defined
        as class attributes
    u   fixedu   tiedu   boundsu   _parameters_u   _nameu    c         C` sy  t  t |  ƒ j ƒ  | |  _ | j ƒ  |  _ |  _ | d  k rœ t | t	 ƒ rœ | d  k	 r‡ | j
 | j ƒ r‡ t d j | | ƒ ƒ ‚ n  | j } | j } n  | |  _ | |  _ | d  k	 rí |	 d  k	 sÒ |
 d  k	 rù t d j | ƒ ƒ ‚ qù n |	 |
 f } | |  _ | |  _ | |  _ d  |  _ d  |  _ |  j | d  ƒ |  _ |  j | d  ƒ |  _ d  |  _ | d  k	 ru|  j | ƒ n  d  S(   NuM   parameter default {0} does not have units equivalent to the required unit {1}u^   bounds may not be specified simultaneously with min or or max when instantiating Parameter {0}(   R3   R8   t   __init__t   _namet   stripR   t   _descriptionR%   R   R   t   is_equivalentR'   R   R   R"   t   _defaultt   _unitR   t   _fixedt   _tiedt   _boundst   _orderR$   t   _create_value_wrappert   _gettert   _settert
   _validatort   _bind(   R(   t   namet   descriptiont   defaultR'   t   gettert   settert   fixedt   tiedt   mint   maxt   boundst   model(    (    s:   lib/python2.7/site-packages/astropy/modeling/parameters.pyR9   Ø   s8    										c         C` sI   | d  k r |  S|  j j |  j ƒ } | j j |  j ƒ | j | ƒ | S(   N(   R%   R4   t   __new__t   __dict__t   updateRH   (   R(   t   objt   objtypet	   parameter(    (    s:   lib/python2.7/site-packages/astropy/modeling/parameters.pyt   __get__  s    c         C` s*  t  | ƒ } | j |  j d } | d  k rX t | t ƒ r™ | j | j |  j d <q™ nA t | t ƒ s‚ t d j |  j	 ƒ ƒ ‚ n | j | j |  j d <|  j
 d  k	 r» |  j
 | | ƒ n  |  j d  k	 r|  j |  j | ƒ } |  j d  k	 r| | |  j ƒ j } q| | ƒ } n  |  j | | ƒ d  S(   Nu	   orig_unitue   The '{0}' parameter should be given as a Quantity because it was originally initialized as a Quantity(   R#   t   _param_metricsRI   R%   R   R   R'   R   R   R:   RG   RF   RD   R"   t   _set_model_value(   R(   RW   R"   t
   param_unitRM   (    (    s:   lib/python2.7/site-packages/astropy/modeling/parameters.pyt   __set__  s"    	c         C` s+   |  j  d  k r t d ƒ ‚ n  t |  j  ƒ S(   Nu+   Parameter definitions do not have a length.(   R$   R%   R   t   len(   R(   (    (    s:   lib/python2.7/site-packages/astropy/modeling/parameters.pyt   __len__9  s    c         C` s2   |  j  } t |  j ƒ d k r* | g } n  | | S(   Ni   (   R"   R_   R$   (   R(   t   keyR"   (    (    s:   lib/python2.7/site-packages/astropy/modeling/parameters.pyt   __getitem__>  s    	c         C` sä   |  j  } t |  j ƒ } t | t ƒ r  t | | ƒ d k rX t d j |  j ƒ ƒ ‚ n  x… t t	 | j
 t |  ƒ ƒ Œ  | ƒ D] \ } } |  j | | ƒ q} Wn@ y | | | <Wn/ t k
 rß t d j | |  j | ƒ ƒ ‚ n Xd  S(   Ni    u;   Slice assignment outside the parameter dimensions for '{0}'uB   Input dimension {0} invalid for {1!r} parameter with dimension {2}(   R"   R_   R$   R   t   sliceR   R   RI   R
   t   ranget   indicest   __setitem__t
   IndexError(   R(   Ra   R"   t   oldvaluet   n_modelst   idxR)   (    (    s:   lib/python2.7/site-packages/astropy/modeling/parameters.pyRf   F  s    	1c         C` sñ   d j  |  j ƒ } |  j d  k rL |  j d  k	 rb | d j  |  j ƒ 7} qb n | d j  |  j ƒ 7} |  j d  k	 rŠ | d j  |  j ƒ 7} n  xN |  j D]C } t |  | ƒ } | d  t	 d f k r” | d j  | | ƒ 7} q” q” Wd j  |  j
 j | ƒ S(   Nu   '{0}'u   , default={0}u   , value={0}u
   , unit={0}u	   , {0}={1}u   {0}({1})(   NN(   R   R:   R$   R%   R>   R"   R'   t   constraintst   getattrt   FalseR4   R   (   R(   t   argst   consR)   (    (    s:   lib/python2.7/site-packages/astropy/modeling/parameters.pyt   __repr__`  s    c         C` s   |  j  S(   u   Parameter name(   R:   (   R(   (    (    s:   lib/python2.7/site-packages/astropy/modeling/parameters.pyRI   t  s    c         C` sÉ   |  j  d k s3 |  j d k s3 t |  j  ƒ d k r: |  j St |  j  ƒ } |  j  j } |  j } t j | ƒ d | d t j | ƒ } t j | | ƒ } t j	 | d | ƒ } t j
 | | d d ƒ} | S(   u   Parameter default valuei   iÿÿÿÿt   axisN(   i   (   R$   R%   R>   R_   t   _model_set_axisR   t   shapet   ndimt   reshapet   rollaxist   repeat(   R(   Ri   t   model_set_axisRK   t	   new_shape(    (    s:   lib/python2.7/site-packages/astropy/modeling/parameters.pyRK   z  s    	c         C` s­   |  j  d k r t d ƒ ‚ n  |  j |  j  ƒ } |  j d k rC | S|  j  j |  j d } |  j  j |  j d } | d k	 rœ t j |  j | | | ƒ j	 ƒ S|  j | ƒ Sd S(   u.   The unadorned value proxied by this parameter.u*   Parameter definition does not have a valueu   raw_unitu	   orig_unitN(
   R$   R%   t   AttributeErrort   _get_model_valueRE   R[   RI   R   t   float64R"   (   R(   R"   t   raw_unitt	   orig_unit(    (    s:   lib/python2.7/site-packages/astropy/modeling/parameters.pyR"   –  s    c         C` st   |  j  d  k r t d ƒ ‚ n  |  j d  k	 r? |  j | ƒ } n  t | t ƒ r] t d ƒ ‚ n  |  j |  j  | ƒ d  S(   Nu,   Cannot set a value on a parameter definitionu±   The .value property on parameters should be set to unitless values, not Quantity objects. To set a parameter to a quantity simply set the parameter directly without using .value(   R$   R%   Rz   RF   R   R   R   R\   (   R(   R"   R)   (    (    s:   lib/python2.7/site-packages/astropy/modeling/parameters.pyR"   ¨  s    c         C` s:   |  j  d k r |  j S|  j  j |  j j d |  j ƒ Sd S(   uô   
        The unit attached to this parameter, if any.

        On unbound parameters (i.e. parameters accessed through the
        model class, rather than a model instance) this is the required/
        default unit for the parameter.
        u	   orig_unitN(   R$   R%   R?   R[   RI   t   get(   R(   (    (    s:   lib/python2.7/site-packages/astropy/modeling/parameters.pyR'   ¸  s    
c         C` s   |  j  | ƒ d  S(   N(   t	   _set_unit(   R(   R'   (    (    s:   lib/python2.7/site-packages/astropy/modeling/parameters.pyR'   É  s    c         C` s€   |  j  d  k r t d ƒ ‚ n  |  j  j |  j d } | rU | |  j  j |  j d <n' | d  k rp t d ƒ ‚ n t d ƒ ‚ d  S(   Nu)   Cannot set unit on a parameter definitionu	   orig_unituN   Cannot attach units to parameters that were not initially specified with unitsuY   Cannot change the unit attribute directly, instead change the parameter to a new quantity(   R$   R%   Rz   R[   RI   R   (   R(   R'   t   forceR~   (    (    s:   lib/python2.7/site-packages/astropy/modeling/parameters.pyR€   Í  s    c         C` s%   |  j  d k	 r |  j |  j  Sd Sd S(   uQ   
        This parameter, as a :class:`~astropy.units.Quantity` instance.
        N(   R'   R%   R"   (   R(   (    (    s:   lib/python2.7/site-packages/astropy/modeling/parameters.pyt   quantityÞ  s    c         C` sD   t  | t ƒ s t d ƒ ‚ n  | j |  _ |  j | j d t ƒd  S(   Nu:   The .quantity attribute should be set to a Quantity objectR   (   R   R   R   R"   R€   R'   t   True(   R(   R‚   (    (    s:   lib/python2.7/site-packages/astropy/modeling/parameters.pyR‚   è  s    c         C` s’   |  j  d k r t d ƒ ‚ n  |  j  j |  j d } t |  j  ƒ d k rŽ |  j  j } | d k  ru t | ƒ | } n  | |  | | d } n  | S(   u*   The shape of this parameter's value array.u+   Parameter definition does not have a shape.u   shapei   i    N(   R$   R%   Rz   R[   R:   R_   Rr   (   R(   Rs   t
   model_axis(    (    s:   lib/python2.7/site-packages/astropy/modeling/parameters.pyRs   ï  s    c         C` s   t  j |  j ƒ S(   u)   The size of this parameter's value array.(   R   t   sizeR"   (   R(   (    (    s:   lib/python2.7/site-packages/astropy/modeling/parameters.pyR…     s    c         C` s@   |  j  d k	 r5 |  j  j d } | j |  j |  j ƒ S|  j Sd S(   uS   
        Boolean indicating if the parameter is kept fixed during fitting.
        u   fixedN(   R$   R%   t   _constraintsR   R:   R@   (   R(   RN   (    (    s:   lib/python2.7/site-packages/astropy/modeling/parameters.pyRN     s    c         C` sW   |  j  d k	 rG t | t ƒ s- t d ƒ ‚ n  | |  j  j d |  j <n t d ƒ ‚ d S(   u   Fix a parameteru   Fixed can be True or Falseu   fixedu3   can't set attribute 'fixed' on Parameter definitionN(   R$   R%   R   R!   R   R†   R:   Rz   (   R(   R"   (    (    s:   lib/python2.7/site-packages/astropy/modeling/parameters.pyRN     s
    c         C` s@   |  j  d k	 r5 |  j  j d } | j |  j |  j ƒ S|  j Sd S(   u”   
        Indicates that this parameter is linked to another one.

        A callable which provides the relationship of the two parameters.
        u   tiedN(   R$   R%   R†   R   R:   RA   (   R(   RO   (    (    s:   lib/python2.7/site-packages/astropy/modeling/parameters.pyRO   %  s    c         C` sj   |  j  d k	 rZ t j | ƒ r@ | t d f k r@ t d ƒ ‚ n  | |  j  j d |  j <n t d ƒ ‚ d S(   u   Tie a parameteru   Tied must be a callableu   tiedu2   can't set attribute 'tied' on Parameter definitionN(	   R$   R%   R	   t   callableRm   R   R†   R:   Rz   (   R(   R"   (    (    s:   lib/python2.7/site-packages/astropy/modeling/parameters.pyRO   3  s
    "c         C` s@   |  j  d k	 r5 |  j  j d } | j |  j |  j ƒ S|  j Sd S(   u8   The minimum and maximum values of a parameter as a tupleu   boundsN(   R$   R%   R†   R   R:   RB   (   R(   RR   (    (    s:   lib/python2.7/site-packages/astropy/modeling/parameters.pyRR   ?  s    c         C` sÛ   |  j  d k	 rË | \ } } | d k	 rW t | t j ƒ sH t d ƒ ‚ n  t | ƒ } n  | d k	 r“ t | t j ƒ s„ t d ƒ ‚ n  t | ƒ } n  |  j  j j d i  ƒ } | | f |  j  j d |  j	 <n t
 d ƒ ‚ d S(   u>   Set the minimum and maximum values of a parameter from a tupleu   Min value must be a numberu   Max value must be a numberu   boundsu4   can't set attribute 'bounds' on Parameter definitionN(   R$   R%   R   R   R   R   R   R†   t
   setdefaultR:   Rz   (   R(   R"   t   _mint   _maxRR   (    (    s:   lib/python2.7/site-packages/astropy/modeling/parameters.pyRR   I  s     c         C` s   |  j  d S(   u6   A value used as a lower bound when fitting a parameteri    (   RR   (   R(   (    (    s:   lib/python2.7/site-packages/astropy/modeling/parameters.pyRP   _  s    c         C` s4   |  j  d k	 r$ | |  j f |  _ n t d ƒ ‚ d S(   u"   Set a minimum value of a parameteru1   can't set attribute 'min' on Parameter definitionN(   R$   R%   RQ   RR   Rz   (   R(   R"   (    (    s:   lib/python2.7/site-packages/astropy/modeling/parameters.pyRP   e  s    c         C` s   |  j  d S(   u7   A value used as an upper bound when fitting a parameteri   (   RR   (   R(   (    (    s:   lib/python2.7/site-packages/astropy/modeling/parameters.pyRQ   o  s    c         C` s4   |  j  d k	 r$ |  j | f |  _ n t d ƒ ‚ d S(   u#   Set a maximum value of a parameter.u1   can't set attribute 'max' on Parameter definitionN(   R$   R%   RP   RR   Rz   (   R(   R"   (    (    s:   lib/python2.7/site-packages/astropy/modeling/parameters.pyRQ   u  s    c         C` s^   |  j  d k r |  d „ } | Sd „  } t j rJ t j | |  t |  ƒ ƒ St j | |  ƒ Sd S(   uA
  
        Used as a decorator to set the validator method for a `Parameter`.
        The validator method validates any value set for that parameter.
        It takes two arguments--``self``, which refers to the `Model`
        instance (remember, this is a method defined on a `Model`), and
        the value being set for this parameter.  The validator method's
        return value is ignored, but it may raise an exception if the value
        set on the parameter is invalid (typically an `InputParameterError`
        should be raised, though this is not currently a requirement).

        The decorator *returns* the `Parameter` instance that the validator
        is set on, so the underlying validator method should have the same
        name as the `Parameter` itself (think of this as analogous to
        ``property.setter``).  For example::

            >>> from astropy.modeling import Fittable1DModel
            >>> class TestModel(Fittable1DModel):
            ...     a = Parameter()
            ...     b = Parameter()
            ...
            ...     @a.validator
            ...     def a(self, value):
            ...         # Remember, the value can be an array
            ...         if np.any(value < self.b):
            ...             raise InputParameterError(
            ...                 "parameter 'a' must be greater than or equal "
            ...                 "to parameter 'b'")
            ...
            ...     @staticmethod
            ...     def evaluate(x, a, b):
            ...         return a * x + b
            ...
            >>> m = TestModel(a=1, b=2)  # doctest: +IGNORE_EXCEPTION_DETAIL
            Traceback (most recent call last):
            ...
            InputParameterError: parameter 'a' must be greater than or equal
            to parameter 'b'
            >>> m = TestModel(a=2, b=2)
            >>> m.a = 0  # doctest: +IGNORE_EXCEPTION_DETAIL
            Traceback (most recent call last):
            ...
            InputParameterError: parameter 'a' must be greater than or equal
            to parameter 'b'

        On bound parameters this property returns the validator method itself,
        as a bound method on the `Parameter`.  This is not often as useful, but
        it allows validating a parameter value without setting that parameter::

            >>> m.a.validator(42)  # Passes
            >>> m.a.validator(-42)  # doctest: +IGNORE_EXCEPTION_DETAIL
            Traceback (most recent call last):
            ...
            InputParameterError: parameter 'a' must be greater than or equal
            to parameter 'b'
        c         S` s   |  | _  | S(   N(   RG   (   t   funcR(   (    (    s:   lib/python2.7/site-packages/astropy/modeling/parameters.pyt	   validator»  s    	c         S` s&   |  j  d  k	 r" |  j  |  j | ƒ Sd  S(   N(   RG   R%   R$   (   R(   R"   (    (    s:   lib/python2.7/site-packages/astropy/modeling/parameters.pyRŒ   Ã  s    N(   R$   R%   R	   t   PY2t   typest
   MethodTypeR   (   R(   RŒ   (    (    s:   lib/python2.7/site-packages/astropy/modeling/parameters.pyRŒ     s    :		c         C` s¸   t  ƒ  j ƒ  } | d =x’ t j | ƒ D] \ } } | d k r& | d k rP q& nJ t |  | ƒ rq t |  | ƒ } n) t |  d | ƒ rš t |  d | ƒ } n  | | | <q& q& W|  j |   S(   uÄ  
        Make a copy of this `Parameter`, overriding any of its core attributes
        in the process (or an exact copy).

        The arguments to this method are the same as those for the `Parameter`
        initializer.  This simply returns a new `Parameter` instance with any
        or all of the attributes overridden, and so returns the equivalent of:

        .. code:: python

            Parameter(self.name, self.description, ...)

        u   selfu   minu   maxu   _N(   u   minu   max(   t   localst   copyR	   t	   iteritemsR%   t   hasattrRl   R4   (   R(   RI   RJ   RK   R'   RL   RM   RN   RO   RP   RQ   RR   t   kwargsRa   R"   (    (    s:   lib/python2.7/site-packages/astropy/modeling/parameters.pyR‘   Ì  s    c         C` s   |  j  |  j ƒ S(   uc  
        Currently for internal use only.

        Like Parameter.value but does not pass the result through
        Parameter.getter.  By design this should only be used from bound
        parameters.

        This will probably be removed are retweaked at some point in the
        process of rethinking how parameter values are stored/updated.
        (   R{   R$   (   R(   (    (    s:   lib/python2.7/site-packages/astropy/modeling/parameters.pyt
   _raw_valueï  s    c         C` s=   | |  _  |  j |  j | ƒ |  _ |  j |  j | ƒ |  _ d S(   uÆ   
        Bind the `Parameter` to a specific `Model` instance; don't use this
        directly on *unbound* parameters, i.e. `Parameter` descriptors that
        are defined in class bodies.
        N(   R$   RD   RE   RF   (   R(   RS   (    (    s:   lib/python2.7/site-packages/astropy/modeling/parameters.pyRH   þ  s    	c         C` sx   t  | d ƒ s! t |  j ƒ ‚ n  | j |  j } | d } | d } | j | } | rj | j | ƒ } n
 | d } | S(   u?  
        This method implements how to retrieve the value of this parameter from
        the model instance.  See also `Parameter._set_model_value`.

        These methods take an explicit model argument rather than using
        self._model so that they can be used from unbound `Parameter`
        instances.
        u   _parametersu   sliceu   shapei    (   R“   Rz   R:   R[   t   _parametersRu   (   R(   RS   t   param_metricst   param_slicet   param_shapeR"   (    (    s:   lib/python2.7/site-packages/astropy/modeling/parameters.pyR{     s    



c         C` sx   d „  } | | |  j  | ƒ t | d ƒ rt | j |  j  \ } } t | j | d ƒ rt | | j | | | ƒ qt n  d S(   uW  
        This method implements how to store the value of a parameter on the
        model instance.

        Currently there is only one storage mechanism (via the ._parameters
        array) but other mechanisms may be desireable, in which case really the
        model class itself should dictate this and *not* `Parameter` itself.
        c         S` s€   |  j  | } | d } | d } t j | ƒ } t j | ƒ | k r` t d j | | ƒ ƒ ‚ n  t j | ƒ j ƒ  |  j | <d  S(   Nu   sliceu   shapeuT   Input value for parameter {0!r} does not have {1} elements as the current value does(	   R[   R   t   prodR…   R   R   t   arrayt   ravelR–   (   RS   RI   R"   R—   R˜   R™   t
   param_size(    (    s:   lib/python2.7/site-packages/astropy/modeling/parameters.pyt   _update_parameter_value1  s    

u
   _param_mapu   _param_metricsN(   R:   R“   t
   _param_mapt
   _submodels(   R(   RS   R"   Rž   t   submodel_indt
   param_name(    (    s:   lib/python2.7/site-packages/astropy/modeling/parameters.pyR\   (  s    		c         C` sÄ   t  |  t j ƒ r3 |  j d k rÀ t d ƒ ‚ qÀ n |  d k rC d St |  ƒ \ } } t | ƒ } | d k rp nP | d k r´ | d k	 rÀ | d j } t	 j
 |  i | | 6 }  qÀ n t d ƒ ‚ |  S(   uM  Wraps a getter/setter function to support optionally passing in
        a reference to the model object as the second argument.

        If a model is tied to this parameter and its getter/setter supports
        a second argument then this creates a partial function using the model
        instance as the second argument.
        i   uO   A numpy.ufunc used for Parameter getter/setter may only take one input argumenti   uI   Parameter getter/setter must be a function of either one or two argumentsN(   R   R   t   ufunct   ninR   R%   R   R_   RI   R.   t   partial(   R-   RS   t   inputst   paramst   nargst	   model_arg(    (    s:   lib/python2.7/site-packages/astropy/modeling/parameters.pyRD   D  s    
c         C` sF   t  j |  j d | ƒ} |  j d  k	 rB t | |  j d t ƒ} n  | S(   NR   R‘   (   R   t   asarrayR"   R'   R%   R   Rm   (   R(   R   t   arr(    (    s:   lib/python2.7/site-packages/astropy/modeling/parameters.pyt	   __array__h  s    c         C` s$   |  j  d  k r t St |  j ƒ Sd  S(   N(   R$   R%   Rƒ   R!   R"   (   R(   (    (    s:   lib/python2.7/site-packages/astropy/modeling/parameters.pyt   __nonzero__q  s    R,   (   u   fixedu   tiedu   boundsN(O   R   R   R   Rk   t   _class_attribute_t   _name_attribute_R%   Rm   R9   RZ   R^   R`   Rb   Rf   Rp   t   propertyRI   RK   R"   RM   R'   R€   R‚   Rs   R…   RN   RO   RR   RP   RQ   RŒ   R‘   R•   RH   R{   R\   t   staticmethodRD   R¬   R­   t   __bool__R0   R1   t   addt   __add__Rƒ   t   __radd__t   subt   __sub__t   __rsub__t   mult   __mul__t   __rmul__t   powt   __pow__t   __rpow__t   truedivt   __div__t   __rdiv__t   __truediv__t   __rtruediv__R6   t   eqt   __eq__t   net   __ne__R2   R5   t   gtt   __gt__t   let   __le__t   get   __ge__R7   t   negt   __neg__t   abst   __abs__(    (    (    s:   lib/python2.7/site-packages/astropy/modeling/parameters.pyR8   ‡   s„   D4						
	


M!			$		c         C` s:   t  |  j ƒ } |  j d k	 r6 d j | |  j ƒ } n  | S(   u„   
    Like array_repr_oneline but works on `Parameter` objects and supports
    rendering parameters with units like quantities.
    u	   {0} {1!s}N(   R   R"   R'   R%   R   (   t   paramt   out(    (    s:   lib/python2.7/site-packages/astropy/modeling/parameters.pyt   param_repr_oneline  s    ('   R   t
   __future__R    R   R   R   R.   R   RŽ   R1   t   numpyR   t    R   t   uR   R   t   utilsR   R   t   externR	   t   extern.six.movesR
   R   R   t   __all__t	   ExceptionR   R   R   R   R#   Rm   R0   R6   R7   R8   RÔ   (    (    (    s:   lib/python2.7/site-packages/astropy/modeling/parameters.pyt   <module>   s4   "	 		ÿ ÿ ÿ 