Descriptive/Smoother.pm

filter: Statementstmt 100% 34 / 34 Branchbran 100% 8 / 8 Conditioncond 87.5% 7 / 8 MC/DCmcdc 80.0% 4 / 5 Subroutinesub 100% 6 / 6 Podpod 100% 3 / 3 totaltotal 96.8% 62 / 64 CC 8 SCAR 13.3
CC
8
Cov
98%
instantiate
6.0
set_smoothing_coeff
3.0
BEGIN
1.0
CRAP 3.8
« Descriptive/Full.pm ↑ Summary Descriptive/Smoother/Weightedexponential.pm »
1 package Statistics::Descriptive::Smoother;
2 17 $Statistics::Descriptive::Smoother::VERSION = '3.0801';
3 17 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 17 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 17 ▶use Carp qw/ carp /;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 ## no critic (ProhibitExplicitReturnUndef)
9  
10 sub instantiate
11 16 ▶{
Subroutine instantiate: called CC=6 SCAR=17.9
Pod documented
12 16 my ( $class, $args ) = @_;
13  
14 16 my $method = delete $args->{method};
15 16 ▶ my $coeff = delete $args->{coeff} || 0;
Condition100%2/2
delete $args->{'coeff'} || 0
l!l
88
MC/DC100%1/1
delete $args->{'coeff'} || 0
delete $args->{'coeff'}
Truth table100%2/2
A
A= delete $args->{'coeff'}
Aresult
11
00
16 16 my $ra_samples = delete $args->{samples};
17 16 my $ra_data = delete $args->{data};
18  
19 16 ▶ if ( $coeff < 0 || $coeff > 1 )
Branch: 1 branch
BranchTrueFalseTotal
if ($coeff < 0 or $coeff > 1) 2 14 16
Condition100%3/3
$coeff < 0 or $coeff > 1
l!l&&r!l&&!r
1114
MC/DC100%2/2
$coeff < 0 or $coeff > 1
$coeff < 0 $coeff > 1
Truth table100%3/3
A or B
A= $coeff < 0B= $coeff > 1
ABresult
1X1
011
000
20 {
21 2 carp("Invalid smoothing coefficient C $coeff\n");
22 2 return;
23 }
24 14 ▶ if ( @$ra_data < 2 )
Branch: 1 branch
BranchTrueFalseTotal
if (@$ra_data < 2) 1 13 14
25 {
26 1 carp("Need at least 2 samples to smooth the data\n");
27 1 return;
28 }
29 13 $method = ucfirst( lc($method) );
30 13 my $sub_class = __PACKAGE__ . "::$method";
31 ## no critic
32 13 eval "require $sub_class";
33 ## use critic
34 13 ▶ die "No such class $sub_class: $@" if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 1 12 13
35  
36 12 return $sub_class->_new(
37 {
38 data => $ra_data,
39 samples => $ra_samples,
40 count => scalar @$ra_data,
41 coeff => $coeff,
42 }
43 );
44 }
45  
46 145 ▶sub get_smoothing_coeff { $_[0]->{coeff} }
Subroutine get_smoothing_coeff: called CC=1 SCAR=0.0
Pod documented
47  
48 sub set_smoothing_coeff
49 2 ▶{
Subroutine set_smoothing_coeff: called CC=3 SCAR=11.0
Pod documented
50 2 my ( $self, $coeff ) = @_;
51  
52 2 ▶ if ( $coeff < 0 || $coeff > 1 )
Branch: 1 branch
BranchTrueFalseTotal
if ($coeff < 0 or $coeff > 1) 1 1 2
Condition66%2/3
$coeff < 0 or $coeff > 1
l!l&&r!l&&!r
011
MC/DC50%1/2
$coeff < 0 or $coeff > 1
$coeff < 0 $coeff > 1
Truth table66%2/3
A or B
A= $coeff < 0B= $coeff > 1
ABresult
1X1
011
000
53 {
54 1 carp("Invalid smoothing coefficient C $coeff\n");
55 1 return;
56 }
57  
58 1 $self->{coeff} = $coeff;
59 1 return 1;
60 }
61  
62 17 1;
63  
64 __END__
« Descriptive/Full.pm ↑ Summary Descriptive/Smoother/Weightedexponential.pm »