L i(dddlZddlmZddlmZmZmZddgZgdZ dZ d Z Gd d Z d d Z y)N)array_namespace) _output_len_apply mode_enumupfirdnr) constantwrapedgesmooth symmetricreflect antisymmetric antireflectlinect|t| |zz}tj||j}||dt||j d|j dddddfj }|S)aStore coefficients in a transposed, flipped arrangement. For example, suppose upRate is 3, and the input number of coefficients is 10, represented as h[0], ..., h[9]. Then the internal buffer will look like this:: h[9], h[6], h[3], h[0], // flipped phase 0 coefs 0, h[7], h[4], h[1], // flipped phase 1 coefs (zero-padded) 0, h[8], h[5], h[2], // flipped phase 2 coefs (zero-padded) N)lennpzerosdtypereshapeTravel)huph_padlenh_fulls [/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/scipy/signal/_upfirdn.py_pad_hr /sp1v#a&2&H XXh (FF7CFO ^^B # % %a2g . 4 4 6F Mc<|j}t|}|S)N)lowerr)modeenums r _check_moder&Cs ::= 1)rasarrayndimsize ValueError result_typerfloat32 _output_typeint_up_downr _h_trans_flipascontiguousarrayr _h_len_orig)selfrx_dtyperdowns r__init__z_UpFIRDn.__init__Ls JJqM 66Q;!&&A+AB BNN177GRZZH JJq$++ ,r7Y 88a<4::><= =#Atxx011$2D2DEq6r!c t|j|j||j|j}t j |jt j}|||<t j||jd}||jz}t|}tt j ||j|j||j|j||||S)z@Apply the prepared filter to the specified axis of N-D signal x.)rC)rorder)rr6shaper2r3rr*int64rr0r+r&rr4)r7xaxisr$cval output_len output_shapeouts r apply_filterz_UpFIRDn.apply_filter[s !1!11774=!%4::7 zz!'': ' Thh|4+<+>> import numpy as np >>> from scipy.signal import upfirdn >>> upfirdn([1, 1, 1], [1, 1, 1]) # FIR filter array([ 1., 2., 3., 2., 1.]) >>> upfirdn([1], [1, 2, 3], 3) # upsampling with zeros insertion array([ 1., 0., 0., 2., 0., 0., 3.]) >>> upfirdn([1, 1, 1], [1, 2, 3], 3) # upsampling with sample-and-hold array([ 1., 1., 1., 2., 2., 2., 3., 3., 3.]) >>> upfirdn([.5, 1, .5], [1, 1, 1], 2) # linear interpolation array([ 0.5, 1. , 1. , 1. , 1. , 1. , 0.5]) >>> upfirdn([1], np.arange(10), 1, 3) # decimation by 3 array([ 0., 3., 6., 9.]) >>> upfirdn([.5, 1, .5], np.arange(10), 2, 3) # linear interp, rate 2/3 array([ 0. , 1. , 2.5, 4. , 5.5, 7. , 8.5]) Apply a single filter to multiple signals: >>> x = np.reshape(np.arange(8), (4, 2)) >>> x array([[0, 1], [2, 3], [4, 5], [6, 7]]) Apply along the last dimension of ``x``: >>> h = [1, 1] >>> upfirdn(h, x, 2) array([[ 0., 0., 1., 1.], [ 2., 2., 3., 3.], [ 4., 4., 5., 5.], [ 6., 6., 7., 7.]]) Apply along the 0th dimension of ``x``: >>> upfirdn(h, x, 2, axis=0) array([[ 0., 1.], [ 0., 1.], [ 2., 3.], [ 2., 3.], [ 4., 5.], [ 4., 5.], [ 6., 7.], [ 6., 7.]]) )rrr*r(rrF) rr@rr9rAr$rBxpufds rrrlsRT A B 1 A 1aggr4 (C ::c&&q$d; <rTs@D1:: m $ (  Fo=r!