Skip to content

Conversation

@duffee
Copy link

@duffee duffee commented Oct 8, 2025

Changing or-assignment to defined-assignment so that acf(0) and acvf(0) return a single value as expected, not all values which is the default behaviour when no argument is given. plot_acf was not affected by the bug, but there's no current test for it.

The definition of acf is that it is the normalization of acvf using the value of the acvf with no lag.
This commit makes it behave as described in docs for TS.pm

Tests pass locally with this output

$ prove -Ilocal/lib/perl5 -b t/
t/00-report-prereqs.t .. # 
# Versions for all modules listed in MYMETA.json (including optional ones):
# 
# === Configure Requires ===
# 
#     Module  Want  Have Where                                                    Howbig
#     ------ ----- ----- -------------------------------------------------------- ------
#     PDL    2.099 2.100 /tmp/PDL-Stats/local/lib/perl5/x86_64-linux-thread-multi   6835
# 
# === Build Requires ===
# 
#     Module  Want  Have Where                                                    Howbig
#     ------ ----- ----- -------------------------------------------------------- ------
#     PDL    2.099 2.100 /tmp/PDL-Stats/local/lib/perl5/x86_64-linux-thread-multi   6835
# 
# === Test Requires ===
# 
#     Module     Want     Have Where                                                    Howbig
#     ---------- ---- -------- -------------------------------------------------------- ------
#     Test::More 0.88 1.302195 /usr/share/perl5/vendor_perl                              54209
#     Test::PDL  0.21     0.22 /tmp/PDL-Stats/local/lib/perl5/x86_64-linux-thread-multi  14754
# 
# === Runtime Requires ===
# 
#     Module  Want  Have Where                                                    Howbig
#     ------ ----- ----- -------------------------------------------------------- ------
#     PDL    2.099 2.100 /tmp/PDL-Stats/local/lib/perl5/x86_64-linux-thread-multi   6835
# 
# === Runtime Recommends ===
# 
#     Module                Want    Have Where                       Howbig
#     --------------------- ---- ------- --------------------------- ------
#     PDL::GSL               any missing                                  0
#     PDL::Graphics::Simple  any   1.015 /usr/local/share/perl5/5.38  49691
# 
t/00-report-prereqs.t .. ok   
t/basic.t .............. ok    
t/glm.t ................ ok     
t/kmeans.t ............. ok    
t/ts.t ................. ok    
All tests successful.
Files=5, Tests=337,  3 wallclock secs ( 0.05 usr  0.00 sys +  2.27 cusr  0.06 csys =  2.38 CPU)
Result: PASS

when new tests run with previous version of PDL::Stats::TS, it fails with

t/ts.t ................. 1/? PDL::Ops::divide(a,b,c): parameter 'b': Mismatched implicit broadcast dimension 0: size 6 vs. 10
There are 3 PDLs in the expression; 1 broadcast dim.
   PDL IN EXPR.    BROADCAST DIMS
   #  0 (normal):        6
   #  1 (normal):       10
   #  2 (null)
 at lib/PDL/PP.pm line 1445.
	PDL::__ANON__(PDL=SCALAR(0x55c2e72d2580), PDL=SCALAR(0x55c2e72d2988), "") called at t/ts.t line 15
# Tests were run but no plan was declared and done_testing() was not seen.
# Looks like your test exited with 255 just after 5.

Changing or-assignment to defined-assignment so that acf(0)
and acvf(0) return a single value as expected, not all values
which is the default behaviour when no argument is given.
@duffee duffee changed the title Fix acf and acvf default handling Fix acf and acvf default handling in PDL::Stats::TS Oct 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant