
    HR-et                        d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dl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mZ d dlmZ d dlZd dlmZ d dlmZ d dlmZ eeej        fZd Ze ej!        fZ" G d d	          Z#d
 Z$d0dZ%d Z&ej'        dd         dk    rd dlm(Z( nd Z(d Z)d Z*d Z+d Z,d Z-d Z.d Z/d Z0d Z1d Z2d Z3d Z4da5d Z6dZ7dZ8d  Z9d! Z:d" Z;d# Z<d$ Z=d% Z>d& Z?d' Z@d( ZAd) ZBd* ZCed0d+            ZDd, ZEd- ZFd. ZGd/ ZHdS )1    N)contextmanagersuppresswraps)Version)data)AstropyUserWarningc                     | |k    | |k     z
  S N )abs     4lib/python3.11/site-packages/astropy/io/fits/util.py<lambda>r      s    AEa!e$     c                   8     e Zd ZdZdZd Zd Zd Z fdZ xZ	S )NotifierMixina~  
    Mixin class that provides services by which objects can register
    listeners to changes on that object.

    All methods provided by this class are underscored, since this is intended
    for internal use to communicate between classes in a generic way, and is
    not machinery that should be exposed to users of the classes involved.

    Use the ``_add_listener`` method to register a listener on an instance of
    the notifier.  This registers the listener with a weak reference, so if
    no other references to the listener exist it is automatically dropped from
    the list and does not need to be manually removed.

    Call the ``_notify`` method on the notifier to update all listeners
    upon changes.  ``_notify('change_type', *args, **kwargs)`` results
    in calling ``listener._update_change_type(*args, **kwargs)`` on all
    listeners subscribed to that notifier.

    If a particular listener does not have the appropriate update method
    it is ignored.

    Examples
    --------
    >>> class Widget(NotifierMixin):
    ...     state = 1
    ...     def __init__(self, name):
    ...         self.name = name
    ...     def update_state(self):
    ...         self.state += 1
    ...         self._notify('widget_state_changed', self)
    ...
    >>> class WidgetListener:
    ...     def _update_widget_state_changed(self, widget):
    ...         print('Widget {0} changed state to {1}'.format(
    ...             widget.name, widget.state))
    ...
    >>> widget = Widget('fred')
    >>> listener = WidgetListener()
    >>> widget._add_listener(listener)
    >>> widget.update_state()
    Widget fred changed state to 2
    Nc                 r    | j         t          j                    | _         || j         t          |          <   dS )z
        Add an object to the list of listeners to notify of changes to this
        object.  This adds a weakref to the list of listeners that is
        removed from the listeners list when the listener has no other
        references to it.
        N)
_listenersweakrefWeakValueDictionaryidselflisteners     r   _add_listenerzNotifierMixin._add_listenerO   s4     ?"%9;;DO(08%%%r   c                     | j         dS t          t                    5  | j         t          |          = ddd           dS # 1 swxY w Y   dS )z
        Removes the specified listener from the listeners list.  This relies
        on object identity (i.e. the ``is`` operator).
        N)r   r   KeyErrorr   r   s     r   _remove_listenerzNotifierMixin._remove_listener[   s    
 ?"Fh 	. 	.8-	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	. 	.s   AAAc                     | j         dS d| }| j                                         D ]F} |            }|t          ||          r't          ||          }t	          |          r ||i | GdS )aA  
        Notify all listeners of some particular state change by calling their
        ``_update_<notification>`` method with the given ``*args`` and
        ``**kwargs``.

        The notification does not by default include the object that actually
        changed (``self``), but it certainly may if required.
        N_update_)r   	valuerefshasattrgetattrcallable)r   notificationargskwargsmethod_namer   methods          r   _notifyzNotifierMixin._notifyf   s     ?"F///1133 
	, 
	,H  xzzHx-- , ;77F## ,FD+F+++
	, 
	,r   c                     	 t                                                      }n)# t          $ r | j                                        }Y nw xY wd|d<   |S )zj
        Exclude listeners when saving the listener's state, since they may be
        ephemeral.
        Nr   )super__getstate__AttributeError__dict__copy)r   state	__class__s     r   r.   zNotifierMixin.__getstate__   sb    	)GG((**EE 	) 	) 	)M&&((EEE	) #ls    $ #A
	A
)
__name__
__module____qualname____doc__r   r   r   r+   r.   __classcell__)r3   s   @r   r   r   !   sw        ) )V J
1 
1 
1	. 	. 	., , ,2        r   r   c                 :    t          t          |                     S )z
    Returns the first item returned by iterating over an iterable object.

    Examples
    --------
    >>> a = [1, 2, 3]
    >>> first(a)
    1
    )nextiter)iterables    r   firstr=      s     Xr   c              #   T  K   |t                      }	 |                                 }n%# t          $ r |                     |           }Y nw xY wt          |t	          j        d                    D ]6}||vr0|                    |           |V  t          ||          D ]}|V  7dS )a  
    Generator over all subclasses of a given class, in depth first order.

    >>> class A: pass
    >>> class B(A): pass
    >>> class C(A): pass
    >>> class D(B,C): pass
    >>> class E(D): pass
    >>>
    >>> for cls in itersubclasses(A):
    ...     print(cls.__name__)
    B
    D
    E
    C
    >>> # get ALL classes currently defined
    >>> [cls.__name__ for cls in itersubclasses(object)]
    [...'tuple', ...'type', ...]

    From http://code.activestate.com/recipes/576949/
    Nr4   )key)set__subclasses__	TypeErrorsortedoperator
attrgetteradditersubclasses)cls_seensubssubs       r   rG   rG      s      , }'!!## ' ' '!!#&&'d 3J ? ?@@@  eIIcNNNIII%c511  				 s   ) A
Ac                 <     t                      fd            }|S )z
    This decorator registers a custom SIGINT handler to catch and ignore SIGINT
    until the wrapped function is completed.
    c                  r   t          j                    }t          j                    dk    o
|j        dk    } G fdd          } |            }|rt	          j        t          j        |          }	  | i | |rY| t	          j        t          j        |           n)t	          j        t          j        t          j                   |j        r	t          d S d S # |rY| t	          j        t          j        |           n)t	          j        t          j        t          j                   |j        rt          w xY w)N   
MainThreadc                        e Zd Zd Z fdZdS )5ignore_sigint.<locals>.wrapped.<locals>.SigintHandlerc                     d| _         d S )NF)sigint_received)r   s    r   __init__z>ignore_sigint.<locals>.wrapped.<locals>.SigintHandler.__init__   s    ',$$$r   c                 \    t          j        dj         dt                     d| _        d S )Nz KeyboardInterrupt ignored until z is complete!T)warningswarnr4   r	   rS   )r   signumframefuncs      r   __call__z>ignore_sigint.<locals>.wrapped.<locals>.SigintHandler.__call__   s:    St}SSS&   (,$$$r   N)r4   r5   r6   rT   r[   )rZ   s   r   SigintHandlerrQ      s=        - - -, , , , , , ,r   r\   )		threadingcurrent_threadactive_countnamesignalSIGINTSIG_DFLrS   KeyboardInterrupt)r'   r(   curr_threadsingle_threadr\   sigint_handlerold_handlerrZ   s          r   wrappedzignore_sigint.<locals>.wrapped   sh     .00"$$)Nk.>,.N 			, 		, 		, 		, 		, 		, 		, 		, 		, 		, '  	G -~FFK
	,D$!&!!! ,*M&-====M&-@@@!1 ,++, ,, ,  ,*M&-====M&-@@@!1 ,++++++s   2C AD6r   )rZ   ri   s   ` r   ignore_sigintrj      s6     4[[$, $, $, $, [$,L Nr      )   
   )pairwisec                 Z    t          j        |           \  }}|D ]} t          ||          S )zuReturn the items of an iterable paired with its next item.

        Ex: s -> (s0,s1), (s1,s2), (s2,s3), ....
        )	itertoolsteezip)r<   r   r   _s       r   rn   rn      s9    
 }X&&1 	 	A 1ayyr   c                    t          | t                    r|                     d          S t          | t          j                  rt          | j        j        t          j                  rt          j	                            | d          
                    t          |                     }|j        j        | j        j        dz  k    r.|                    t          j        | j        j        dz  f          }|S t          | t          j                  r3t          | j        j        t          j                  st          d          | S )Nascii   $string operation on non-string array)
isinstancestrencodenpndarray
issubclassdtypetypestr_charviewitemsizeastypebytes_rB   )snss     r   encode_asciir     s    !S @xx   	Arz	"	" @z!','H'H @W^^Aw'',,T!WW558 01 444BIqw'7!';<==B		Arz	"	" @:aglBI+N+N @>???Hr   c                    t          | t                    rm	 |                     d          S # t          $ rJ t	          j        dt                     |                     dd          } |                     dd          cY S w xY wt          | t          j	                  rt          | j        j        t          j                  r| j        dk    rW| j        j                            dd	          }t          j        g |
                              t          |                     }n@t          j                            | d                              t          |                     }|j        j        dz  | j        j        k    r+|                    t          j        | j        j        f          }|S t          | t          j	                  r3t          | j        j        t          j                  st-          d          | S )Nru   zanon-ASCII characters are present in the FITS file header and have been replaced by "?" charactersreplace)errorsu   �?r   SUr~   rv   rw   )rx   bytesdecodeUnicodeDecodeErrorrV   rW   r	   r   r{   r|   r}   r~   r   r   sizery   arrayr   r   r   r   r   rB   )r   dtr   s      r   decode_asciir     s   !U @		,88G$$$! 	, 	, 	,MG"  
 33A99Xs+++++	, 
Arz	"	" @z!',	'J'J @
 6Q;; $$S#..B"B''',,T!WW55BB7++00a99B8q AG$444BGQW%5677B		Arz	"	" @:aglBG+L+L @ >???Hs   , AB ?B c                     t           d          r                                 S t           d          r j        rt          d          t           d          sdS t           d          rt	           fddD                       sdS d	S )
z
    Returns True if the file-like object can be read from.  This is a common-
    sense approximation of io.IOBase.readable.
    readableclosedI/O operation on closed filereadFmodec              3   *   K   | ]}|j         v V  d S r   r   .0cfs     r   	<genexpr>zisreadable.<locals>.<genexpr>C  s)      %@%@aa16k%@%@%@%@%@%@r   zr+T)r#   r   r   
ValueErroranyr   s   `r   
isreadabler   4  s    
 q* zz||q( 9 978881f uq& #%@%@%@%@4%@%@%@"@"@ u 4r   c                     t           d          r                                 S t           d          r j        rt          d          t           d          sdS t           d          rt	           fddD                       sdS d	S )
z
    Returns True if the file-like object can be written to.  This is a common-
    sense approximation of io.IOBase.writable.
    writabler   r   writeFr   c              3   *   K   | ]}|j         v V  d S r   r   r   s     r   r   ziswritable.<locals>.<genexpr>Z  s)      %A%Aaa16k%A%A%A%A%A%Ar   zwa+T)r#   r   r   r   r   r   s   `r   
iswritabler   K  s    
 q* zz||q( 9 978881g uq& #%A%A%A%A5%A%A%A"A"A u 4r   c                     t          | t          j                  rdS t          | d          rt	          | j                  S t          | d          rt	          | j                  S dS )z
    Returns True if the given object represents an OS-level file (that is,
    ``isinstance(f, file)``).

    On Python 3 this also returns True if the given object is higher level
    wrapper on top of a FileIO object, such as a TextIOWrapper.
    TbufferrawF)rx   ioFileIOr#   isfiler   r   r   s    r   r   r   b  sd     !RY t	H		 ah	E		 ae}}5r   c                 v   t          | t          t          f          r| S t          | t          j                  rt          | j                  S t          | d          r| j        S t          | d          r| j	        S t          | d          rt          | j
                  S t          t          |                     S )z
    Returns the 'name' of file-like object *f*, if it has anything that could be
    called its name.  Otherwise f's class or type is returned.  If f is a
    string f itself is returned.
    r`   filenamer3   )rx   ry   r   gzipGzipFilefileobj_namefileobjr#   r`   r   r3   r   r   s    r   r   r   s  s     !c5\"" 	At}	%	%  AI&&&	F		 v	J		 z	K	 	  1;477||r   c                 &   t          | t                    rdS t          | d          r| j        S t          | d          r!t          | j        d          r| j        j        S t          | d          r!t          | j        d          r| j        j        S dS )a  
    Returns True if the given file-like object is closed or if *f* is a string
    (and assumed to be a pathname).

    Returns False for all other types of objects, under the assumption that
    they are file-like objects with no sense of a 'closed' state.
    Tr   r   fpF)rx   	path_liker#   r   r   r   r   s    r   fileobj_closedr     s     !Y tq( x	I		 719h#?#? y	D		 gadH55 t{ur   c                 ,   t          | d          rt          | j        d          r| j        }nYt          | d          r| j        S t          | d          rt          | j        d          r| j        }nt          | d          r| }ndS t	          |          S )zm
    Returns the 'mode' string of a file-like object if such a thing exists.
    Otherwise returns None.
    r   r   fileobj_moder   N)r#   r   r   r   _fileobj_normalize_mode)r   r   s     r   r   r     s     q) F!;!; ) 
N	#	# ~ 
D		 	gadF33 	$ 
F		  t"7+++r   c                     | j         }t          | t          j                  r&|t          j        k    rdS |t          j        k    rdS dS d|v r|                    dd          }|dz  }|S )zTakes care of some corner cases in Python where the mode string
    is either oddly formatted or does not truly represent the file mode.
    rbwbN+ )r   rx   r   r   READWRITEr   r   r   s     r   r   r     sv     6D !T]## 494TZ44 d{{||C$$Kr   c                     t          | d          r| j        S t          | t          j                  rdS t          |           }|rd|v S dS )z
    Returns True if the give file or file-like object has a file open in binary
    mode.  When in doubt, returns True by default.
    binaryFr   T)r#   r   rx   r   
TextIOBaser   r   s     r   fileobj_is_binaryr     sX     q( x!R]## u??D d{tr   c                     |r+|                                 }|D ]}d |t          |          <   |                     |          S r   )r1   ord	translate)r   tabledeletecharsr   s       r   r   r     sI     !

 	! 	!A E#a&&MM;;ur   c                     |                      d          }fdd                    fd|D                       S )z
    Like :func:`textwrap.wrap` but preserves existing paragraphs which
    :func:`textwrap.wrap` does not otherwise handle well.  Also handles section
    headers.
    z

c                     t          fd|                                 D                       r| S t          j        | fi S )Nc              3   >   K   | ]}t          |          k     V  d S r   )len)r   linewidths     r   r   z+fill.<locals>.maybe_fill.<locals>.<genexpr>  s.      <<Ts4yy5 <<<<<<r   )all
splitlinestextwrapfill)tr(   r   s    r   
maybe_fillzfill.<locals>.maybe_fill   sO    <<<<Q\\^^<<<<< 	5H=E44V444r   c              3   .   K   | ]} |          V  d S r   r   )r   pr   s     r   r   zfill.<locals>.<genexpr>  s+      99zz!}}999999r   )splitjoin)textr   r(   
paragraphsr   s    `` @r   r   r     s_     F##J5 5 5 5 5 5 ;;9999j999999r   c                    t          |           rt          Lt          j        dk    r:t	          t          j                    d                   t	          d          k     rdandat          rt          d|j        z            }||k     rt          j	        | ||          S t          j
        ||	          }t          d||          D ]4}t          |||z             }t          j	        | |||z
            |||<   5|S t          j	        | ||          S t          j        |          j        |z  }|                     |          }t          j        |||f
          }|                                }|S )z7Create a numpy array from a file or a file-like object.Ndarwinr   z10.9TFi   @)r~   countr   )r   r~   shape)r   CHUNKED_FROMFILEsysplatformr   mac_verintr   r{   fromfileemptyrangeminr~   r   r|   r1   )	infiler~   r   
chunk_sizer   begend	read_sizer   s	            r   _array_from_filer     s   f~~  #|x''GH4D4F4Fq4I,J,JWN N - - $(  #(  	AWu~566Jz!!{6eDDDDe444 E:66 W WCeS:%566C%'[uCRUI%V%V%VE#c'NN;vU%@@@@
 HUOO,u4	KK	""
!5AAA 

r   l    ic                 T   	 |                                 }n# t          $ r d}Y nw xY wt          |          r|rd }nt          }t          j        dk    r1| j        t          dz   k    r| j        dz  dk    rt          | j        z  }n;t          j        	                    d          rt          | j        z  }n || |          S d}|                     t          j                                                  } || j        k     r) || |||z            |           ||z  }|| j        k     'dS dS )	a  
    Write a numpy array to a file or a file-like object.

    Parameters
    ----------
    arr : ndarray
        The Numpy array to write.
    outfile : file-like
        A file-like object such as a Python file object, an `io.BytesIO`, or
        anything else with a ``write`` method.  The file object must support
        the buffer interface in its ``write``.

    If writing directly to an on-disk file this delegates directly to
    `ndarray.tofile`.  Otherwise a slower Python implementation is used.
    Fc                 ,    |                      |          S r   )tofile)r   r   s     r   r   z _array_to_file.<locals>.<lambda>P  s    QXXa[[ r   r   rN   i   r   winN)seekabler/   r   _array_to_file_liker   r   nbytes_OSX_WRITE_LIMITr   
startswith_WIN_WRITE_LIMITr   r{   r|   flatten)arroutfiler   r   	chunksizeidxs         r   _array_to_filer  :  sZ    ##%%    g $8 $((# 	  J*Q...J"" %4				 	 	'	' #$4		 uS'""" C
((2:


&
&
(
(C



c#i'('222y 






s    &&c                    t          |           dk    rdS | j        j        r-	 |                    | j                   dS # t
          $ r Y nw xY wt          t          d          rBt          j        | d          D ])}|                    |	                                           *dS | j
        j        }t          j        dk    r|dk    st          j        dk    rK|d	k    rE| j        D ];}|                    |                                	                                           <dS | j        D ])}|                    |	                                           *dS )
zp
    Write a `~numpy.ndarray` to a file-like object (which is not supported by
    `numpy.ndarray.tofile`).
    r   NnditerC)orderlittle>big<)r   flags
contiguousr   r   rB   r#   r{   r  tobytesr~   	byteorderr   flatbyteswap)r  r   itemr  s       r   r   r   t  sx    3xx1}}
y 	MM#(### F  	 	 	D	
 r8 .Ic--- 	* 	*DMM$,,..))))	* 	* I'	MX%%)s*:*:MU""yC'7'7 9 9dmmoo557788889 9  . .dllnn----. .s   ? 
AAc                     t          |           }|r%t          |t                    rt          |          }n&|s$t          | t                    st	          |          }|                     |           dS )z
    Write a string to a file, encoding to ASCII if the file is open in binary
    mode, or decoding if the file is open in text mode.
    N)r   rx   ry   r   r   r   )r   r   binmodes      r   _write_stringr    sn      ""G :a%% OO Z3// OOGGAJJJJJr   c                     | j         |k    r| S | j         j        |j        k    rXt          j        | j         t          j                  rt          j        |t          j                  s|                     |          S |                     |          S )z
    Converts an array to a new dtype--if the itemsize of the new dtype is
    the same as the old dtype and both types are not numeric, a view is
    returned.  Otherwise a new array must be created.
    )r~   r   r{   
issubdtypenumberr   r   )r   r~   s     r   _convert_arrayr    s|     {e			/	/
ek29-- 
024-ry2Q2Q 
0
 zz%   ||E"""r   c                 l    | j         dk    r| j        dk    rdS | j         dk    sJ d| j        dz  dz
  z  S )zg
    Given a numpy dtype, finds its "zero" point, which is exactly in the
    middle of its range.
    irN   iu   kindr   r   s    r   _pseudo_zeror"    sL     zSU^q00t:!#a'((r   c                 Z    | j         dk    r| j        dk    p| j         dk    o
| j        dk    S )Nr  rk   r  rN   r   r   s    r   _is_pseudo_integerr$    s8    J#5%.A"5 
c1en1r   c                 ,    t          | t                    S r   )rx   all_integer_types)vals    r   _is_intr(    s    c,---r   c                 f    	 t          |           }n# t          $ r t          |           }Y nw xY w|S )zAConverts a given string to either an int or a float if necessary.)r   r   float)r'  nums     r   _str_to_numr,    sE    #hh   Cjj Js    ..c                    g }t          |           }t          j        |                     d          dz   d          }t          j        |dk              d         }d}d}	 	 t          j        |||z   k              d         d         }n# t
          $ r t          |          }Y nw xY w|dk    r||dz
           dz   }nd}||k    rt          ||z   |          }|                    | ||                    ||k    rn|}|S )	z
    Split a long string into parts where each part is no longer than ``strlen``
    and no word is cut into two pieces.  But if there are any single words
    which are longer than ``strlen``, then they will be split in the middle of
    the word.
    utf8    S1r   r   TrN   )r   r{   
frombufferrz   nonzero
IndexErrorr   append)	r   r   wordsslenr  	blank_locoffsetxoffsetlocs	            r   _words_groupr<    s6    Eq66D -((4/t
<
<
<C 
3$;''*IFG	!*Y%&.899!<Q?CC 	! 	! 	!i..CCC	! 77sQw'!+FFF W5$//F 	Qwv~&'''T>>'* Ls   "'B
 
B&%B&c                     | t           j                            |           } t          j        |           \  }}t          j        |           |S )z
    Create a temporary file name which should not already exist.  Use the
    directory of the input file as the base name of the mkstemp() output.
    N)dir)ospathdirnametempfilemkstempclose)inputr   fns      r   	_tmp_namerG    sF    
 &&'''EArHQKKKIr   c                    t          | t          j                  r| S | }t          |d          rM|j        Ht          |j        t          j                  r|j        S |j        }t          |d          r|j        DdS dS dS dS )zu
    If the array has an mmap.mmap at base of its base chain, return the mmap
    object; otherwise return None.
    baseN)rx   mmapr#   rI  )r   rI  s     r   _get_array_mmaprK    s    
 %## D
$

 DI$9di++ 	9y $

 DI$9$9$9  $9$9  r   c              #     K   	 d V  d S # t           $ r}d}t          | t                    s| g} |)t          j                            | j        j                  }t          j                            |          rIt          j
        |          }t          d | D                       }||k     rd                    ||          }| D ]}|                                 t          |t          |          z             d }~ww xY w)Nr   c              3   $   K   | ]}|j         V  d S r   )r   )r   hdus     r   r   z$_free_space_check.<locals>.<genexpr>4  s$      ;;Csx;;;;;;r   z6Not enough space on disk: requested {}, available {}. )OSErrorrx   listr?  r@  rA  _filer`   isdirr   get_free_space_in_dirsumformat_closery   )hdulistrA  excerror_message
free_spacehdulist_sizerN  s          r   _free_space_checkr\  (  s     0 0 0 0'4(( 	 iG?googm&899G7==!! 	3G<<J;;7;;;;;LL((LSS$j    	 	CJJLLLLmc#hh.///'0s   
 
C>C%C99C>c                 n    	 t          t          |                     S # t          t          f$ r |cY S w xY w)z
    Attempts to extract an integer number from the given value. If the
    extraction fails, the value of the 'default' argument is returned.
    )r   r,  rB   r   )valuedefaults     r   _extract_numberr`  B  sH    
 ;u%%&&&z"   s    44c                 2    t          j        d|  d          S )a8  
    Return a string representing the path to the file requested from the
    io.fits test data set.

    .. versionadded:: 2.0.3

    Parameters
    ----------
    filename : str
        The filename of the test data file.

    Returns
    -------
    filepath : str
        The path to the requested file.
    zio/fits/tests/data/astropy)r   get_pkg_data_filename)r   s    r   get_testdata_filepathrd  O  s     " %&FH&F&F	RRRr   c                    | j         }|j        dvrt          d          |j        dk    rdnd}d|j        |z   d|j         d| }|                     |t          j                  }t          j                    }|j	        d	k    r&	 d
|j
        d
         f|_
        n# t          $ r Y nw xY wt          d|j
        d         |          D ]}||||z            }t          j        |j
        dd
         t                    }t          d
|j
        d
          d
          D ].}	||d|	f         dk    z  }d|d|	f         |<   |d|	f         dk    }/| S )z
    Performs an in-place rstrip operation on string arrays. This is necessary
    since the built-in `np.char.rstrip` in Numpy does not perform an in-place
    calculation.
    SUz/This function can only be used on string arraysr   rN   rv   (z,)r  rk   r1  r   Nr   .    )r~   r!  rB   r   r  r   r{   r|   
getbufsizendimr   r/   r   onesbool)
r   r   bpcdt_intr   bufsizejr   maskr  s
             r   _rstrip_inplacerr  c  s    
B	wdIJJJ w#~~!!1C;#;;r|;;c;;F

62:&&AmooG 	vzz	!'"+oAGG 	 	 	D	1agaj'** " "a!g+owqwss|4000 rAGBK<,, 	" 	"AAc1fIO#DAc1fIdOS!V9>DD	"
 Ls   B 
B('B(c                 v    t          | d          sdS 	 ddlm} t          | |          S # t          $ r Y dS w xY w)zCheck whether data is a dask array.

    We avoid importing dask unless it is likely it is a dask array,
    so that non-dask code is not slowed down.
    computeFr   )Array)r#   
dask.arrayru  rx   ImportError)r   ru  s     r   _is_dask_arrayrx    sj     4## u'$$$$$$ $&&&     uus   * 
88r   )Ir   r   rp   rJ  rD   r?  r   ra   r   rB  r   r]   rV   r   
contextlibr   r   	functoolsr   numpyr{   packaging.versionr   astropy.utilsr   astropy.utils.exceptionsr	   ry   r   PathLiker   cmpr   integerr&  r   r=   rG   rj   version_inforn   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r   r  r  r"  r$  r(  r,  r<  rG  rK  r\  r`  rd  rr  rx  r   r   r   <module>r     s    				       				   



         / / / / / / / /           % % % % % %       7 7 7 7 7 7%%	$$"*% m m m m m m m m`
  
  
 ! ! ! !H- - -` BQB7"""""""""
 
 

 
 
! ! !H  .  .  "  6  *, , ,@  2  (  : : :,  " " "J   7 7 7t'. '. '.T  "# # #$
) 
) 
)  . . .  ( ( (V	 	 	   0 0 0 02
 
 
S S S(. . .b' ' ' ' 'r   