Statistics/R/REXP/Complex.pm

filter: Statementstmt 100% 50 / 50 Branchbran 90.0% 18 / 20 Conditioncond 52.3% 11 / 21 MC/DCmcdc 25.0% 3 / 12 Subroutinesub 100% 11 / 11 Podpod 0.0% 0 / 2 totaltotal 80.1% 93 / 116 CC 18 SCAR 18.0
CC
18
Cov
87%
BUILD
9.2
__ANON__
9.1
BUILDARGS
5.0
CRAP 6.1
« Statistics/R/IO.pm ↑ Summary Statistics/R/REXP/S4.pm »
1 package Statistics::R::REXP::Complex;
2 # ABSTRACT: an R numeric vector
3 12 $Statistics::R::REXP::Complex::VERSION = '1.0002';
4 12 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 12 ▶use Scalar::Util qw(blessed looks_like_number);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 12 ▶use Math::Complex qw();
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 12 ▶use Class::Tiny::Antlers qw(-default around);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 12 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 12 extends 'Statistics::R::REXP::Vector';
13 12 ▶use overload;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15  
16 12 ▶use constant sexptype => 'CPLXSXP';
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18  
19 194 ▶sub BUILDARGS {
Subroutine BUILDARGS: called CC=5 SCAR=16.1
Pod undocumented
20 194 my $class = shift;
21 194 my $attributes = $class->SUPER::BUILDARGS(@_);
22  
23 193 ▶ if (ref($attributes->{elements}) eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $attributes->{"elements"} eq "ARRAY") 179 14 193
24 $attributes->{elements} = [
25 318 ▶ map { (blessed($_) && $_->isa('Math::Complex')) ? $_ :
Branch: 2 branches
BranchTrueFalseTotal
builtin::blessed($_) && $_->isa('Math::Complex') ? : 242 76 318
&looks_like_number($_) ? : 46 30 76
Condition66%2/3
builtin::blessed($_) and $_->isa("Math::Complex")
!ll&&!rl&&r
760242
MC/DC50%1/2
builtin::blessed($_) and $_->isa("Math::Complex")
builtin::blessed($_) $_->isa("Math::Complex")
Truth table66%2/3
A and B
A= builtin::blessed($_)B= $_->isa("Math::Complex")
ABresult
0X0
100
111
26 looks_like_number $_ ? Math::Complex::cplx($_) :
27 undef }
28 179 Statistics::R::REXP::Vector::_flatten(@{$attributes->{elements}})
29 ]
30 }
31 $attributes
32 193 }
33  
34  
35 190 ▶sub BUILD {
Subroutine BUILD: called CC=6 SCAR=22.1
Pod undocumented
36 190 my ($self, $args) = @_;
37  
38 # Required attribute type
39 die "Elements of the 'elements' attribute must be scalar numbers or instances of Math::Complex" if
40 defined $self->elements &&
41 318 ▶ grep { defined($_) && !(blessed($_) && $_->isa('Math::Complex') ||
Condition44%4/9
defined $_ && !(builtin::blessed($_) && $_->isa('Math::Complex') || &Scalar::Util::looks_like_number($_))
!ll&&!rl&&r
302880
builtin::blessed($_) && $_->isa('Math::Complex') || &Scalar::Util::looks_like_number($_)
l!l&&r!l&&!r
28800
builtin::blessed($_) and $_->isa("Math::Complex")
!ll&&!rl&&r
00288
MC/DC0%0/4
defined $_ && !(builtin::blessed($_) && $_->isa('Math::Complex') || &Scalar::Util::looks_like_number($_))
defined $_ builtin::blessed($_) $_->isa("Math::Complex") &Scalar::Util::looks_like_number($_)
Truth table33%2/6
A && not(B and C || D)
A= defined $_B= builtin::blessed($_)C= $_->isa("Math::Complex")D= &Scalar::Util::looks_like_number($_)
ABCDresult
0XXX0
111X0
10X10
11010
10X01
11001
42 Scalar::Util::looks_like_number($_)) }
43 190 ▶ @{$self->elements}
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->elements and grep {defined $_ and not builtin::blessed($_) && $_->isa("Math::Complex") || &Scalar::Util::looks_like_number($_);} @{$self->elements;} 0 190 190
Condition33%1/3
defined $self->elements and grep {defined $_ and not builtin::blessed($_) && $_->isa("Math::Complex") || &Scalar::Util::looks_like_number($_);} @{$self->elements;}
!ll&&!rl&&r
01900
MC/DC0%0/2
defined $self->elements and grep {defined $_ and not builtin::blessed($_) && $_->isa("Math::Complex") || &Scalar::Util::looks_like_number($_);} @{$self->elements;}
defined $self->elements grep {defined $_ and not builtin::blessed($_) && $_->isa("Math::Complex") || &Scalar::Util::looks_like_number($_);} @{$self->elements;}
Truth table33%1/3
A and B
A= defined $self->elementsB= grep {defined $_ and not builtin::blessed($_) && $_->isa("Math::Complex") || &Scalar::Util::looks_like_number($_);} @{$self->elements;}
ABresult
0X0
100
111
44 }
45  
46  
47 123 ▶around _eq => sub {
Subroutine __ANON__: called CC=9 SCAR=22.0
48 123 my $orig = shift;
49  
50 123 ▶ return unless Statistics::R::REXP::_eq(@_);
Branch: 1 branch
BranchTrueFalseTotal
unless Statistics::R::REXP::_eq(@_) 2 121 123
51
52 121 my ($self, $obj) = (shift, shift);
53  
54 121 my $a = $self->elements;
55 121 my $b = $obj->elements;
56 121 ▶ return undef unless scalar(@$a) == scalar(@$b);
Branch: 1 branch
BranchTrueFalseTotal
unless scalar @$a == scalar @$b 0 121 121
57 121 ▶ for (my $i = 0; $i < scalar(@{$a}); $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < scalar @{$a;}) 196 119 315
58 196 my $x = $a->[$i];
59 196 my $y = $b->[$i];
60 196 ▶ if (defined($x) && defined($y)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $x and defined $y) { } 177 19 196
Condition66%2/3
defined $x and defined $y
!ll&&!rl&&r
190177
MC/DC50%1/2
defined $x and defined $y
defined $x defined $y
Truth table66%2/3
A and B
A= defined $xB= defined $y
ABresult
0X0
100
111
61 return undef unless
62 177 ▶ $x == $y;
Branch: 1 branch
BranchTrueFalseTotal
unless $x == $y 1 176 177
63 } else {
64 19 ▶ return undef if defined($x) or defined($y);
Branch: 1 branch
BranchTrueFalseTotal
if defined $x or defined $y 1 18 19
Condition66%2/3
defined $x or defined $y
l!l&&r!l&&!r
0118
MC/DC50%1/2
defined $x or defined $y
defined $x defined $y
Truth table66%2/3
A or B
A= defined $xB= defined $y
ABresult
1X1
011
000
65 }
66 }
67
68 119 1
69 12 };
70  
71  
72 4 ▶sub _type { 'complex'; }
Subroutine _type: called CC=1 SCAR=0.0
73  
74  
75 12 1; # End of Statistics::R::REXP::Complex
76  
77 __END__
« Statistics/R/IO.pm ↑ Summary Statistics/R/REXP/S4.pm »