Current File : //proc/self/root/proc/self/root/lib64/python2.7/site-packages/numpy/oldnumeric/alter_code1.pyo
�
E�`Qc
@s�dZddddgZddlZddlZddlZddlZddgZd	gZd
ddd
ddddddg
Zidd6dd6dd6dd6Z	iZ
iZx1eD])ZdeZ
eje
ej�e
e<q�Wx1eD])ZdeZ
eje
ej�e
e<q�Wx1eD])ZdeZ
eje
ej�e
e<qWx7e	j�D])ZdeZ
eje
ej�ee<qXWd �Zejd!�Zd"�ZiZd#d$d%d&d'd(d)gZx+eD]#Zd*eZ
eje
�ee<q�Wd+�Zd,�Zejd-�Zejd.�Zd/�ZddlZd0�Zd1�Zd2d3�Zd4�Z ej!j"d2d5�Z#ejd6�Z$ej!j"dd2d7�Z&d8�Z'ej!j"d9�Z(e)d:kr�e ej*�ndS(;s�
This module converts code written for Numeric to run with numpy

Makes the following changes:
 * Changes import statements (warns of use of from Numeric import *)
 * Changes import statements (using numerix) ...
 * Makes search and replace changes to:
   - .typecode()
   - .iscontiguous()
   - .byteswapped()
   - .itemsize()
   - .toscalar()
 * Converts .flat to .ravel() except for .flat = xxx or .flat[xxx]
 * Replace xxx.spacesaver() with True
 * Convert xx.savespace(?) to pass + ## xx.savespace(?)

 * Converts uses of 'b' to 'B' in the typecode-position of
   functions:
   eye, tri (in position 4)
   ones, zeros, identity, empty, array, asarray, arange,
   fromstring, indices, array_constructor (in position 2)

   and methods:
   astype --- only argument
    -- converts uses of '1', 's', 'w', and 'u' to
    -- 'b', 'h', 'H', and 'I'

 * Converts uses of type(...) is <type>
   isinstance(..., <type>)
tconvertfilet
convertalltconverttreet
convertsrci����Nteyettritastypetonestzerostidentityt
fromstringtindicestemptytarraytasarraytarangetarray_constructortbt1thtstHtwtItus.(%s\s*[(][^,]*?[,][^'"]*?['"])b(['"][^)]*?[)])s@(%s\s*[(][^,]*?[,][^,]*?[,][^,]*?[,][^'"]*?['"])b(['"][^)]*?[)])s&(.%s\s*[(][^'"]*?['"])b(['"][^)]*?[)])s+(.astype\s*[(][^'"]*?['"])%s(['"][^)]*?[)])cCshx,tttD]}t|jd|�}qWx2tj�D]$}t|jdt||�}q<W|S(Ns\1B\2s\1%s\2(t_func2t_func4t_meth1tfunc_retsubt_charstkeystmeth_re(tfstrtnametchar((sB/usr/lib64/python2.7/site-packages/numpy/oldnumeric/alter_code1.pytfixtypecharsAs
"s([.]flat(\s*?[[=]))cCsd|}d|}d|}d}tjd|d||f|�}|j|d|�}|j|d||f�}d}t|�}td|�}	xn|j||�}
|
dkr�Pn|
|}||dkr�q�nd	||
 |||f}||	|7}q�||fS(
Ns	import %ss
import %s as sfrom %s import is(import\s+[^,\n\r]+,\s*)(%s)s
\1%s as %ssimport %s as %st*s%sfrom %s import %s(treRtreplacetlentfind(R!R"tnewnamet	importstrtimportasstrtfromstrtfromalltindtNlentNlen2tfound((sB/usr/lib64/python2.7/site-packages/numpy/oldnumeric/alter_code1.pyt
changeimportsJs*




tfloattinttcomplext	ArrayTypet	FloatTypetIntTypetComplexTypes*type\s*[(]([^)]*)[)]\s+(?:is|==)\s+(.*?%s)cCs+x$tD]}t|jd|�}qW|S(Nsisinstance(\1, \2)(t_typest	istest_reR(tastrR"((sB/usr/lib64/python2.7/site-packages/numpy/oldnumeric/alter_code1.pytfixistestingis
cCs�|jdd�}|jdd�}|jdd�}|jdd�}|jd	d
�}tjd|�}|jdd
�}|jdd�}|S(Ns.typecode()s.dtype.chars.iscontiguous()s.flags.contiguouss.byteswapped()s.byteswap()s.toscalar()s.item()s.itemsize()s	.itemsizes@@@@\2s.flats.ravel()s@@@@(R'tflatindex_reR(R=ttmpstr((sB/usr/lib64/python2.7/site-packages/numpy/oldnumeric/alter_code1.pytreplaceattrnss([^,(\s]+[.]spacesaver[(][)])s(\S+[.]savespace[(].*[)])cCs(tjd|�}tjd|�}|S(NtTruespass  ## \1(tsvspc2Rtsvspc3(R=((sB/usr/lib64/python2.7/site-packages/numpy/oldnumeric/alter_code1.pytreplaceotherscCs1|}t|�}t|�}t|dd�\}}t|dd�\}}t|dd�\}}t|dd�\}}t|dd�\}}t|d	d
�\}}t|dd�\}}t|dd�\}}t|d
d�\}}t|dd�\}}t|dd�\}}t|dd�\}}t|dd�\}}t|dd�\}}t|dd�\}}t|dd�\}}|p�|p�|}t|�}t|�}||kr'tjj�jd�}t	j
jtj
d�d}d |||f}|d!fS|dfS("NtNumericsnumpy.oldnumerict
multiarraytumatht	Precisionsnumpy.oldnumeric.precisiont	UserArraysnumpy.oldnumeric.user_arraytArrayPrintersnumpy.oldnumeric.array_printertnumerixt
scipy_basetMatrixsnumpy.oldnumeric.matrixtMLabsnumpy.oldnumeric.mlabt
LinearAlgebrasnumpy.oldnumeric.linear_algebratRNGsnumpy.oldnumeric.rngsRNG.Statisticssnumpy.oldnumeric.rng_statstRandomArraysnumpy.oldnumeric.random_arraytFFTsnumpy.oldnumeric.ffttMAsnumpy.oldnumeric.mas	%b %d, %Yii����s:## Automatically adapted for numpy.oldnumeric %s by %s

%si(R$R>R3RAREtdatetimetdatettodaytstrftimetostpathtsplittsystargv(tfilestrtsavestrtfromall1tfromall2tfromall3R.RWR"((sB/usr/lib64/python2.7/site-packages/numpy/oldnumeric/alter_code1.pyR-�s:
cCs*t|d�}|j|�|j�dS(NR(tfiletwritetclose(R"R^tfid((sB/usr/lib64/python2.7/site-packages/numpy/oldnumeric/alter_code1.pytmakenewfile�s
icCs�t|�}|j�}|j�t|�\}}|r�|rotjj|�\}}tj||d�n
tj|�t	||�ndS(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
    s.origN(
topentreadReR-RYRZtsplitexttrenametremoveRg(tfilenametorigRfR^tchangedtbasetext((sB/usr/lib64/python2.7/site-packages/numpy/oldnumeric/alter_code1.pyR�s

cCs|d}t|�dS(Ni(R(targsRm((sB/usr/lib64/python2.7/site-packages/numpy/oldnumeric/alter_code1.pytfromargs�s
cCsVtjtjj|d��}x1|D])}|ddkrAq%nt||�q%WdS(sConvert all .py files to use numpy.oldnumeric (from Numeric) in the directory given

    For each changed 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*.pyi����ssetup.pyN(tglobRYRZtjoinR(tdirecRntfilestafile((sB/usr/lib64/python2.7/site-packages/numpy/oldnumeric/alter_code1.pyR�s

s(Numeric/arrayobject.h)c
Cs|dkr-tjtjj|d��}n@g}x7|D]/}|jtjtjj|d|���q:Wx�|D]�}t|�}|j�}|j�t	j
d|�\}}|dkrt|r�tjj|�\}	}tj||	d�n
tj
|�t||�qtqtWdS(s�Replace Numeric/arrayobject.h with numpy/oldnumeric.h in all files in the
    directory with extension give by list ext (if ext is None, then all files are
    replaced).R%s*.%ssnumpy/oldnumeric.his.origN(tNoneRtRYRZRutextendRhRiRet	header_retsubnRjRkRlRg(
RvRqRnRwtaextRxRfR!tnRp((sB/usr/lib64/python2.7/site-packages/numpy/oldnumeric/alter_code1.pyR�s !
-


cCs0t|dd�t|dddgdd�dS(NRniRqRtc(RR(targtdirnametfnames((sB/usr/lib64/python2.7/site-packages/numpy/oldnumeric/alter_code1.pyt_func�scCstjj|td�dS(sBConvert all .py files and source code files in the tree given
    N(RYRZtwalkR�Ry(Rv((sB/usr/lib64/python2.7/site-packages/numpy/oldnumeric/alter_code1.pyR�st__main__(+t__doc__t__all__R\RYR&RtRRRRRR R"t_astrtcompiletDOTALLRR#R$R?R3R<R;R>RARCRDRERUR-RgRRsRZtcurdirRR{RyRR�Rt__name__R](((sB/usr/lib64/python2.7/site-packages/numpy/oldnumeric/alter_code1.pyt<module>sd	"