blib/lib/PDL/PP/Dims.pm

filter: Statementstmt 100% 48 / 48 Branchbran 75.0% 12 / 16 Conditioncond 62.9% 17 / 27 MC/DCmcdc 35.2% 6 / 17 Subroutinesub 100% 18 / 18 Podpod n/a totaltotal 80.1% 101 / 126 CC 18 SCAR 15.5
CC
18
Cov
85%
add_value
9.3
get_indobj_make
8.0
get_initdim
4.0
CRAP 4.7
« blib/lib/PDL/Install/Files.pm ↑ Summary blib/lib/PDL/Ops.pm »
1 ##############################################
2 package # hide from PAUSE/MetaCPAN
3 PDL::PP::PdlDimsObj; # Hold more dims
4 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 4 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 sub new {
9 172 ▶ my($type) = @_;
Subroutine new: called CC=1 SCAR=0.0
10 172 bless {},$type;
11 }
12  
13 sub get_indobj_make {
14 135 ▶ my ($this,$expr,$calc,$orig_inds,$par_name) = @_;
Subroutine get_indobj_make: called CC=7 SCAR=20.8
15 135 ▶ my ($name, $val) = $expr =~ /^([a-zA-Z0-9]+)(?:=([0-9]+))?$/
Branch: 1 branch
BranchTrueFalseTotal
() = $expr =~ /^([a-zA-Z0-9]+)(?:=([0-9]+))?$/ or confess("Invalid index expr in Par '${par_name}' '${expr}' while parsing '${orig_inds}'\n") 0 135 135
16 or confess "Invalid index expr in Par '$par_name' '$expr' while parsing '$orig_inds'\n";
17 135 ▶ confess "Error: both simple value '$val' and CALC '$calc'"
Branch: 1 branch
BranchTrueFalseTotal
if $calc and defined $val 0 135 135
Condition33%1/3
$calc and defined $val
!ll&&!rl&&r
13500
MC/DC0%0/2
$calc and defined $val
$calc defined $val
Truth table33%1/3
A and B
A= $calcB= defined $val
ABresult
0X0
100
111
18 if $calc && defined $val;
19 135 ▶ $val //= $calc;
Condition66%2/3
$val //= $calc
l!l&&r!l&&!r
330102
MC/DC50%1/2
$val //= $calc
$val $calc
Truth table66%2/3
A //= B
A= $valB= $calc
ABresult
1X1
011
000
20 135 ▶ my $indobj = $this->{$name} //= PDL::PP::Ind->new($name);
Condition66%2/3
$this->{$name} //= "PDL::PP::Ind"->new($name)
l!l&&r!l&&!r
40950
MC/DC0%0/2
$this->{$name} //= "PDL::PP::Ind"->new($name)
$this->{$name} "PDL::PP::Ind"->new($name)
Truth table66%2/3
A //= B
A= $this->{$name}B= "PDL::PP::Ind"->new($name)
ABresult
1X1
011
000
21 135 ▶ $indobj->add_value($val) if defined $val;
Branch: 1 branch
BranchTrueFalseTotal
if defined $val 33 102 135
22 135 return $indobj;
23 }
24  
25 72 ▶sub ind_obj {$_[0]{$_[1]}}
Subroutine ind_obj: called CC=1 SCAR=0.0
26 164 ▶sub ind_names {keys %{$_[0]}}
Subroutine ind_names: called CC=1 SCAR=0.0
27 34 ▶sub ind_fromcomp {grep defined $_->{From}, values %{$_[0]}}
Subroutine ind_fromcomp: called CC=1 SCAR=0.0
28 34 ▶sub ind_notfromcomp {grep !defined $_->{From}, values %{$_[0]}}
Subroutine ind_notfromcomp: called CC=1 SCAR=0.0
29  
30 #####################################################################
31 #
32 # Encapsulate one index.
33  
34 package # hide from PAUSE/MetaCPAN
35 PDL::PP::Ind;
36 4 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
37  
38 sub new {
39 95 ▶ my($type,$name) = @_;
Subroutine new: called CC=1 SCAR=0.0
40 95 bless {Name => $name},$type;
41 }
42  
43 # set the value of an index, also used by perl level broadcasting
44 sub add_value {
45 51 ▶ my($this,$val) = @_;
Subroutine add_value: called CC=8 SCAR=22.3
46 51 ▶ croak("index values for $this->{Name} must be positive")
Branch: 1 branch
BranchTrueFalseTotal
if $val =~ /^\d+$/ and $val <= 0 0 51 51
Condition33%1/3
$val =~ /^\d+$/ and $val <= 0
!ll&&!rl&&r
0510
MC/DC0%0/2
$val =~ /^\d+$/ and $val <= 0
$val =~ /^\d+$/ $val <= 0
Truth table33%1/3
A and B
A= $val =~ /^\d+$/B= $val <= 0
ABresult
0X0
100
111
47 if $val =~ /^\d+$/ and $val <= 0;
48 return $this->{Value} = $val if
49 !defined $this->{Value} or
50 $this->{Value} == -1 or
51 51 ▶ $this->{Value} == 1;
Branch: 1 branch
BranchTrueFalseTotal
if not defined $this->{"Value"} or $this->{"Value"} == -1 or $this->{"Value"} == 1 0 5 5
Condition66%4/6
not defined $this->{"Value"} or $this->{"Value"} == -1 or $this->{"Value"} == 1
l!l&&r!l&&!r
4605
not defined $this->{"Value"} or $this->{"Value"} == -1
l!l&&r!l&&!r
4605
MC/DC33%1/3
not defined $this->{"Value"} or $this->{"Value"} == -1 or $this->{"Value"} == 1
not defined $this->{"Value"} $this->{"Value"} == -1 $this->{"Value"} == 1
Truth table50%2/4
not(A) or B or C
A= not defined $this->{"Value"}B= $this->{"Value"} == -1C= $this->{"Value"} == 1
ABCresult
1XX1
01X1
0011
0000
52 5 ▶ croak "For index $this->{Name} conflicting values $this->{Value} and $val given\n" if $val != 1 && $val != $this->{Value};
Branch: 1 branch
BranchTrueFalseTotal
if $val != 1 and $val != $this->{"Value"} 2 3 5
Condition100%3/3
$val != 1 and $val != $this->{"Value"}
!ll&&!rl&&r
122
MC/DC100%2/2
$val != 1 and $val != $this->{"Value"}
$val != 1 $val != $this->{"Value"}
Truth table100%3/3
A and B
A= $val != 1B= $val != $this->{"Value"}
ABresult
0X0
100
111
53 }
54  
55 # This index will take its size value from outside parameter ...
56 2 ▶sub set_from { my($this,$otherpar) = @_;
Subroutine set_from: called CC=1 SCAR=0.0
57 2 $this->{From} = $otherpar;
58 }
59  
60 284 ▶sub name {$_[0]{Name}}
Subroutine name: called CC=1 SCAR=0.0
61  
62 # where it occurs in the C arrays that track it (at least name and size)
63 sub set_index {
64 71 ▶ my ($this, $i) = @_;
Subroutine set_index: called CC=1 SCAR=0.0
65 71 $this->{Index} = $i;
66 }
67 17 ▶sub get_index {$_[0]{Index} // confess "unknown index for $_[0]{Name}"}
Subroutine get_index: called CC=2 SCAR=9.2
Condition33%1/3
$_[0]{"Index"} // confess(qq[unknown index for $_[0]{"Name"}])
l!l&&r!l&&!r
1700
MC/DC0%0/2
$_[0]{"Index"} // confess(qq[unknown index for $_[0]{"Name"}])
$_[0]{"Index"} confess(qq[unknown index for $_[0]{"Name"}])
Truth table33%1/3
A // B
A= $_[0]{"Index"}B= confess(qq[unknown index for $_[0]{"Name"}])
ABresult
1X1
011
000
68  
69 35 ▶sub get_initdim { my($this) = @_;
Subroutine get_initdim: called CC=4 SCAR=13.9
70 my $init = $this->{Value} //
71 35 ▶ ($this->{From} ? "\$COMP(".$this->{From}{ProtoName}.")" : undef);
Branch: 1 branch
BranchTrueFalseTotal
$this->{'From'} ? : 1 33 34
Condition100%3/3
$this->{"Value"} // ($this->{"From"} ? '$COMP(' . $this->{"From"}{"ProtoName"} . ')' : undef)
l!l&&r!l&&!r
1133
MC/DC100%2/2
$this->{"Value"} // ($this->{"From"} ? '$COMP(' . $this->{"From"}{"ProtoName"} . ')' : undef)
$this->{"Value"} ($this->{"From"} ? '$COMP(' . $this->{"From"}{"ProtoName"} . ')' : undef)
Truth table100%3/3
A // B
A= $this->{"Value"}B= ($this->{"From"} ? '$COMP(' . $this->{"From"}{"ProtoName"} . ')' : undef)
ABresult
1X1
011
000
72 35 ▶ return if !defined $init;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $init 33 2 35
73 2 $this->get_size." = $init;"
74 }
75  
76 3 ▶sub get_size { my($this) = @_;
Subroutine get_size: called CC=1 SCAR=0.0
77 3 "\$PRIV(ind_sizes)[@{[$this->get_index]}]"
78 }
79  
80 4 1;
« blib/lib/PDL/Install/Files.pm ↑ Summary blib/lib/PDL/Ops.pm »