| 1 | |||||||||||||||||||||||||||||||||||||||||||
| 2 | # count and names of color space axis (short and long), space name = usr | prefix + axis initials | ||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||
| 4 | package Graphics::Toolkit::Color::Space::Basis; | ||||||||||||||||||||||||||||||||||||||||||
| 5 | 52 | ▶ | use v5.12; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 52 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 52 | ▶ | use Graphics::Toolkit::Color::Space::Util qw/is_nr/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 52 | ▶ | use Graphics::Toolkit::Color::Error; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | 547 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=20 SCAR=31.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 547 | my ($pkg, $axis_long_names, $axis_short_names, $space_name, $alias_name, $family, $axis_role_names) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 12 | 547 | ▶ | return 'first argument (axis names) has to be an ARRAY reference' unless ref $axis_long_names eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 544 | ▶ | return 'amount of short axis names have to match the count of long axis names' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
defined $axis_short_names and ref $axis_short_names ne "ARRAY" || @$axis_long_names != @$axis_short_names
ref $axis_short_names ne "ARRAY" or @$axis_long_names != @$axis_short_names
MC/DC66%2/3
defined $axis_short_names and ref $axis_short_names ne "ARRAY" || @$axis_long_names != @$axis_short_names
defined $axis_short_names
ref $axis_short_names ne "ARRAY"
@$axis_long_names != @$axis_short_names
Truth table75%3/4
A and B or C
A= defined $axis_short_namesB= ref $axis_short_names ne "ARRAY"C= @$axis_long_names != @$axis_short_names
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | if defined $axis_short_names and (ref $axis_short_names ne 'ARRAY' or @$axis_long_names != @$axis_short_names); | ||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | 543 | my @axis_long_name = map {lc} @$axis_long_names; | |||||||||||||||||||||||||||||||||||||||||
| 17 | 543 | ▶ | my @axis_short_name = map { color_key_shortcut($_) } (defined $axis_short_names) ? @$axis_short_names : @axis_long_name; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | 543 | ▶ | return 'need some axis names to create a color space' unless @axis_long_name > 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | 543 | ▶ | return 'need same amount of axis short names and long names' unless @axis_long_name == @axis_short_name; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | 543 | ▶ | return 'space family dan only be a string' if defined $family and ref $family; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $family and ref $family
MC/DC0%0/2
defined $family and ref $family
defined $family
ref $family
Truth table66%2/3
A and B
A= defined $familyB= ref $family
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | 543 | ▶ | return 'axis role description has to be provided with a family name' if defined($axis_role_names) and not defined($family); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $axis_role_names and not defined $family
MC/DC0%0/2
defined $axis_role_names and not defined $family
defined $axis_role_names
not defined $family
Truth table66%2/3
A and not(B)
A= defined $axis_role_namesB= not defined $family
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | 543 | ▶ | return 'axis role description has to have same length as axis names' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
defined $axis_role_names and ref $axis_role_names ne "ARRAY" || @$axis_role_names != @$axis_long_names
ref $axis_role_names ne "ARRAY" or @$axis_role_names != @$axis_long_names
MC/DC0%0/3
defined $axis_role_names and ref $axis_role_names ne "ARRAY" || @$axis_role_names != @$axis_long_names
defined $axis_role_names
ref $axis_role_names ne "ARRAY"
@$axis_role_names != @$axis_long_names
Truth table50%2/4
A and B or C
A= defined $axis_role_namesB= ref $axis_role_names ne "ARRAY"C= @$axis_role_names != @$axis_long_names
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | if defined $axis_role_names and (ref $axis_role_names ne 'ARRAY' or @$axis_role_names != @$axis_long_names); | ||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | 543 | my @iterator = 0 .. $#axis_long_name; | |||||||||||||||||||||||||||||||||||||||||
| 26 | 543 | my %long_name_order = map { $axis_long_name[$_] => $_ } @iterator; | |||||||||||||||||||||||||||||||||||||||||
| 27 | 543 | my %short_name_order = map { $axis_short_name[$_] => $_ } @iterator; | |||||||||||||||||||||||||||||||||||||||||
| 28 | 543 | my $axis_initials = uc join( '', @axis_short_name ); | |||||||||||||||||||||||||||||||||||||||||
| 29 | 543 | ▶ | $space_name //= $axis_initials; | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$space_name //= $axis_initials
MC/DC0%0/2
$space_name //= $axis_initials
$space_name
$axis_initials
Truth table66%2/3
A //= B
A= $space_nameB= $axis_initials
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | 543 | ▶ | $alias_name //= ''; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$alias_name //= ""
MC/DC100%1/1
$alias_name //= ""
$alias_name
Truth table100%2/2
A
A= $alias_name
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | 543 | my %role_name_order; | |||||||||||||||||||||||||||||||||||||||||
| 33 | 543 | ▶ | %role_name_order = map { $axis_role_names->[$_] => $_ } @iterator if defined $axis_role_names; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | 543 | ▶ | bless { space_name => $space_name, alias_name => $alias_name, | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%4/4
$family // ""
$axis_role_names // []
MC/DC100%1/1
$family // ""
$family
MC/DC100%1/1
$axis_role_names // []
$axis_role_names
Truth table100%2/2
A
A= $family
Truth table100%2/2
A
A= $axis_role_names
| |||||||||||||||||||||||||||||||||||||||||||
| 36 | normal_name => normalize_name('',$space_name), normal_alias => normalize_name('',$alias_name), | ||||||||||||||||||||||||||||||||||||||||||
| 37 | space_family_name => $family // '', | ||||||||||||||||||||||||||||||||||||||||||
| 38 | axis_long_name => \@axis_long_name, long_name_order => \%long_name_order, | ||||||||||||||||||||||||||||||||||||||||||
| 39 | axis_short_name => \@axis_short_name, short_name_order => \%short_name_order, | ||||||||||||||||||||||||||||||||||||||||||
| 40 | axis_role_name => $axis_role_names // [], role_name_order => \%role_name_order, | ||||||||||||||||||||||||||||||||||||||||||
| 41 | axis_iterator => \@iterator, | ||||||||||||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||||||||||||
| 44 | 1657 | ▶ | sub color_key_shortcut { lc substr($_[0], 0, 1) if defined $_[0] } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
color_key_shortcut: called CC=2 SCAR=7.6
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||
| 46 | #### getter ############################################################ | ||||||||||||||||||||||||||||||||||||||||||
| 47 | 8038 | ▶ | sub space_name { # -- ?alias ?given --> ~ | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
space_name: called CC=7 SCAR=19.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 48 | 8038 | my ($self, $alias, $given) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 49 | 8038 | ▶ | $given = undef if defined $given and not $given; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $given and not $given
MC/DC0%0/2
defined $given and not $given
defined $given
not $given
Truth table66%2/3
A and not(B)
A= defined $givenB= not $given
| |||||||||||||||||||||||||||||||||||||||||||
| 50 | 8038 | ▶ | if (defined $alias and $alias ){ return defined( $given ) ? $self->{'alias_name'} : $self->{'normal_alias'} } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
defined $alias and $alias
MC/DC50%1/2
defined $alias and $alias
defined $alias
$alias
Truth table66%2/3
A and B
A= defined $aliasB= $alias
| |||||||||||||||||||||||||||||||||||||||||||
| 51 | 7493 | ▶ | else { return defined( $given ) ? $self->{'space_name'} : $self->{'normal_name'} } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||
| 53 | 990 | ▶ | sub family { $_[0]{'space_family_name'}} # | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
family: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 54 | 312 | ▶ | sub long_axis_names { @{$_[0]{'axis_long_name'}} } # | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
long_axis_names: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 55 | 9 | ▶ | sub short_axis_names { @{$_[0]{'axis_short_name'}} } # | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
short_axis_names: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | ▶ | sub axis_role_names { @{$_[0]{'axis_role_name'}} } # | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
axis_role_names: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 57 | 12490 | ▶ | sub axis_iterator { @{$_[0]{'axis_iterator'}} } # counting all axis 0 .. -1 | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
axis_iterator: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 58 | 19205 | ▶ | sub axis_count { int @{$_[0]{'axis_iterator'}} } # | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
axis_count: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||
| 60 | #### predicates ######################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 61 | 3452 | ▶ | sub is_name { # --> ? # is this a valid name of this space | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_name: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 62 | 3452 | my ($self, $name) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 63 | 3452 | ▶ | return 0 unless defined $name; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 64 | 2428 | $name = $self->normalize_name( $name ); | |||||||||||||||||||||||||||||||||||||||||
| 65 | 2428 | ▶ | return 1 if $name eq $self->{'normal_name'}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 66 | 2248 | ▶ | return 1 if $self->{'alias_name'} and $name eq $self->{'normal_alias'}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->{"alias_name"} and $name eq $self->{"normal_alias"}
MC/DC100%2/2
$self->{"alias_name"} and $name eq $self->{"normal_alias"}
$self->{"alias_name"}
$name eq $self->{"normal_alias"}
Truth table100%3/3
A and B
A= $self->{"alias_name"}B= $name eq $self->{"normal_alias"}
| |||||||||||||||||||||||||||||||||||||||||||
| 67 | 2208 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||
| 69 | 19725 | ▶ | sub normalize_name { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
normalize_name: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 70 | 19725 | my ($self, $name) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 71 | 19725 | ▶ | return $name unless defined $name; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 72 | 19725 | $name = uc $name; | |||||||||||||||||||||||||||||||||||||||||
| 73 | 19725 | $name =~ tr/_ .-//d; # '-' has to be last | |||||||||||||||||||||||||||||||||||||||||
| 74 | 19725 | return $name; | |||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | 1555 | ▶ | sub is_long_axis_name { (defined $_[1] and exists $_[0]->{'long_name_order'}{ lc $_[1] }) ? 1 : 0 } # ~long_name --> ? | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_long_axis_name: called CC=3 SCAR=11.1
Pod
undocumented
Branch: 1 branch
Condition66%2/3
defined $_[1] and exists $_[0]{"long_name_order"}{lc $_[1]}
MC/DC50%1/2
defined $_[1] and exists $_[0]{"long_name_order"}{lc $_[1]}
defined $_[1]
exists $_[0]{"long_name_order"}{lc $_[1]}
Truth table66%2/3
A and B
A= defined $_[1]B= exists $_[0]{"long_name_order"}{lc $_[1]}
| |||||||||||||||||||||||||||||||||||||||||||
| 78 | 1114 | ▶ | sub is_short_axis_name { (defined $_[1] and exists $_[0]->{'short_name_order'}{ lc $_[1] }) ? 1 : 0 } # ~short_name --> ? | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_short_axis_name: called CC=3 SCAR=11.1
Pod
undocumented
Branch: 1 branch
Condition66%2/3
defined $_[1] and exists $_[0]{"short_name_order"}{lc $_[1]}
MC/DC50%1/2
defined $_[1] and exists $_[0]{"short_name_order"}{lc $_[1]}
defined $_[1]
exists $_[0]{"short_name_order"}{lc $_[1]}
Truth table66%2/3
A and B
A= defined $_[1]B= exists $_[0]{"short_name_order"}{lc $_[1]}
| |||||||||||||||||||||||||||||||||||||||||||
| 79 | 28 | ▶ | sub is_axis_role_name { (defined $_[1] and exists $_[0]->{'role_name_order'}{ lc $_[1] }) ? 1 : 0 } # ~role_name --> ? | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_axis_role_name: called CC=3 SCAR=14.2
Pod
undocumented
Branch: 1 branch
Condition33%1/3
defined $_[1] and exists $_[0]{"role_name_order"}{lc $_[1]}
MC/DC0%0/2
defined $_[1] and exists $_[0]{"role_name_order"}{lc $_[1]}
defined $_[1]
exists $_[0]{"role_name_order"}{lc $_[1]}
Truth table33%1/3
A and B
A= defined $_[1]B= exists $_[0]{"role_name_order"}{lc $_[1]}
| |||||||||||||||||||||||||||||||||||||||||||
| 80 | 1547 | ▶ | sub is_axis_name { $_[0]->is_long_axis_name($_[1]) or $_[0]->is_short_axis_name($_[1]) } # ~long|short --> ? | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_axis_name: called CC=2 SCAR=6.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 81 | 28 | ▶ | sub is_axis_role { $_[0]->is_axis_role_name($_[1]) or $_[0]->is_axis_name($_[1]) } # ~name --> ? | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_axis_role: called CC=2 SCAR=7.6
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||
| 83 | 1141 | ▶ | sub pos_from_long_axis_name { defined $_[1] ? $_[0]->{'long_name_order'}{ lc $_[1] } : undef } # ~long_name --> +pos | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pos_from_long_axis_name: called CC=2 SCAR=7.6
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 84 | 564 | ▶ | sub pos_from_short_axis_name { defined $_[1] ? $_[0]->{'short_name_order'}{ lc $_[1] } : undef } # ~short_name --> +pos | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pos_from_short_axis_name: called CC=2 SCAR=7.6
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 85 | 88 | ▶ | sub pos_from_axis_role_name { defined $_[1] ? $_[0]->{'role_name_order'}{ lc $_[1] } : undef } # ~role_name --> +pos | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pos_from_axis_role_name: called CC=2 SCAR=7.6
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 86 | 495 | ▶ | sub pos_from_axis_name { pos_from_long_axis_name(@_) // pos_from_short_axis_name(@_) } # ~long|short --> +pos | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pos_from_axis_name: called CC=2 SCAR=6.9
Pod
undocumented
Condition100%3/3
pos_from_long_axis_name(@_) // pos_from_short_axis_name(@_)
MC/DC100%2/2
pos_from_long_axis_name(@_) // pos_from_short_axis_name(@_)
pos_from_long_axis_name(@_)
pos_from_short_axis_name(@_)
Truth table100%3/3
A // B
A= pos_from_long_axis_name(@_)B= pos_from_short_axis_name(@_)
| |||||||||||||||||||||||||||||||||||||||||||
| 87 | 88 | ▶ | sub pos_from_axis_role { pos_from_axis_role_name(@_) // pos_from_axis_name(@_) } # ~name --> +pos | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pos_from_axis_role: called CC=2 SCAR=7.2
Pod
undocumented
Condition66%2/3
pos_from_axis_role_name(@_) // pos_from_axis_name(@_)
MC/DC50%1/2
pos_from_axis_role_name(@_) // pos_from_axis_name(@_)
pos_from_axis_role_name(@_)
pos_from_axis_name(@_)
Truth table66%2/3
A // B
A= pos_from_axis_role_name(@_)B= pos_from_axis_name(@_)
| |||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||
| 89 | 2355 | ▶ | sub is_hash { # with all axis names as keys | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_hash: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 90 | 2355 | my ($self, $value_hash) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 91 | 2355 | ▶ | $self->is_partial_hash( $value_hash ) and (keys %$value_hash == $self->axis_count); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||
| 93 | 2849 | ▶ | sub is_partial_hash { # with some axis names as keys | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_partial_hash: called CC=9 SCAR=22.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 94 | 2849 | my ($self, $value_hash) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 95 | 2849 | ▶ | return 0 unless ref $value_hash eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 96 | 1034 | my $key_count = keys %$value_hash; | |||||||||||||||||||||||||||||||||||||||||
| 97 | 1034 | my @axis_visited; | |||||||||||||||||||||||||||||||||||||||||
| 98 | 1034 | ▶ | return 0 unless $key_count and $key_count <= $self->axis_count; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$key_count and $key_count <= $self->axis_count
MC/DC100%2/2
$key_count and $key_count <= $self->axis_count
$key_count
$key_count <= $self->axis_count
Truth table100%3/3
A and B
A= $key_countB= $key_count <= $self->axis_count
| |||||||||||||||||||||||||||||||||||||||||||
| 99 | 857 | for my $axis_name (keys %$value_hash) { | |||||||||||||||||||||||||||||||||||||||||
| 100 | 1263 | ▶ | return 0 unless $self->is_axis_name( $axis_name ) and defined $value_hash->{$axis_name}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->is_axis_name($axis_name) and defined $value_hash->{$axis_name}
MC/DC50%1/2
$self->is_axis_name($axis_name) and defined $value_hash->{$axis_name}
$self->is_axis_name($axis_name)
defined $value_hash->{$axis_name}
Truth table66%2/3
A and B
A= $self->is_axis_name($axis_name)B= defined $value_hash->{$axis_name}
| |||||||||||||||||||||||||||||||||||||||||||
| 101 | 637 | my $axis_pos = $self->pos_from_long_axis_name( $axis_name ); | |||||||||||||||||||||||||||||||||||||||||
| 102 | 637 | ▶ | $axis_pos = $self->pos_from_short_axis_name( $axis_name ) unless defined $axis_pos; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 103 | 637 | $axis_visited[ $axis_pos ]++; | |||||||||||||||||||||||||||||||||||||||||
| 104 | 637 | ▶ | return 0 if $axis_visited[ $axis_pos ] > 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||
| 106 | 219 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||
| 108 | 10447 | ▶ | sub is_value_tuple { (ref $_[1] eq 'ARRAY' and @{$_[1]} == $_[0]->axis_count) ? 1 : 0 } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_value_tuple: called CC=3 SCAR=11.0
Pod
undocumented
Branch: 1 branch
Condition100%3/3
ref $_[1] eq "ARRAY" and @{$_[1];} == $_[0]->axis_count
MC/DC100%2/2
ref $_[1] eq "ARRAY" and @{$_[1];} == $_[0]->axis_count
ref $_[1] eq "ARRAY"
@{$_[1];} == $_[0]->axis_count
Truth table100%3/3
A and B
A= ref $_[1] eq "ARRAY"B= @{$_[1];} == $_[0]->axis_count
| |||||||||||||||||||||||||||||||||||||||||||
| 109 | 2398 | ▶ | sub is_number_tuple { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_number_tuple: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 110 | 2398 | my ($self, $tuple) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 111 | 2398 | ▶ | return 0 unless $self->is_value_tuple( $tuple ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 112 | 2389 | ▶ | map { return 0 unless is_nr( $tuple->[$_] ) } $self->axis_iterator; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 113 | 2385 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||
| 116 | #### converter ######################################################### | ||||||||||||||||||||||||||||||||||||||||||
| 117 | 4 | ▶ | sub short_axis_name_from_long { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
short_axis_name_from_long: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 118 | 4 | my ($self, $name) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 119 | 4 | ▶ | return unless $self->is_long_axis_name( $name ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 120 | 3 | ($self->short_axis_names)[ $self->pos_from_long_axis_name( $name ) ]; | |||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||
| 122 | 4 | ▶ | sub long_axis_name_from_short { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
long_axis_name_from_short: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 123 | 4 | my ($self, $name) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 124 | 4 | ▶ | return unless $self->is_short_axis_name( $name ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 125 | 3 | ($self->long_axis_names)[ $self->pos_from_short_axis_name( $name ) ]; | |||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||
| 128 | 13 | ▶ | sub long_name_hash_from_tuple { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
long_name_hash_from_tuple: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 129 | 13 | my ($self, $tuple) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 130 | 13 | ▶ | return unless $self->is_value_tuple( $tuple ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 131 | 11 | return { map { $self->{'axis_long_name'}[$_] => $tuple->[$_]} $self->axis_iterator }; | |||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||
| 133 | 10 | ▶ | sub short_name_hash_from_tuple { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
short_name_hash_from_tuple: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 134 | 10 | my ($self, $tuple) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 135 | 10 | ▶ | return unless $self->is_value_tuple( $tuple ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 136 | 8 | return { map {$self->{'axis_short_name'}[$_] => $tuple->[$_]} $self->axis_iterator }; | |||||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||
| 139 | 39 | ▶ | sub tuple_from_hash { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
tuple_from_hash: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 140 | 39 | my ($self, $value_hash) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 141 | 39 | ▶ | return unless $self->is_hash( $value_hash ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 142 | 38 | my $values = [ (0) x $self->axis_count ]; | |||||||||||||||||||||||||||||||||||||||||
| 143 | 38 | for my $key (keys %$value_hash) { | |||||||||||||||||||||||||||||||||||||||||
| 144 | 120 | $values->[ $self->pos_from_axis_name( $key ) ] = $value_hash->{ $key }; | |||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||
| 146 | 38 | return $values; | |||||||||||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||||||||||||
| 148 | 387 | ▶ | sub tuple_from_partial_hash { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
tuple_from_partial_hash: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 149 | 387 | my ($self, $value_hash) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 150 | 387 | ▶ | return unless $self->is_partial_hash( $value_hash ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 151 | 37 | my $values = []; | |||||||||||||||||||||||||||||||||||||||||
| 152 | 37 | for my $key (keys %$value_hash) { | |||||||||||||||||||||||||||||||||||||||||
| 153 | 57 | $values->[ $self->pos_from_axis_name( $key ) ] = $value_hash->{ $key }; | |||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||||
| 155 | 37 | return $values; | |||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||
| 158 | 52 | 1; | |||||||||||||||||||||||||||||||||||||||||