
    !Цi|                         S SK r S SKJr  S SKrSSKJr  SSKJr  SSK	J
r
JrJr  SSKJr  SSKJr  SS	KJr  SS
KJrJr  SSKJrJrJr  / SQrS r  SS jrSS jr  SS jrSS jr  SS jrSS jr g)    N)product   )_have_c99_complex)idwt_single)ModesWavelet_check_dtype)swt)swt_axis)swt_max_level)idwt2idwtn)	AxisError_as_wavelet_wavelets_per_axis)r
   r   iswtswt2iswt2swtniswtnc           	          [        U R                  S-   U R                   Vs/ s H  n[        R                  " U5      U-  PM     sn5      nU R
                  Ul        U R                  Ul        U$ s  snf )Nr)r   namefilter_banknpasarray
orthogonalbiorthogonal)waveletsffwavs       H/var/www/html/ai-image-ml/venv/lib/python3.13/site-packages/pywt/_swt.py_rescale_wavelet_filterbankr$      sg    
',,$/6/B/BC/B!2::a=2%/BCEC ''CN++CJ Ds   #A0
c                    [         (       d  [        R                  " U 5      (       a  [        R                  " U 5      n XUXTUS.n[	        U R
                  40 UD6n[	        U R                  40 UD6n	U(       d<  / n
[        X5       H)  u  u  pu  pU
R                  USU-  -   USU-  -   45        M+     U
$ [        X5       VVs/ s H  u  nnUSU-  -   PM     n
nnU
$ [        U 5      n[        R                  " U US9n [        U5      nU(       aJ  UR                  (       d  [        R                  " S5        [        US[        R                   " S5      -  5      nUS:  a  X@R"                  -   nSUs=::  a  U R"                  :  d  O  [%        S5      eUc  ['        U R(                  U   5      nU R"                  S:X  a  [+        XX#U5      nU$ [-        XX#XE5      nU$ s  snnf )	a`  
Multilevel 1D stationary wavelet transform.

Parameters
----------
data :
    Input signal
wavelet :
    Wavelet to use (Wavelet object or name)
level : int, optional
    The number of decomposition steps to perform.
start_level : int, optional
    The level at which the decomposition will begin (it allows one to
    skip a given number of transform steps and compute
    coefficients starting from start_level) (default: 0)
axis: int, optional
    Axis over which to compute the SWT. If not given, the
    last axis is used.
trim_approx : bool, optional
    If True, approximation coefficients at the final level are retained.
norm : bool, optional
    If True, transform is normalized so that the energy of the coefficients
    will be equal to the energy of ``data``. In other words,
    ``np.linalg.norm(data.ravel())`` will equal the norm of the
    concatenated transform coefficients when ``trim_approx`` is True.

Returns
-------
coeffs : list
    List of approximation and details coefficients pairs in order
    similar to wavedec function::

        [(cAn, cDn), ..., (cA2, cD2), (cA1, cD1)]

    where n equals input parameter ``level``.

    If ``start_level = m`` is given, then the beginning m steps are
    skipped::

        [(cAm+n, cDm+n), ..., (cAm+1, cDm+1), (cAm, cDm)]

    If ``trim_approx`` is ``True``, then the output list is exactly as in
    ``pywt.wavedec``, where the first coefficient in the list is the
    approximation coefficient at the final level and the rest are the
    detail coefficients::

        [cAn, cDn, ..., cD2, cD1]

Notes
-----
The implementation here follows the "algorithm a-trous" and requires that
the signal length along the transformed axis be a multiple of ``2**level``.
If this is not the case, the user should pad up to an appropriate size
using a function such as ``numpy.pad``.

A primary benefit of this transform in comparison to its decimated
counterpart (``pywt.wavedecn``), is that it is shift-invariant. This comes
at cost of redundancy in the transform (the size of the output coefficients
is larger than the input).

When the following three conditions are true:

    1. The wavelet is orthogonal
    2. ``swt`` is called with ``norm=True``
    3. ``swt`` is called with ``trim_approx=True``

the transform has the following additional properties that may be
desirable in applications:

    1. energy is conserved
    2. variance is partitioned across scales

When used with ``norm=True``, this transform is closely related to the
multiple-overlap DWT (MODWT) as popularized for time-series analysis,
although the underlying implementation is slightly different from the one
published in [1]_. Specifically, the implementation used here requires a
signal that is a multiple of ``2**level`` in length.

References
----------
.. [1] DB Percival and AT Walden. Wavelet Methods for Time Series Analysis.
    Cambridge University Press, 2000.
)r   levelstart_leveltrim_approxaxisnorm              ?dtypezinorm=True, but the wavelet is not orthogonal: 
	The conditions for energy preservation are not satisfied.r      r   !Axis greater than data dimensions)r   r   iscomplexobjr   r
   realimagzipappendr	   arrayr   r   warningswarnr$   sqrtndimr   r   shape_swt	_swt_axis)datar   r&   r'   r)   r(   r*   kwargscoeffs_realcoeffs_imagcoeffs_cplxcA_rcD_rcA_icD_icrcidtrets                      r#   r
   r
      s   l !6!6zz$$[%0N$)).v.$)).v.K.1+.K*lt""D2d7ND2d7N#CD /L
  ,/{+HJ+HxB 2:+H  J 
d	B88D#D'"G!!MMNO .gq|Daxii tyy ;<<}djj./yyA~4%kB J u4MJ9Js   Gc                    [        U S   [        [        45      (       + nU(       a  U S   OU S   S   nUR                  S:  aH  U(       a  U/U SS  Vs/ s H  nSU0PM	     sn-   nOU  VVs/ s H	  u  pXS.PM     nnn[	        XqU4US9$ US:w  a  US:w  a  [        S5      e[        (       d  [        R                  " U5      (       a  U(       a7  U  V	s/ s H  oR                  PM     n
n	U  V	s/ s H  oR                  PM     nn	OXU  VVs/ s H  u  pUR                  UR                  4PM     n
nnU  VVs/ s H  u  pUR                  UR                  4PM     nnnXS	.n[        U
40 UD6nUS
[        U40 UD6-  -   $ U(       a  U SS n UR                  S:w  a  [        S5      e[        U5      n[        R                  " UUSS9n[        U 5      n[!        U5      nU(       a   [#        U[        R$                  " S5      5      n[&        R(                  " S5      n[+        USS5       GHy  n[-        [/        SUS-
  5      5      nUnU(       a  U U*    nO	U U*    u  nn[        R0                  " U[        U5      S9nUR2                  UR2                  :w  a  UR2                  R4                  S:X  d  UR2                  R4                  S:X  a  [        R6                  nO[        R8                  n[        R0                  " UUS9n[        R0                  " UUS9n[+        U5       H~  n[        R:                  " U[        U5      U5      nUSSS2   nUSSS2   n[=        UU   UU   UU5      n[=        UU   UU   UU5      n[        R>                  " US5      nUU-   S-  UU'   M     GM|     U$ s  snf s  snnf s  sn	f s  sn	f s  snnf s  snnf )a  
Multilevel 1D inverse discrete stationary wavelet transform.

Parameters
----------
coeffs : array_like
    Coefficients list of tuples::

        [(cAn, cDn), ..., (cA2, cD2), (cA1, cD1)]

    where cA is approximation, cD is details.  Index 1 corresponds to
    ``start_level`` from ``pywt.swt``.
wavelet : Wavelet object or name string
    Wavelet to use
norm : bool, optional
    Controls the normalization used by the inverse transform. This must
    be set equal to the value that was used by ``pywt.swt`` to preserve the
    energy of a round-trip transform.

Returns
-------
1D array of reconstructed data.

Examples
--------
>>> import pywt
>>> coeffs = pywt.swt([1,2,3,4,5,6,7,8], 'db2', level=2)
>>> pywt.iswt(coeffs, 'db2')
array([ 1.,  2.,  3.,  4.,  5.,  6.,  7.,  8.])
r   r   Nd)arK   axesr*   r/   r   r*   r+   ziswt only supports 1D dataTr-   copyr.   periodizationr,   cg       @) 
isinstancetuplelistr9   r   r   r   r   r0   r1   r2   r   
ValueErrorr	   r5   lenr   r$   r8   r   from_objectrangeintpowr   r-   kind
complex128float64aranger   roll) coeffsr   r*   r)   r(   cArK   	coeffs_ndrL   rT   r?   r@   cacdr>   yrH   output
num_levelsmodej	step_size
last_indexcD_r-   firstindiceseven_indicesodd_indicesx1x2s                                    r#   r   r      sj   B !UDM::K!vay|B	ww{&*=*Qa*==I6<=fdaq)fI=YtgDAA	trz;<<!4!4+126a666K2+126a666K2K<BCF&"BGGRWW-FKC<BCF&"BGGRWW-FKC$3''2[3F3333	ww!|566	b	BXXb.F VJ'"G-grwwqzB_-D:q"%Aqs$	
BA2JEArZZ,r"2388v||#||  C'288==C+?

ZZe4FBe,B:&E iis2w	:G #14a4=L!!$Q$-K VL1-$d,B VK0_$d,B
 QB  "BwlF7O3 '! &V MW  >= 32CCs$   N(,N-N3.N8$N=7$Oc           	      F   [        U5      n[        R                  " U 5      n [        U5      S:w  a  [	        S5      e[        U5      [        [        U5      5      :w  a  [	        S5      eU R                  [        [        R                  " U5      5      :  a  [	        S5      e[        XX#XEU5      n/ nU(       a  UR                  US   5        USS nU HK  n	U(       a  UR                  U	S   U	S	   U	S
   45        M)  UR                  U	S   U	S   U	S	   U	S
   445        MM     U$ )a
  
Multilevel 2D stationary wavelet transform.

Parameters
----------
data : array_like
    2D array with input data
wavelet : Wavelet object or name string, or 2-tuple of wavelets
    Wavelet to use.  This can also be a tuple of wavelets to apply per
    axis in ``axes``.
level : int
    The number of decomposition steps to perform.
start_level : int, optional
    The level at which the decomposition will start (default: 0)
axes : 2-tuple of ints, optional
    Axes over which to compute the SWT. Repeated elements are not allowed.
trim_approx : bool, optional
    If True, approximation coefficients at the final level are retained.
norm : bool, optional
    If True, transform is normalized so that the energy of the coefficients
    will be equal to the energy of ``data``. In other words,
    ``np.linalg.norm(data.ravel())`` will equal the norm of the
    concatenated transform coefficients when ``trim_approx`` is True.

Returns
-------
coeffs : list
    Approximation and details coefficients (for ``start_level = m``).
    If ``trim_approx`` is ``False``, approximation coefficients are
    retained for all levels::

        [
            (cA_m+level,
                (cH_m+level, cV_m+level, cD_m+level)
            ),
            ...,
            (cA_m+1,
                (cH_m+1, cV_m+1, cD_m+1)
            ),
            (cA_m,
                (cH_m, cV_m, cD_m)
            )
        ]

    where cA is approximation, cH is horizontal details, cV is
    vertical details, cD is diagonal details and m is ``start_level``.

    If ``trim_approx`` is ``True``, approximation coefficients are only
    retained at the final level of decomposition. This matches the format
    used by ``pywt.wavedec2``::

        [
            cA_m+level,
            (cH_m+level, cV_m+level, cD_m+level),
            ...,
            (cH_m+1, cV_m+1, cD_m+1),
            (cH_m, cV_m, cD_m),
        ]

Notes
-----
The implementation here follows the "algorithm a-trous" and requires that
the signal length along the transformed axes be a multiple of ``2**level``.
If this is not the case, the user should pad up to an appropriate size
using a function such as ``numpy.pad``.

A primary benefit of this transform in comparison to its decimated
counterpart (``pywt.wavedecn``), is that it is shift-invariant. This comes
at cost of redundancy in the transform (the size of the output coefficients
is larger than the input).

When the following three conditions are true:

    1. The wavelet is orthogonal
    2. ``swt2`` is called with ``norm=True``
    3. ``swt2`` is called with ``trim_approx=True``

the transform has the following additional properties that may be
desirable in applications:

    1. energy is conserved
    2. variance is partitioned across scales

r.   zExpected 2 axesz'The axes passed to swt2 must be unique.z8Input array has fewer dimensions than the specified axesr   r   Ndaadddaa)
rV   r   r   rY   rX   setr9   uniquer   r4   )
r=   r   r&   r'   rN   r(   r*   coefsrI   rT   s
             r#   r   r     s   l ;D::dD
4yA~*++
4yCD	N"BCCyy3ryy''   ! 	! DtLE
C

58ab	JJ$4!D'23JJ$!D'1T7AdG!<=>	 
 J    c                 N   [        U S   [        [        45      (       + nU(       a  U S   OU S   S   nUR                  S:w  d  US:w  aW  U(       a%  U/U SS  VVVs/ s H  u  pgnXgUS.PM     snnn-   n	O!U  V
VVVs/ s H  u  n
u  pgnXXxS.PM     n	nnn
n[	        XX2S9$ [
        (       Gdt  [        R                  " U5      (       GaX  U(       a  UR                  /nXSS  VVVs/ s H(  u  pgoR                  UR                  UR                  4PM*     snnn-  nUR                  /nXSS  VVVs/ s H(  u  pgoR                  UR                  UR                  4PM*     snnn-  nOU  V
VVVs/ s H8  u  n
u  pgnU
R                  UR                  UR                  UR                  44PM:     nnnn
nU  V
VVVs/ s H8  u  n
u  pgnU
R                  UR                  UR                  UR                  44PM:     nnnn
nXS	.n[        U40 UD6nUS
[        U40 UD6-  -   $ U(       a  U SS n [        U5      n[        R                  " X_SS9nUR                  S:w  a  [        S5      e[        U 5      n[        USS9nU(       a0  U Vs/ s H#  n[!        U[        R"                  " S5      5      PM%     nn[%        U5       GH  n['        [)        SUU-
  S-
  5      5      nUnU(       a
  U U   u  nnnOU U   u  nu  nnnUR*                  UR*                  :w  d  UR*                  UR*                  :w  a  [-        S5      e[        R.                  " U/UUU4 Vs/ s H  n[        U5      PM     sn-   6 nUR0                  U:w  a  UR3                  U5      n[%        U5       GH  n[%        U5       GH  n[5        UUR*                  S   U5      n[5        UUR*                  S   U5      n [5        UUR*                  S   SU-  5      n![5        UUR*                  S   SU-  5      n"[5        UU-   UR*                  S   SU-  5      n#[5        UU-   UR*                  S   SU-  5      n$[7        UU!U"4   UU!U"4   UU!U"4   UU!U"4   44US5      n%[7        UU!U$4   UU!U$4   UU!U$4   UU!U$4   44US5      n&[7        UU#U"4   UU#U"4   UU#U"4   UU#U"4   44US5      n'[7        UU#U$4   UU#U$4   UU#U$4   UU#U$4   44US5      n([        R8                  " U&SSS9n&[        R8                  " U'SSS9n'[        R8                  " U(SSS9n([        R8                  " U(SSS9n(U%U&-   U'-   U(-   S-  UUU 4'   GM     GM     GM     U$ s  snnnf s  snnnn
f s  snnnf s  snnnf s  snnnn
f s  snnnn
f s  snf s  snf )a5  
Multilevel 2D inverse discrete stationary wavelet transform.

Parameters
----------
coeffs : list
    Approximation and details coefficients::

        [
            (cA_n,
                (cH_n, cV_n, cD_n)
            ),
            ...,
            (cA_2,
                (cH_2, cV_2, cD_2)
            ),
            (cA_1,
                (cH_1, cV_1, cD_1)
            )
        ]

    where cA is approximation, cH is horizontal details, cV is
    vertical details, cD is diagonal details and n is the number of
    levels.  Index 1 corresponds to ``start_level`` from ``pywt.swt2``.
wavelet : Wavelet object or name string, or 2-tuple of wavelets
    Wavelet to use.  This can also be a 2-tuple of wavelets to apply per
    axis.
norm : bool, optional
    Controls the normalization used by the inverse transform. This must
    be set equal to the value that was used by ``pywt.swt2`` to preserve
    the energy of a round-trip transform.

Returns
-------
2D array of reconstructed data.

Examples
--------
>>> import pywt
>>> coeffs = pywt.swt2([[1,2,3,4],[5,6,7,8],
...                     [9,10,11,12],[13,14,15,16]],
...                    'db1', level=2)
>>> pywt.iswt2(coeffs, 'db1')
array([[  1.,   2.,   3.,   4.],
       [  5.,   6.,   7.,   8.],
       [  9.,  10.,  11.,  12.],
       [ 13.,  14.,  15.,  16.]])

r   r.   rO   r   N)rx   ry   rz   )r{   rx   ry   rz   rM   rP   r+   TrQ   zKiswt2 only supports 2D arrays.  see iswtn for a general n-dimensionsal ISWTr   r   rN   4Mismatch in shape of intermediate coefficient arraysrS   r)      )rU   rV   rW   r9   r   r   r   r0   r1   r2   r   r	   r5   rX   rY   r   r$   r8   r[   r\   r]   r:   RuntimeErrorresult_typer-   astypeslicer   rb   ))rc   r   r*   rN   r(   rd   hvrK   re   rL   r?   r@   r>   rh   rH   ri   rj   waveletsr"   rl   rm   rn   cHcVro   rp   rT   common_dtypefirst_hfirst_w	indices_h	indices_w
even_idx_h
even_idx_w	odd_idx_h	odd_idx_wru   rv   x3x4s)                                            r#   r   r   }  s   h !UDM::K!vay|B	ww!|tx'/5abz ;/9GA! () ;/9 ; ;I .45-3\Q	q !"!=-3  5Yd>>!4!477)K12JOJqVVQVVQVV4JOOK77)K12JOJqVVQVVQVV4JOOK 178069A! FFQVVQVVQVV$<=06  8 178069A! FFQVVQVVQVV$<=06  8$3+((2k4V4444 
b	BXXb.F{{a"# 	# VJ!'7H')' 0RWWQZ@' 	 ) :Az!|A~./	
!!9LRR$QiOA|BHH bhh"((&:FH H
 ~~FB|<|!l1o|<<?<<<']]<0FZ(G ,!'288A;	B	!'288A;	B	"7BHHQK9E
"7BHHQK9E
!'I"5rxx{AiKP	!'I"5rxx{AiKP	 F:z#9:z:56z:56z:5689 $_	6
 F:y#89z945z945z94578 $_	6
 F9j#89y*45y*45y*4578 $_	6
 F9i#78y)34y)34y)3467 $_	6 WWR+WWR+WWR+WWR+02R"r0AQ/Fy)+,M - )' x MG ;5 PO88*)$ =s0   U0
<U7
%/U?
1/V
/?V
:?V
*VV"c                 v  ^  [         R                  " T 5      m [        (       d  [         R                  " T 5      (       a  XUXTUS.n[	        T R
                  40 UD6n[	        T R                  40 UD6n	U(       a  US   SU	S   -  -   /n
SnO/ n
Sn[        XS XS 5       H1  u  pU
R                  U Vs0 s H  oX   SX   -  -   _M     sn5        M3     U
$ T R                  [         R                  " S5      :X  a  [        S5      eT R                  S:  a  [        S5      eUc  [        T R                  5      nU Vs/ s H  oS:  a  UT R                  -   OUPM     nn[        U 4S	 jU 5       5      (       a  [        S
5      e[!        U5      [!        [#        U5      5      :w  a  [        S5      e[!        U5      n[%        X5      nU(       a  [         R&                  " U Vs/ s H  nUR(                  PM     sn5      (       d  [*        R,                  " S5        U Vs/ s H&  n[/        US[         R0                  " S5      -  5      PM(     nn/ n[        X3U-   5       H  nST 4/n[        UU5       HF  u  nn/ nU H6  u  nn[3        UUSUUS9S   u  nnUR5                  US-   U4US-   U4/5        M8     UnMH     [7        U5      nUR                  U5        USU-     m U(       d  M  UR9                  SU-  5        M     U(       a  UR                  T 5        UR;                  5         U$ s  snf s  snf s  snf s  snf )aY  
n-dimensional stationary wavelet transform.

Parameters
----------
data : array_like
    n-dimensional array with input data.
wavelet : Wavelet object or name string, or tuple of wavelets
    Wavelet to use.  This can also be a tuple of wavelets to apply per
    axis in ``axes``.
level : int
    The number of decomposition steps to perform.
start_level : int, optional
    The level at which the decomposition will start (default: 0)
axes : sequence of ints, optional
    Axes over which to compute the SWT. A value of ``None`` (the
    default) selects all axes. Axes may not be repeated.
trim_approx : bool, optional
    If True, approximation coefficients at the final level are retained.
norm : bool, optional
    If True, transform is normalized so that the energy of the coefficients
    will be equal to the energy of ``data``. In other words,
    ``np.linalg.norm(data.ravel())`` will equal the norm of the
    concatenated transform coefficients when ``trim_approx`` is True.

Returns
-------
[{coeffs_level_n}, ..., {coeffs_level_1}]: list of dict
    Results for each level are arranged in a dictionary, where the key
    specifies the transform type on each dimension and value is a
    n-dimensional coefficients array.

    For example, for a 2D case the result at a given level will look
    something like this::

        {'aa': <coeffs>  # A(LL) - approx. on 1st dim, approx. on 2nd dim
         'ad': <coeffs>  # V(LH) - approx. on 1st dim, det. on 2nd dim
         'da': <coeffs>  # H(HL) - det. on 1st dim, approx. on 2nd dim
         'dd': <coeffs>  # D(HH) - det. on 1st dim, det. on 2nd dim
        }

    For user-specified ``axes``, the order of the characters in the
    dictionary keys map to the specified ``axes``.

    If ``trim_approx`` is ``True``, the first element of the list contains
    the array of approximation coefficients from the final level of
    decomposition, while the remaining coefficient dictionaries contain
    only detail coefficients. This matches the behavior of `pywt.wavedecn`.

Notes
-----
The implementation here follows the "algorithm a-trous" and requires that
the signal length along the transformed axes be a multiple of ``2**level``.
If this is not the case, the user should pad up to an appropriate size
using a function such as ``numpy.pad``.

A primary benefit of this transform in comparison to its decimated
counterpart (``pywt.wavedecn``), is that it is shift-invariant. This comes
at cost of redundancy in the transform (the size of the output coefficients
is larger than the input).

When the following three conditions are true:

    1. The wavelet is orthogonal
    2. ``swtn`` is called with ``norm=True``
    3. ``swtn`` is called with ``trim_approx=True``

the transform has the following additional properties that may be
desirable in applications:

    1. energy is conserved
    2. variance is partitioned across scales

)r   r&   r'   r(   rN   r*   r   r+   r   Nobjectz"Input must be a numeric array-likezInput data must be at least 1Dc              3   X   >#    U  H  oS :  =(       d    UTR                   :  v   M!     g7f)r   N)r9   ).0rL   r=   s     r#   	<genexpr>swtn.<locals>.<genexpr>  s#     
1Dqq5"AN"Ds   '*r/   'The axes passed to swtn must be unique.zpnorm=True, but the wavelets used are not orthogonal: 
	The conditions for energy preservation are not satisfied.r.    )r&   r'   r)   rL   rK   )r   r   r   r0   r   r1   r2   r3   r4   r-   	TypeErrorr9   rX   r[   anyr   rY   r|   r   allr   r6   r7   r$   r8   r<   extenddictpopreverse)r=   r   r&   r'   rN   r(   r*   r>   r1   r2   cplxoffsetrdictidictkrL   num_axesr   r"   rI   irc   r)   
new_coeffssubbandxrd   ro   s   `                           r#   r   r     s   X ::dD!6!6$[%0NDII((DII((Gb47l*+DFDFWtG}=LEKK6;<eEHrEH},,e<> > zzRXXh''<==yy1}9::|TYY3784aUA		M)4D8

1D
111;<<
4yCD	N"BCC4yH!'0Hvv:#s~~:;;MMNO  ()' 0Qrwwqz\B' 	 )
C;e 34t* x0MD'J$
"1gQA(,../1B!!GcM2#6$+cM2#6#8 9 %
  F 1 f

6 cHn%;JJsX~&# 5$ 

4KKMJ_ = 9 ;)s   2L'
; L,L1-L6c                 
   [        S U S    5       5      n[        U S   [        5      (       + nU(       a  U S   O
U S   SU-     n[        (       d  [        R
                  " U5      (       a  U(       a&  U S   R                  /nU S   R                  /nU SS n O/ n/ nXp V	V
Vs/ s H1  oR                  5        V
Vs0 s H  u  pXR                  _M     snn
PM3     snn
n	-  nX V	V
Vs/ s H1  oR                  5        V
Vs0 s H  u  pXR                  _M     snn
PM3     snn
n	-  nXUS.n[        U40 UD6nUS[        U40 UD6-  -   $ U(       a  U SS n [        U5      n[        R                  " XnS	S
9nUR                  nUc  [        UR                  5      nU Vs/ s H  nUS:  a  UU-   OUPM     nn[        U5      [        [        U5      5      :w  a  [!        S5      eU[        U5      :w  a  [!        S5      e[        U 5      n[#        X5      nU(       a0  U Vs/ s H#  n[%        U[        R&                  " S5      5      PM%     nn[)        S5      /U-  n[)        S5      /U-  n[)        S5      /U-  n[)        S5      /U-  n[        U5       GH  n[+        [-        SUU-
  S-
  5      5      nUnU(       d  U U   R/                  SU-  5      nU U   n[        R0                  " U/UR3                  5        Vs/ s H  oR4                  PM     sn-   6 nUR4                  U:w  a  UR7                  U5      nUR                  5        V
Vs/ s H  u  pUR8                  PM     nn
n[        [        U5      5      S:w  a  [;        S5      e[=        U Vs/ s H  nUS   U   PM     sn5      n [?        [        U5      /U-  6  GHj  n![A        U!U U5       H@  u  n"n#n[)        U"U#U5      UU'   [)        U"U#SU-  5      UU'   [)        U"U-   U#SU-  5      UU'   MB     URC                  5       n$SU[=        U5      '   Sn%[?        S/U-  6  H  n&[A        U&U5       H  u  n'nU'(       a
  UU   UU'   M  UU   UU'   M!     0 n(UR                  5        H  u  n)n*U*[=        U5         U(U)'   M     U$[=        U5         U(SU-  '   [E        U(USUS9n+[A        U&U5       H%  u  n'nU'(       d  M  [        RF                  " U+SUS9n+M'     U[=        U5      ==   U+-  ss'   U%S-  n%M     U[=        U5      ==   U%-  ss'   GMm     U(       a  GM  WU U   SU-  '   GM     U$ s  snn
f s  snn
n	f s  snn
f s  snn
n	f s  snf s  snf s  snf s  snn
f s  snf )aW  
Multilevel nD inverse discrete stationary wavelet transform.

Parameters
----------
coeffs : list
    [{coeffs_level_n}, ..., {coeffs_level_1}]: list of dict
wavelet : Wavelet object or name string, or tuple of wavelets
    Wavelet to use.  This can also be a tuple of wavelets to apply per
    axis in ``axes``.
axes : sequence of ints, optional
    Axes over which to compute the inverse SWT. Axes may not be repeated.
    The default is ``None``, which means transform all axes
    (``axes = range(data.ndim)``).
norm : bool, optional
    Controls the normalization used by the inverse transform. This must
    be set equal to the value that was used by ``pywt.swtn`` to preserve
    the energy of a round-trip transform.

Returns
-------
nD array of reconstructed data.

Examples
--------
>>> import pywt
>>> coeffs = pywt.swtn([[1,2,3,4],[5,6,7,8],
...                     [9,10,11,12],[13,14,15,16]],
...                    'db1', level=2)
>>> pywt.iswtn(coeffs, 'db1')
array([[  1.,   2.,   3.,   4.],
       [  5.,   6.,   7.,   8.],
       [  9.,  10.,  11.,  12.],
       [ 13.,  14.,  15.,  16.]])

c              3   8   #    U  H  n[        U5      v   M     g 7f)N)rY   )r   keys     r#   r   iswtn.<locals>.<genexpr>  s     8ZcSZs   rO   r   rL   r   N)r   rN   r*   r+   TrQ   r   zYThe number of axes used in iswtn must match the number of dimensions transformed in swtn.r.   r   r   rS   r   r   )$maxrU   r   r   r   r0   r1   r2   itemsr   r	   r5   r9   r[   rY   r|   rX   r   r$   r8   r   r\   r]   r   r   valuesr-   r   r:   r   rV   r   r3   rR   r   rb   ),rc   r   rN   r*   ndim_transformr(   rd   r?   r@   rT   r   r   r>   rh   rH   ri   r9   rL   rj   r   r"   rr   rs   rt   odd_even_slicesrl   rm   rn   detailsr   shapesaxcoeff_trans_shapefirstsrq   shapproxntransformsoddsodetails_slicer   valuer   s,                                               r#   r   r     sY   N 8VBZ88N D11K!vay^1C'DB!4!4!!9>>*K!!9>>*KABZFKK6J6awwy9ytqFFy96JJ6J6awwy9ytqFFy96JJ$DA+((2k4V4444 
b	BXXb.F;;D|V[[!.23dAAH1$dD3
4yCD	N"BCCT" E F 	F VJ!'0H')' 0RWWQZ@' 	 )
 T{od"G$K?4'L;/$&KT{od*O:Az!|A~./	
q	c.01A)~~Fw~~'78'7!gg'788;<<<']]<0F '.mmo6oda!''o6s6{q FH H "4"@4R6!9R=4"@A z!2 5n DFF!$V->!Er2#E2y9#(AiK#@R "'iQy["IB "F [[]F%&F5>"K6*^";= t_EAr.9"o+.:2.>+	 - !#")--/JC).u_/E)FM#& #24:/*5,c.01
 -?N t_EArqGGAqr2 - uW~&!+&q + >, 5>"k1"A GB {,-F1Ic.()q r M} :J9J 4)$ 9
 7 #AsN   "U
:UU
'U
?UU
U!*U&8U+U0U6
U
U
)Nr   rO   FF)FrO   )r   r   FF)Fr   )r   NFF)NF)!r6   	itertoolsr   numpyr   _c99_configr   _extensions._dwtr   _extensions._pywtr   r   r	   _extensions._swtr
   r;   r   r<   r   	_multidimr   r   _utilsr   r   r   __all__r$   r   r   r   r   r    r   r#   <module>r      sy       * ) ; ; ) 3 + # > >
L 8: %}@qh 4<!&jZ\~ FKIXQr   