Ñò
PÇKc           @   s  d  Z  g  Z d d k Z e i d ƒ d d k Z d d k Z d d k Z d d k Z d „  Z d „  Z	 d „  Z
 d „  Z d d k Z d „  Z d	 „  Z d
 „  Z d „  Z d „  Z e i i d „ Z d „  Z e i i d „ Z e d j o e e i ƒ n d S(   sº  
This module converts code written for numpy.oldnumeric to work
with numpy

FIXME:  Flesh this out.

Makes the following changes:
 * Converts typecharacters '1swu' to 'bhHI' respectively
   when used as typecodes
 * Changes import statements
 * Change typecode= to dtype=
 * Eliminates savespace=xxx keyword arguments
 *  Removes it when keyword is not given as well
 * replaces matrixmultiply with dot
 * converts functions that don't give axis= keyword that have changed
 * converts functions that don't give typecode= keyword that have changed
 * converts use of capitalized type-names
 * converts old function names in oldnumeric.linear_algebra,
   oldnumeric.random_array, and oldnumeric.fft

iÿÿÿÿNs0   numpy.oldnumeric.alter_code2 is not working yet.c         C   s^   |  i  d d ƒ }  |  i  d d ƒ }  |  i  d d ƒ }  |  i  d d ƒ }  |  i  d d	 ƒ }  |  S(
   Ns   's's   'h's   'b's   'B's   '1's   'w's   'H's   'u's   'I'(   t   replace(   t   astr(    (    sL   P:\graphics\Tools\Python26\Lib\site-packages\numpy\oldnumeric\alter_code2.pyt   replacetypechars#   s    c         C   s÷   d | } d | } d | } d } |  i  | d | ƒ }  |  i  | d | | f ƒ }  d } t | ƒ } t d | ƒ }	 xr |  i | | ƒ }
 |
 d j  o Pn |
 | } |  | d j o q{ n d |  |
  | |  | f }  | |	 | 7} q{ |  | f S(   Ns	   import %ss   import %s as s   from %s import i    s   import %s as %st   *s   %sfrom %s import %s(   R    t   lent   find(   t   fstrt   namet   newnamet	   importstrt   importasstrt   fromstrt   fromallt   indt   Nlent   Nlen2t   found(    (    sL   P:\graphics\Tools\Python26\Lib\site-packages\numpy\oldnumeric\alter_code2.pyt   changeimports+   s&    



c         C   s   |  i  d d ƒ }  |  S(   Nt   matrixmultiplyt   dot(   R    (   R   (    (    sL   P:\graphics\Tools\Python26\Lib\site-packages\numpy\oldnumeric\alter_code2.pyt   replaceattrB   s    c         C   s=   t  i d d |  ƒ }  |  i d d ƒ }  |  i d d ƒ }  |  S(   Ns   typecode\s*=s   dtype=t	   ArrayTypet   ndarrayt   NewAxist   newaxis(   t   ret   subR    (   R   (    (    sL   P:\graphics\Tools\Python26\Lib\site-packages\numpy\oldnumeric\alter_code2.pyt   replaceotherF   s    c         C   sP  t  |  d d ƒ \ }  } t  |  d d ƒ \ }  } t  |  d d ƒ \ }  } t  |  d d ƒ \ }  } t  |  d d ƒ \ }  } t  |  d	 d
 ƒ \ }  } t  |  d d ƒ \ }  } t  |  d d ƒ \ }  } t  |  d d ƒ \ }  } | p t p | } t |  ƒ }  t |  ƒ }  t i i ƒ  i d ƒ } t i	 i
 t i d ƒ d } d | | |  f }  |  S(   Ns   numpy.oldnumerict   numpys   numpy.core.multiarrays   numpy.core.umatht   LinearAlgebras   numpy.linalg.oldt   RNGs   numpy.random.oldrngs   RNG.Statisticss   numpy.random.oldrngstatst   RandomArrays   numpy.random.oldrandomarrayt   FFTs   numpy.fft.oldt   MAs   numpy.core.mas	   %b %d, %Yi    iÿÿÿÿs/   ## Automatically adapted for numpy %s by %s

%s(   R   t   fromall2R   R   t   datetimet   datet   todayt   strftimet   ost   patht   splitt   syst   argv(   t   filestrt   fromall1t   fromall3R   R%   R   (    (    sL   P:\graphics\Tools\Python26\Lib\site-packages\numpy\oldnumeric\alter_code2.pyR   M   s$    	c         C   s*   t  |  d ƒ } | i | ƒ | i ƒ  d  S(   Nt   w(   t   filet   writet   close(   R   R,   t   fid(    (    sL   P:\graphics\Tools\Python26\Lib\site-packages\numpy\oldnumeric\alter_code2.pyt   makenewfileb   s    c         C   sO   t  |  ƒ } | i ƒ  } | i ƒ  t i i |  ƒ \ } } t | d | ƒ | S(   Ns   .orig(   R0   t   readR2   R'   R(   t   splitextR4   (   R   R3   R,   t   baset   ext(    (    sL   P:\graphics\Tools\Python26\Lib\site-packages\numpy\oldnumeric\alter_code2.pyt
   getandcopyg   s    
c         C   s)   t  |  ƒ } t | ƒ } t |  | ƒ d S(   sŸ   Convert the filename given from using Numeric to using NumPy

    Copies the file to filename.orig and then over-writes the file
    with the updated code
    N(   R9   R   R4   (   t   filenameR,   (    (    sL   P:\graphics\Tools\Python26\Lib\site-packages\numpy\oldnumeric\alter_code2.pyt   convertfileo   s    c         C   s   |  d } t  | ƒ d  S(   Ni   (   R;   (   t   argsR:   (    (    sL   P:\graphics\Tools\Python26\Lib\site-packages\numpy\oldnumeric\alter_code2.pyt   fromargsy   s    
c         C   s=   t  i  t i i |  d ƒ ƒ } x | D] } t | ƒ q% Wd S(   sò   Convert all .py files to use NumPy (from Numeric) in the directory given

    For each file, a backup of <usesnumeric>.py is made as
    <usesnumeric>.py.orig.  A new file named <usesnumeric>.py
    is then written with the updated code.
    s   *.pyN(   t   globR'   R(   t   joinR;   (   t   direct   filest   afile(    (    sL   P:\graphics\Tools\Python26\Lib\site-packages\numpy\oldnumeric\alter_code2.pyt
   convertall}   s     c         C   s   t  | ƒ d  S(   N(   RC   (   t   argt   dirnamet   fnames(    (    sL   P:\graphics\Tools\Python26\Lib\site-packages\numpy\oldnumeric\alter_code2.pyt   _funcˆ   s    c         C   s   t  i i |  t d ƒ d S(   s-   Convert all .py files in the tree given

    N(   R'   R(   t   walkRG   t   None(   R@   (    (    sL   P:\graphics\Tools\Python26\Lib\site-packages\numpy\oldnumeric\alter_code2.pyt   converttree‹   s    t   __main__(   t   __doc__t   __all__t   warningst   warnR*   R'   R   R>   R   R   R   R   R#   R   R4   R9   R;   R=   R(   t   curdirRC   RG   RJ   t   __name__R+   (    (    (    sL   P:\graphics\Tools\Python26\Lib\site-packages\numpy\oldnumeric\alter_code2.pyt   <module>   s,   								
		