@@ -1673,12 +1673,12 @@ impl Periodogram {
16731673 ) ) ;
16741674 }
16751675 let step_candidate = freqs_f64[ 1 ] - freqs_f64[ 0 ] ;
1676- // Check if representable as a linear grid
1677- let freq_grid_f64 = if freqs_f64. iter ( ) . tuple_windows ( ) . all ( |( x1, x2) | {
1676+ let is_linear = freqs_f64. iter ( ) . tuple_windows ( ) . all ( |( x1, x2) | {
16781677 let dx = x2 - x1;
16791678 let rel_diff = f64:: abs ( dx / step_candidate - 1.0 ) ;
16801679 rel_diff < STEP_SIZE_TOLLERANCE
1681- } ) {
1680+ } ) ;
1681+ let freq_grid_f64 = if is_linear {
16821682 if first_zero && len_is_pow2_p1 {
16831683 let log2_size_m1 = ( size - 1 ) . ilog2 ( ) ;
16841684 FreqGrid :: zero_based_pow2 ( step_candidate, log2_size_m1)
@@ -1726,6 +1726,23 @@ impl Periodogram {
17261726 Ok ( ( eval_f32, eval_f64) )
17271727 }
17281728
1729+ fn power_impl < ' py , T > (
1730+ eval : & lcf:: Periodogram < T , lcf:: Feature < T > > ,
1731+ py : Python < ' py > ,
1732+ t : Arr < T > ,
1733+ m : Arr < T > ,
1734+ ) -> Res < Bound < ' py , PyUntypedArray > >
1735+ where
1736+ T : Float + numpy:: Element ,
1737+ {
1738+ let t: DataSample < _ > = t. as_array ( ) . into ( ) ;
1739+ let m: DataSample < _ > = m. as_array ( ) . into ( ) ;
1740+ let mut ts = TimeSeries :: new_without_weight ( t, m) ;
1741+ let power = eval. power ( & mut ts) . map_err ( lcf:: EvaluatorError :: from) ?;
1742+ let power = PyArray1 :: from_vec ( py, power) ;
1743+ Ok ( power. as_untyped ( ) . clone ( ) )
1744+ }
1745+
17291746 fn freq_power_impl < ' py , T > (
17301747 eval : & lcf:: Periodogram < T , lcf:: Feature < T > > ,
17311748 py : Python < ' py > ,
@@ -1798,6 +1815,24 @@ impl Periodogram {
17981815 ) )
17991816 }
18001817
1818+ /// Periodogram values
1819+ #[ pyo3( signature = ( t, m, * , cast=false ) ) ]
1820+ fn power < ' py > (
1821+ & self ,
1822+ py : Python < ' py > ,
1823+ t : Bound < PyAny > ,
1824+ m : Bound < PyAny > ,
1825+ cast : bool ,
1826+ ) -> Res < Bound < ' py , PyUntypedArray > > {
1827+ dtype_dispatch ! (
1828+ |t, m| Self :: power_impl( & self . eval_f32, py, t, m) ,
1829+ |t, m| Self :: power_impl( & self . eval_f64, py, t, m) ,
1830+ t,
1831+ =m;
1832+ cast=cast
1833+ )
1834+ }
1835+
18011836 /// Angular frequencies and periodogram values
18021837 #[ pyo3( signature = ( t, m, * , cast=false ) ) ]
18031838 fn freq_power < ' py > (
0 commit comments