
    bMh9                        d dl mZ d dlZd dlmZmZmZmZ d dl	Z	ej
        ej        ej        ej        ej        ej        gZej        ej        ej        ej        ej        ej        gZ	 eej        gz  Zeej        gz  Zn# e$ r Y nw xY wd Zd Zd Zd Zd Zd	 Zd
 Zd Zd Zd Zd Zd Zd Z d Z!d Z"d Z#d Z$d Z%d Z&d Z'd Z(d Z)d Z*d Z+d Z,d Z-d Z.dS )    )combinationsN)assert_assert_allcloseassert_equalassert_raisesc                      t          j        g dd           i } t          t          t           j        | d           t          t          t           j        dd           d S )N)            haarr
   )pywtdwtnr   	TypeError
ValueError)datas    X/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/pywt/tests/test_multidim.pytest_dwtn_inputr      sO    IlllF###D)TYf555*diF33333    c            	      0   t          j        g dg dg dg dgg dg dg dg dgg          } t          j        d	          }t          j        j        D ]A}t          j        | ||
          }t          | t          j        |||
          dd           Bd S )Nr   r   r	      r	   r   r   r      r   r
   r	   r      r
   !   r   	   r
   r      r   r    r	   r	   r   r	   r
   r   r            4   r#   r   r
   r$   r   r&   r%   r   r   r
   r%   N   r$   r
   r   modevIh%<=rtolatol)	nparrayr   WaveletModesmodesr   r   idwtn)r   waveletr+   ds       r   test_3D_reconstructr8   %   s    8													 
												  ! !D l6""G
  0 0IdG$///djG$???"	0 	0 	0 	0 	00 0r   c            	         t           j                            d          } |                     dd          }t	          j                    }d|v r|                    d           |D ]}|dv rt          t	          j        |          t          j	                  rSt          j
        j        D ]A}t	          j        |||          }t          t	          j        |||          |dd           Bd S )N     dmey)cmorshanfbspr*   Hz>r-   )r0   randomRandomStaterandnr   wavelistremove
isinstanceDiscreteContinuousWaveletr2   r3   r4   r   r   r5   )rstaterrD   r6   r+   coeffss         r   test_dwdtn_idwtn_allwaveletsrK   7   s    Y""4((FRA}H 9 9...d4W==t|LL 	9
( 9 91gD999
67 F F F !49 9 9 9 99 9r   c            	         t          j        d          } dD ]}t          j        g dg dg dg|          }t           j        j        D ]}t          j        ||           }t          j        d|j                  }||d d dd d d	f<   t          j        |d d dd d d	f         |           }|D ]}t          ||         ||                    d S )
Nr   float32float64r   r   r   r%   r   r
   r	   r   dtype)r   r$   r
   )
r   r2   r0   r1   r3   r4   r   onesrR   r   )r6   rR   r   r+   expectedstridedstrided_dwtnkeys           r   test_striderY   I   s!   l6""G' B Bx++++++---/ $% % %
 J$ 	B 	BDyw//HggTZ888G!%GDDbD##A#I9WTTrT33Q3Y%7AAL B BS 18C=AAAAB	BB Br   c            
         t          j        d          } dD ]}t          j        g dg dg dg|          }t           j        j        D ]}t          j        ||           }t          j        dt          j        |j        dfd	|j        j	        fd
d                    }||d d <   t          j        |d         |           }|D ]}t          ||         ||                    d S )Nr   rM   r   rP   r   rQ   )r   r%   r   byte)r   padT)alignr   )r   r2   r0   r1   r3   r4   r   rT   rR   itemsizer   )r6   rR   r   r+   rU   paddedpadded_dwtnrX   s           r   test_byte_offsetra   [   sD   l6""G' A Ax++++++---/ $% % %
 J$ 	A 	ADyw//HWV28dj!_=CTZEX<Y5[ 5[:>,@ ,@ ,@ A A AF F111I)F6NG<<K A AC 0(3-@@@@A	AA Ar   c                  R   t          j        g dg dg dg dgg dg dg dg dgg          } | d	z   } t          j        d
          }t          j        | |          }t          d | j        D                       }t          | t          j        ||          |         dd           d S )Nr   r   r   r   r!   r"   r'   r(                 ?r   c                 .    g | ]}t          d |          S )N)slice).0ss     r   
<listcomp>z/test_3D_reconstruct_complex.<locals>.<listcomp>~   s     ???qE$NN???r   r,   r-   )	r0   r1   r   r2   r   tupleshaper   r5   )r   r6   r7   original_shapes       r   test_3D_reconstruct_complexrl   n   s    8													 
												  ! !D "9Dl6""G	$  A??DJ???@@ND$*Q00@U, , , , , ,r   c            	      Z   t          j        g dg dg dg          } t          j        d          }t          j        | |          \  }\  }}}||||d}t          j        j        D ]D}t          t          j        ||||ff||          t          j	        |||          dd           Ed S )	Nr   rP   r   r   aadaadddr*   +=r-   
r0   r1   r   r2   dwt2r3   r4   r   idwt2r5   r   r6   LLHLLHHHr7   r+   s           r   test_idwtn_idwt2r|      s    8  D
 l6""Gyw//BR2R00A
  0 0
BR#5wTJJJ
1gD999"	0 	0 	0 	0 	00 0r   c            	      d   t          j        g dg dg dg          } | dz   } t          j        d          }t          j        | |          \  }\  }}}||||d}t          j        j        D ]D}t          t          j        ||||ff||          t          j	        |||          dd	           Ed S )
Nr   rP   r   rc   r   rn   r*   rs   r-   rt   rw   s           r   test_idwtn_idwt2_complexr~      s    8  D "9Dl6""Gyw//BR2R00A
  0 0
BR#5wTJJJ
1gD999"	0 	0 	0 	0 	00 0r   c            
      ~   t          j        g dg dg dg          } t          j        d          }t          j        | |          }t          dt          |                    D ]}t          |                                |          D ]}|	                                }|D ]}||= |
                    dd           }|
                    dd           }|
                    dd           }	|
                    d	d           }
t          t          j        |||	|
ff|          t          j        |d          d
           d S )Nr   rP   r   r   r	   ro   rp   rq   rr   gV瞯<r/   )r0   r1   r   r2   r   rangelenr   keyscopygetr   rv   r5   )r   r6   coefsnum_missingmissingmissing_coefsrX   rx   ry   rz   r{   s              r   test_idwtn_missingr      ss   8  D
 l6""GIdG$$E QE

++ K K#EJJLL+>> 
	K 
	KG!JJLLM ' '!#&&""4..B""4..B""4..B""4..BDJRRL'97CC J}f==EK K K K K
	KK Kr   c                  V    d d d d d} t          t          t          j        | d           d S )Nrn   r   )r   r   r   r5   )r   s    r   test_idwtn_all_coeffs_Noner      s/    t4t<<E*dj%88888r   c                  B   t          j        g dg dg dg          } t          j        d          }t          j        | |          \  }\  }}}|||||d}t          t          t          j        ||           ||||d}t          t          t          j        ||           d S )Nr   rP   r   r   )ro   rp   rq   rr   ff)arp   rq   rr   r0   r1   r   r2   ru   r   r   r5   r   r6   rx   ry   rz   r{   r7   s          r   test_error_on_invalid_keysr      s    8  D
 l6""Gyw//BR 2Rr::A*dj!W555 "B//A*dj!W55555r   c                  D   t          j        g dg dg dg          } t          j        d          }t          j        | |          \  }\  }}}|d d d df         }|d d d df         }|d d d df         }||||d}t          t          t          j        ||           d S )Nr   rP   r   r   rS   rn   r   r   s          r   test_error_mismatched_sizer      s    8  D
 l6""Gyw//BR 
AAAssFB	AAAssFB	AAAssFB2R00A*dj!W55555r   c                     t          j        d          } t          t          t                    D ]\  }}t          j        d|          }d| d}t          j        ||           \  }\  }}}t          |j	        |j	        cxk    o|j	        cxk    o
|j	        k    nc d|z              t          j
        ||||ff|           }	t          |	j	        |k    d|z              d S )Nr   r   r   rQ   wrong dtype returned for  inputzdwt2: zidwt2: )r   r2   zip	dtypes_in
dtypes_outr0   rT   ru   r   rR   rv   )
r6   dt_indt_outxerrmsgcAcHcVcDx_roundtrips
             r   test_dwt2_idwt2_dtypesr      s   l6""GY
33 	A 	AvGF%(((:U:::9Q00LRRBH<<<<<<<<BH<<<<6!	# 	# 	# j"r2rl!3W==!V+Y-?@@@@	A 	Ar   c                     t          j        g dg dg dg          } | d| z  z   } t          j        | dd          }d | D             }t	          |d	         |           d
 | D             }t	          |d         |           t          j        | dd          }d |D             }t	          |d         |           d |D             }t	          |d         |           d S )Nr   r	   r
   r   r	   r	   r	   r	   r	   r   r
   r   rc   r   )r	   axesc                 D    g | ]}t          j        |d           d         S r   r   r   dwtrf   r   s     r   rh   z"test_dwtn_axes.<locals>.<listcomp>  )    777Q$(1f%%a(777r   r   c                 D    g | ]}t          j        |d           d         S r   r	   r   r   s     r   rh   z"test_dwtn_axes.<locals>.<listcomp>  r   r   r7   r	   r	   c                 D    g | ]}t          j        |d           d         S r   r   r   s     r   rh   z"test_dwtn_axes.<locals>.<listcomp>  )    >>>a48Av&&q)>>>r   ro   c                 D    g | ]}t          j        |d           d         S r   r   r   s     r   rh   z"test_dwtn_axes.<locals>.<listcomp>	  r   r   rq   )r0   r1   r   r   r   )r   r   
expected_a
expected_dexpected_aaexpected_ads         r   test_dwtn_axesr      s	   8\\\!\\!\\# $ $D "T'>DIdF...E77$777JsZ(((77$777JsZ(((IdF000E>>:>>>Ktk***>>:>>>Ktk*****r   c                      t          j        g dg dg dg          } | d| z  z   } t          j        | dd          }t	          t          j        |dd          | d	           d S )
Nr   r   r   rc   r   r   r   rs   r   )r0   r1   r   r   r   r5   r   r   s     r   test_idwtn_axesr     s}    8\\\!\\!\\# $ $D "T'>DIdF000EDJuf6:::DuMMMMMMr   c                  H   t          j        g dg dg dg          } | d| z  z   } t          j        | dd          \  }\  }}}t          j        |          }t          j        ||||ffdd          }d }t          j        ||||ffdd          }t          ||           d S )Nr   r   r   rc   r   r   r   )r0   r1   r   ru   
zeros_likerv   r   )r   r   r   r   r   result_zerosresult_nones          r   test_idwt2_none_coeffsr     s    8\\\!\\!\\# $ $D "T'>DyvF;;;BR 
r		B:rBB<0&vFFFL	B*b2r2,/fEEEK{+++++r   c                  >   t          j        g dg dg dg          } | d| z  z   } t          j        | dd          }t          j        |d                   |d<   t          j        |dd          }d |d<   t          j        |dd          }t          ||           d S )	Nr   r   r   rc   r   r   r   rr   )r0   r1   r   r   r   r5   r   )r   r   r   r   s       r   test_idwtn_none_coeffsr   '  s    8\\\!\\!\\# $ $D "T'>DIdF000E -d,,E$K:eV&999LE$K*UF888K{+++++r   c                     t          j        g dg dg dg          } t          j        | dd          }t	          t          j        |dd          | d           t          t          t          j        |dd	           d S )
Nr   r   r   r   r   r   rs   r   r   r	   r	   )r0   r1   r   ru   r   rv   r   r   r   s     r   test_idwt2_axesr   8  s    8\\\!\\!\\# $ $D IdF000EDJuf6:::DuMMMM *dj%iHHHHHHr   c                  
   t          j        t           j                            d                    } t	          dd          D ]@}t          j        | d|          }t          t          j        |d|          | d           Ad S )N)r   r   r   )r   r	   r
   r
   r   r   rs   r   )	r0   r1   rA   standard_normalr   r   ru   r   rv   r   r   r   s      r   test_idwt2_axes_subsetsr   C  s    8BI--i8899DY** P P	$T222
5&t<<<dOOOOOP Pr   c                  
   t          j        t           j                            d                    } t	          dd          D ]@}t          j        | d|          }t          t          j        |d|          | d           Ad S )N)r   r   r   r   r   r   r   r   rs   r   )	r0   r1   rA   r   r   r   r   r   r5   r   s      r   test_idwtn_axes_subsetsr   K  s    8BI--l;;<<D\1-- P P	$T222
5&t<<<dOOOOOP Pr   c                  8   t          j        g dg dg dg          } t          j        | dd          }t          j        | dd          }t	          ||           t          j        |dd          }t          j        |dd          }t	          ||           d S )Nr   r   r   r   r   r   )rS   rS   )r0   r1   r   r   r   r5   )r   coefs1coefs2rec1rec2s        r   test_negative_axesr   S  s    8\\\!\\!\\# $ $D YtV&111FYtV(333F   :ff6222D:ff8444Dtr   c                     t          j        d          } t          t          t                    D ]\  }}t          j        d|          }d| d}t          j        ||           }|                                D ]!\  }}t          |j
        |k    d|z              "t          j        ||           }t          |j
        |k    d|z              d S )Nr   r   rQ   r   r   zdwtn: zidwtn: )r   r2   r   r   r   r0   rT   r   itemsr   rR   r5   )	r6   r   r   r   r   rJ   kvr   s	            r   test_dwtn_idwtn_dtypesr   `  s    l6""GY
33 	A 	AvGF%(((:U:::1g&&LLNN 	: 	:DAqAGv%x&'89999j11!V+Y-?@@@@	A 	Ar   c                     t           j                            d          } |                     ddd          }|d|z  z   }t	          j        |d          }t	          j        |d          }t          ||d           |d|j        z           	                    t           j
                  |d|j        z  <   t	          j        |d          }t          ||dd	           t          |j        t           j        k               d S )
Nr   r   rc   db2g|=)r.   r   r@   r-   )r0   rA   rB   rC   r   r   r5   r   ndimastype	complex64r   rR   
complex128)rH   r   rJ   r   x_roundtrip2s        r   test_idwtn_mixed_complex_dtyper   n  s    Y""1%%FQ1A	BqDAYq%  F*VU++KK//// "#,/66r|DDF3<:fe,,LL!$T::::L"-/00000r   c                      t          j        d          } t          j        d          x}x}}t          t          t          j        | |||ffd           d S )N)r%   r%   )r   r   r   r6   )r0   zerosr   r   r   rv   )rx   rz   ry   r{   s       r   test_idwt2_size_mismatch_errorr   ~  sT    	&		B8F###B#b*dj2B|*<fMMMMMMr   c                     t          j        d          } t          j        d          }t	          t
          t          j        | |           t          j        d          }t	          t
          t          j        ||d           d S )Nr;   r   )r   r   r   r   )r0   rT   r   r2   r   r   ru   )r   r6   data2s      r   test_dwt2_dimension_errorr     sf    72;;Dl6""G *diw777 GFOOE*diiHHHHHHr   c            	         t           j                            d          } |                     ddd          }t	          j        d          ddf}ddt          j        j        j        j	        f}t	          j
        |||          }t          t	          j        |||          |d	           t	          j
        ||d d
         |          }t          t	          j        ||d d
         |          |d	           t	          j
        |||d d
                   }t          t	          j        |||d d
                   |d	           t          t          t          j
        ||d d                    t          t          t          j
        |||d d                    t          t          t          j        ||d d                    t          t          t          j        |||d d                    |d         }t	          j        ||d d         |d d                   }t          t	          j        ||d d         |d d                   |d	           d S )Nr:   r;   r   sym2db4	symmetricperiodizationrs   r   r	   r
   r*   ).r   )r0   rA   rB   rC   r   r2   _extensions_pywtr3   reflectr   r   r5   r   r   ru   rv   )rH   r   waveletsr4   r   r   r   s          r    test_per_axis_wavelets_and_modesr     s   Y""4((F<<B##D V$$fe4H /#)13E IdHe,,EDJuh665IIIIIdHRaRL%00EDJuhrrlE::DuMMMMIdHeBQBi00EDJuhbqb	::DuMMMM *dix|<<<*dixeBQBiHHHH*dj%"1">>>*dj%bqb	JJJJ LEYuhrrlE"1"I66FDJvx|U2A2Y??           r   c                  \   t          j        d          } t          t          j        t          j        gt          j        t          j        g          D ]Z\  }}dt          j        d          fD ]>}t          t          || |            || d          }t          t          |||           ?[d S )N)r;   r;   morlr   db1)r0   rT   r   r   ru   r   rv   r5   rG   r   r   )r   dec_funrec_funcwavecs        r    test_error_on_continuous_waveletr     s    78DDI 6!%TZ 8: : A Ad<VDDE 	A 	AE*gtUCCCCe$$A*gq%@@@@@		AA Ar   )/	itertoolsr   numpyr0   numpy.testingr   r   r   r   r   int8float16rN   rO   r   r   r   r   
complex256AttributeErrorr   r8   rK   rY   ra   rl   r|   r~   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r   r   <module>r     s   # " " " " "     O O O O O O O O O O O O 
 Wbj"*bj",]	j"*bj"*blm
	"-""I2=##JJ 	 	 	D	4 4 40 0 0$9 9 9$B B B$A A A&, , ,*0 0 0"0 0 0"K K K49 9 9
6 6 6&6 6 6,A A A+ + +$N N N, , ,", , ,"I I IP P PP P P
 
 
A A A1 1 1 N N N	I 	I 	I     D	A 	A 	A 	A 	As   (A? ?BB