| 1 | package Text::NumericData::File; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # Document and properly test the pipe stuff! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # Think about replacing MaxInterval by something more generic (sorted index according to given expression) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | #textdata version x | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | #see POD below! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 7 | ▶ | use Text::NumericData::Calc qw(linear_value formula_function expression_function); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 7 | ▶ | use Text::NumericData; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 7 | ▶ | use Text::ASCIIPipe; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 7 | ▶ | use sort 'stable'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | # This is just a placeholder because of a past build system bug. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | # The one and only version for Text::NumericData is kept in | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | # the Text::NumericData module itself. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 7 | our $VERSION = '1'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 7 | $VERSION = eval $VERSION; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 7 | our @ISA = ('Text::NumericData'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | # interpolation types | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 7 | my $none = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 7 | my $linear = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 7 | my $spline = 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 7 | our %help = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | interpolate => 'use interpolation inter-/extrapolation for correlation of data sets (choose linear or spline, or 0 for switching it off)' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 7 | our %defaults = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | interpolate => 'linear' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | sub new | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 18 | ▶ | my $class = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=7 SCAR=19.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 18 | my $config = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 18 | my $self = $class->SUPER::new($config); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 18 | $self->{in_file} = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 18 | ▶ | if(defined $config->{interpolate} and $config->{interpolate} eq 'spline') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
defined $config->{"interpolate"} and $config->{"interpolate"} eq "spline"
MC/DC100%2/2
defined $config->{"interpolate"} and $config->{"interpolate"} eq "spline"
defined $config->{"interpolate"}
$config->{"interpolate"} eq "spline"
Truth table100%3/3
A and B
A= defined $config->{"interpolate"}B= $config->{"interpolate"} eq "spline"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 2 | require Math::Spline; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 2 | $self->{intmethod} = $spline; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | ▶ | elsif(defined $config->{interpolate} and not $config->{interpolate}) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
defined $config->{"interpolate"} and not $config->{"interpolate"}
MC/DC100%2/2
defined $config->{"interpolate"} and not $config->{"interpolate"}
defined $config->{"interpolate"}
not $config->{"interpolate"}
Truth table100%3/3
A and not(B)
A= defined $config->{"interpolate"}B= not $config->{"interpolate"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 1 | $self->{intmethod} = $none; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 15 | else{ $self->{intmethod} = $linear; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | $self->{config}{pipemode} = $config->{pipemode} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 18 | ▶ | if(defined $config->{pipemode}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 18 | ▶ | if(defined $self->{in_file}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 6 | $self->read_all(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 18 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | sub init | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | #not touching in_file! this is only handled by Read | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | #as is out_file! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 35 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 35 | $self->SUPER::init(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 35 | ▶ | $self->{config}{indexformat} = '%6E' unless defined $self->{config}->{indexformat}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 35 | ▶ | $self->{config}{extrapol} = 1 unless defined $self->{config}{extrapol}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 35 | $self->{data} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 35 | $self->{records} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 35 | $self->{data_index} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 35 | $self->{sorted_data} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 35 | $self->{raw_header} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 35 | $self->{buffer} = ""; #containing the raw lines read by readhead (the'd be lost from stdin otherwise) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 35 | $self->{splines} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 35 | $self->{splinex} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | sub read_head | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
read_head: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | return $self->read_all($_[0], 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | # Return values mimicking Text::ASCIIPipe::pull_file. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | # <0: failure | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | # 0: successful, but nothing more to expect | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | # >0: successful, more could be there | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | sub read_all | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 17 | ▶ | my ($self, $infile, $justhead) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
read_all: called CC=20 SCAR=33.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 17 | $self->init(); #do we really want full init? | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 17 | ▶ | $self->{in_file} = $infile if defined $infile; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 17 | my $handle; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 17 | ▶ | if(ref $self->{in_file}){ $handle = $self->{in_file}; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | ▶ | elsif(not defined $self->{in_file} or $self->{in_file} eq ''){ $handle = \*STDIN; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
not defined $self->{"in_file"} or $self->{"in_file"} eq ""
MC/DC0%0/2
not defined $self->{"in_file"} or $self->{"in_file"} eq ""
not defined $self->{"in_file"}
$self->{"in_file"} eq ""
Truth table33%1/3
not(A) or B
A= not defined $self->{"in_file"}B= $self->{"in_file"} eq ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 6 | ▶ | else{ open($handle, $self->{in_file}) or return 0; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 17 | my $data = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 17 | binmode($handle); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 17 | my $l; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 17 | $self->{buffer} = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 17 | my $state; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 17 | ▶ | while(defined ($state = Text::ASCIIPipe::fetch($handle, $l))) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 167 | ▶ | if($state == $Text::ASCIIPipe::line) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 167 | ▶ | if(!$data) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 30 | ▶ | $self->{buffer}.= $l if($justhead); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 30 | ▶ | if($self->line_check(\$l)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 17 | ▶ | last if $justhead; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 17 | $data = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 13 | $self->make_naked($l); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 13 | push(@{$self->{raw_header}}, $l); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 167 | ▶ | if($data) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 154 | my $da = $self->line_data($l); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 154 | ▶ | if(defined $da) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 154 | push(@{$self->{data}}, $da); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 154 | ▶ | ++$self->{records} if @{$da}; # count non-empty records | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | # If there is no prior decision, this enables pipe control codes on possibly following write operations. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | ▶ | $self->{config}{pipemode} = 1 unless defined $self->{config}{pipemode}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | # anything but line and begin is an end | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | ▶ | last if $state != $Text::ASCIIPipe::begin; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | # Empty files aren't an error, or are they? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | # All fine: Loop ended with orderly file end marker. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 17 | ▶ | return 1 if(defined $state and $state != $Text::ASCIIPipe::allend); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $state and $state != $Text::ASCIIPipe::allend
MC/DC0%0/2
defined $state and $state != $Text::ASCIIPipe::allend
defined $state
$state != $Text::ASCIIPipe::allend
Truth table33%1/3
A and B
A= defined $stateB= $state != $Text::ASCIIPipe::allend
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | # Ended on EOF (or some esoteric error we still treat as such), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | # as there was no allend or error before that, just assume normal end of things. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 17 | ▶ | return 0 if(not defined $state); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | # If we hit allend, we did not stop with an orderly file end, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | # so must assume we got nothing at all. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | return -1; # if($state == allend) is already implied | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | # After reading Data, intialize interpolation. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | sub prepare_splines | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 2 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
prepare_splines: called CC=7 SCAR=19.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 2 | my $x = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 2 | $self->{splines} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 2 | $self->{splinex} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 2 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 2 | my @x; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | my @data; # the more effective data structe | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 2 | for my $d (@{$self->{data}}) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | # collect data, omitting duplicates | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 16 | ▶ | next if grep {$_ == $d->[$x]} @x; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 16 | push(@x, $d->[$x]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 16 | ▶ | for(my $j = 0; $j <= $#{$d}; ++$j) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 38 | $data[$j][$i] = $d->[$j]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 16 | ++$i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 2 | ▶ | die "Bad spline column index.\n" if($x < 0 or $x > $#data); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$x < 0 or $x > $#data
MC/DC0%0/2
$x < 0 or $x > $#data
$x < 0
$x > $#data
Truth table33%1/3
A or B
A= $x < 0B= $x > $#data
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 2 | $self->{splinex} = $x; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | # Not caring for undefined pieces of data, does Math::Spline care? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 2 | ▶ | for(my $j = 0; $j <= $#data; ++$j) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 5 | $self->{splines}[$j] = Math::Spline->new(\@x, $data[$j]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | sub SplineY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
SplineY: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | my $val = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | my $x = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | my $y = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | ▶ | $x = 0 unless defined $x; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | ▶ | $y = 1 unless defined $y; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | ▶ | $self->prepare_splines($x) unless(defined $self->{splinex} and $self->{splinex} == $x); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $self->{"splinex"} and $self->{"splinex"} == $x
MC/DC0%0/2
defined $self->{"splinex"} and $self->{"splinex"} == $x
defined $self->{"splinex"}
$self->{"splinex"} == $x
Truth table0%0/3
A and B
A= defined $self->{"splinex"}B= $self->{"splinex"} == $x
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | return $self->{splines}[$y]->evaluate($val); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | sub spline_set | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 280 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
spline_set: called CC=5 SCAR=16.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 280 | my $val = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 280 | my $x = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 280 | ▶ | $x = 0 unless defined $x; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 280 | ▶ | $self->prepare_splines($x) unless(defined $self->{splinex} and $self->{splinex} == $x); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $self->{"splinex"} and $self->{"splinex"} == $x
MC/DC50%1/2
defined $self->{"splinex"} and $self->{"splinex"} == $x
defined $self->{"splinex"}
$self->{"splinex"} == $x
Truth table66%2/3
A and B
A= defined $self->{"splinex"}B= $self->{"splinex"} == $x
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 280 | my @set; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 280 | for my $s (@{$self->{splines}}) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 750 | push(@set, $s->evaluate($val)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 280 | return \@set; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | #compute_index(\arrayofcols) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | sub compute_index | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 7 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
compute_index: called CC=7 SCAR=19.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 7 | my $ar = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 7 | my $zahl = $self->{config}->{numregex}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 7 | ▶ | $ar = [0] unless defined $ar; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 7 | foreach my $c (@{$ar}){ $self->{data_index}->[$c] = {};} | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 7 | foreach my $d (@{$self->{data}}) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 66 | foreach my $c (@{$ar}) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 46 | ▶ | my $key = $d->[$c] =~ /$zahl/ ? sprintf($self->{config}->{indexformat}, $d->[$c]) : $d->[$c]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 46 | ▶ | $self->{data_index}->[$c]->{$key} = $d unless defined $self->{data_index}->[$c]->{$key}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | #(col) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | sub compute_sorted_index | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 2 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
compute_sorted_index: called CC=6 SCAR=18.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 2 | my $xl = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 2 | ▶ | $xl = [0] unless defined $xl; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | #compute any missing indices | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 2 | my @l = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 2 | ▶ | foreach my $x (@{$xl}){ push(@l, $x) unless defined $self->{data_index}->[$x]; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 2 | $self->compute_index(\@l); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | #now sort all concerned indices | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 2 | foreach my $x (@{$xl}) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 2 | $self->{sorted_data}->[$x] = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 2 | foreach my $k (sort {$a <=> $b} keys %{$self->{data_index}->[$x]}) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 20 | push(@{$self->{sorted_data}->[$x]}, $self->{data_index}->[$x]->{$k}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | sub write_data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 9 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
write_data: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 9 | my $handle = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 9 | my $selection = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 9 | ▶ | for(my $i = 0; $i <= $#{$self->{data}}; ++$i) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 74 | print $handle ${$self->data_line($self->{data}->[$i],$selection)}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 9 | return 1; # real error checking? | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | #Write(file, columns) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | #maybe adding limits in future... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | sub write_all | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 2 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
write_all: called CC=8 SCAR=25.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 2 | my $file = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 2 | my $selection = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 2 | ▶ | $self->{out_file} = $file if defined $file; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 2 | my $handle; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 2 | ▶ | if(ref $self->{out_file}){ $handle = $self->{out_file}; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | ▶ | elsif(not defined $self->{out_file} or $self->{out_file} eq ''){ $handle = STDOUT; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
not defined $self->{"out_file"} or $self->{"out_file"} eq ""
MC/DC0%0/2
not defined $self->{"out_file"} or $self->{"out_file"} eq ""
not defined $self->{"out_file"}
$self->{"out_file"} eq ""
Truth table0%0/3
not(A) or B
A= not defined $self->{"out_file"}B= $self->{"out_file"} eq ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | ▶ | else{ open($handle, '>', $self->{out_file}) or return 0; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 2 | binmode($handle); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 2 | ▶ | Text::ASCIIPipe::file_begin($handle) if($self->{config}{pipemode}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | #header | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 2 | $self->write_head($handle, $selection); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | #data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 2 | $self->write_data($handle, $selection); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 2 | ▶ | Text::ASCIIPipe::file_end($handle) if($self->{config}{pipemode}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 2 | return 1; # real error checking? | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | # An inconsistency in first release was write_header, not write_head, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | # as it matches read_head. Providing this wrapper now. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | sub write_header | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 5 | ▶ | my $self = shift; # No real need to shift here, but keeping in style. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
write_header: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 5 | return $self->write_head(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | sub write_head | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 7 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
write_head: called CC=4 SCAR=14.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 7 | my $handle = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 7 | my $selection = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | # If there is no old raw header, do a new one automaticaly. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 7 | ▶ | if(@{$self->{raw_header}}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 6 | foreach my $h (@{$self->{raw_header}}) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 12 | print $handle ${$self->comment_line($h)}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 6 | ▶ | if(defined $selection) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | print $handle ${$self->title_line($selection)}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 1 | return $self->write_new_header($handle,$selection); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 6 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | sub write_new_header | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
write_new_header: called CC=3 SCAR=11.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 1 | my $handle = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 1 | my $selection = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 1 | ▶ | print $handle ${$self->comment_line(\$self->{title})} if defined $self->{title}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 1 | foreach my $c (@{$self->{comments}}){ print $handle ${$self->comment_line(\$c)}; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 1 | print $handle ${$self->title_line($selection)}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 1 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | sub set_of_noint | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 600 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_of_noint: called CC=4 SCAR=14.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 600 | my $value = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 600 | my $zahl = $self->{config}->{numregex}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 600 | ▶ | $value = sprintf($self->{config}->{indexformat}, $value) if $value =~ /$zahl/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 600 | my $x = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 600 | ▶ | $x = 0 unless defined $x; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 600 | ▶ | defined $self->{data_index}->[$x] or $self->compute_index([$x]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 600 | return $self->{data_index}->[$x]->{$value}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | sub set_of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 600 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_of: called CC=9 SCAR=22.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | #the easy way | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 600 | my $set = $self->set_of_noint(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | return $set | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 600 | ▶ | if (defined $set or $self->{intmethod} == $none); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $set or $self->{"intmethod"} == $none
MC/DC100%2/2
defined $set or $self->{"intmethod"} == $none
defined $set
$self->{"intmethod"} == $none
Truth table100%3/3
A or B
A= defined $setB= $self->{"intmethod"} == $none
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | #so, we got to do some Work; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 460 | my $val = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 460 | my $x = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 460 | ▶ | $x = 0 unless defined $x; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 460 | ▶ | if($self->{intmethod} == $spline) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 280 | return $self->spline_set($val, $x); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | #find suitable data value pairs for interpolation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 180 | my $sets = $self->neighbours($val, $x); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 180 | ▶ | return undef unless defined $sets and $#{$sets} == 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $sets and $#{$sets;} == 1
MC/DC0%0/2
defined $sets and $#{$sets;} == 1
defined $sets
$#{$sets;} == 1
Truth table33%1/3
A and B
A= defined $setsB= $#{$sets;} == 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | #compute | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 180 | my @set = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 180 | ▶ | for(my $y = 0; $y <= $#{$sets->[0]}; ++$y) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 360 | ▶ | if($y != $x) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 180 | push(@set, linear_value($val, [$sets->[0][$x], $sets->[1][$x]], [$sets->[0][$y],$sets->[1][$y]])); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 180 | else{ push(@set, $val); } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 180 | return \@set; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | sub y_noint | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
y_noint: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 0 | my $val = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | my $x = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | my $y = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | ▶ | $x = 0 unless defined $x; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | ▶ | $y = 1 unless defined $y; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | my $set = $self->set_of($val,$x); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | ▶ | return defined $set ? $set->[$y] : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | sub y | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
y: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | #the easy way | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 0 | my $y = $self->y_noint(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | return $y | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | ▶ | if (defined $y or $self->{intmethod} == $none); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $y or $self->{"intmethod"} == $none
MC/DC0%0/2
defined $y or $self->{"intmethod"} == $none
defined $y
$self->{"intmethod"} == $none
Truth table0%0/3
A or B
A= defined $yB= $self->{"intmethod"} == $none
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | #so, we got to do some Work; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 0 | my $val = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 0 | my $x = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 0 | $y = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 0 | ▶ | $x = 0 unless defined $x; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 0 | ▶ | $y = 1 unless defined $y; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 0 | ▶ | if($self->{intmethod} == $spline) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | return $self->spline_y($val, $x, $y); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | #find suitable data value pairs for interpolation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 0 | my $sets = $self->neighbours($val, $x); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 0 | ▶ | return undef unless defined $sets and $#{$sets} == 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $sets and $#{$sets;} == 1
MC/DC0%0/2
defined $sets and $#{$sets;} == 1
defined $sets
$#{$sets;} == 1
Truth table0%0/3
A and B
A= defined $setsB= $#{$sets;} == 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | #compute | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | #print STDERR "Sets: "; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | #for(@{$sets}){ print STDERR "(@{$_}) "; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | #print STDERR "\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 0 | return linear_value($val, [$sets->[0][$x], $sets->[1][$x]], [$sets->[0][$y],$sets->[1][$y]]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | #it should be configurable wheter extrapolation is acceptable | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | sub neighbours | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 180 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
neighbours: called CC=21 SCAR=47.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 180 | my $val = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 180 | my $x = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 180 | my $n = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 180 | my $e = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 180 | ▶ | unless($self->{config}{orderedint}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 180 | ▶ | defined $self->{sorted_data}->[$x] or $self->compute_sorted_index([$x]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 180 | ▶ | return undef unless $#{$self->{sorted_data}->[$x]} > 0; #senseless when not at least two points there | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 180 | foreach my $v (@{$self->{sorted_data}->[$x]}) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 1044 | $n = $e; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 1044 | $e = $v; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 1044 | ▶ | if($v->[$x] > $val and defined $n){ last; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$v->[$x] > $val and defined $n
MC/DC100%2/2
$v->[$x] > $val and defined $n
$v->[$x] > $val
defined $n
Truth table100%3/3
A and B
A= $v->[$x] > $valB= defined $n
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 0 | ▶ | if(defined $self->{data}[0] and $self->{data}[0][$x] < $val) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $self->{"data"}[0] and $self->{"data"}[0][$x] < $val
MC/DC0%0/2
defined $self->{"data"}[0] and $self->{"data"}[0][$x] < $val
defined $self->{"data"}[0]
$self->{"data"}[0][$x] < $val
Truth table0%0/3
A and B
A= defined $self->{"data"}[0]B= $self->{"data"}[0][$x] < $val
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 0 | foreach my $v (@{$self->{data}}) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 0 | $n = $e; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 0 | $e = $v; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 0 | ▶ | if($v->[$x] > $val and defined $n){ last; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$v->[$x] > $val and defined $n
MC/DC0%0/2
$v->[$x] > $val and defined $n
$v->[$x] > $val
defined $n
Truth table0%0/3
A and B
A= $v->[$x] > $valB= defined $n
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 0 | foreach my $v (@{$self->{data}}) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 0 | $n = $e; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 0 | $e = $v; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 0 | ▶ | if($v->[$x] < $val and defined $n){ last; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$v->[$x] < $val and defined $n
MC/DC0%0/2
$v->[$x] < $val and defined $n
$v->[$x] < $val
defined $n
Truth table0%0/3
A and B
A= $v->[$x] < $valB= defined $n
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 180 | ▶ | return undef unless defined $n; #catches both empty array and one-element-array | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 180 | ▶ | unless($self->{config}{extrapol}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | #check if we have left and right neighbour | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 0 | ▶ | return undef unless (($n->[$x] <= $val and $e->[$x] >= $val) or ($n->[$x] >= $val and $e->[$x] <= $val)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
$n->[$x] <= $val and $e->[$x] >= $val or $n->[$x] >= $val and $e->[$x] <= $val
$n->[$x] <= $val and $e->[$x] >= $val
$n->[$x] >= $val and $e->[$x] <= $val
MC/DC0%0/4
$n->[$x] <= $val and $e->[$x] >= $val or $n->[$x] >= $val and $e->[$x] <= $val
$n->[$x] <= $val
$e->[$x] >= $val
$n->[$x] >= $val
$e->[$x] <= $val
Truth table0%0/7
A and B or C and D
A= $n->[$x] <= $valB= $e->[$x] >= $valC= $n->[$x] >= $valD= $e->[$x] <= $val
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 180 | return [$n,$e]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | sub max | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
max: called CC=5 SCAR=16.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 1 | my $formula = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 1 | my $ff = expression_function($formula); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 1 | ▶ | return undef unless defined $ff; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 1 | my $max = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 1 | foreach my $d (@{$self->{data}}) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 4 | my $nm = &$ff([$d]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 4 | ▶ | $max = $nm if !defined $max or $nm > $max; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not defined $max or $nm > $max
MC/DC50%1/2
not defined $max or $nm > $max
not defined $max
$nm > $max
Truth table66%2/3
not(A) or B
A= not defined $maxB= $nm > $max
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 1 | return $max; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | # A little Hack for now... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | # Return the two indices for the two biggest expression values. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | # Idea: Between those, the "real" maximum is to be found, perhaps using non-linear interpolation. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | sub max_interval | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
max_interval: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 0 | my $formula = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 0 | my $ff = expression_function($formula); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 0 | ▶ | return undef unless defined $ff; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 0 | my @maxval; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | my @maxidx; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 0 | for my $idx (1..$#{$self->{data}}) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 0 | my $nm = &$ff([$self->{data}[$idx]]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 0 | ▶ | if(@maxval) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 0 | ▶ | if($nm >= $maxval[0]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 0 | $maxval[1] = $maxval[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 0 | $maxval[0] = $nm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 0 | $maxidx[1] = $maxidx[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 0 | $maxidx[0] = $idx; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | elsif($nm > $maxval[1]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 0 | $maxval[1] = $nm; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 0 | $maxidx[1] = $idx; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 0 | @maxidx = ($idx, $idx); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 0 | @maxval = ($nm, $nm); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 0 | return @maxidx; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | sub min | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
min: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 0 | my $formula = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 0 | $formula = '-('.$formula.')'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 0 | return -1*$self->max($formula); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | sub sort_func | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 8 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sort_func: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 8 | my $cols = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 8 | my $down = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 8 | my $sortcode = 'my $r; '; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 8 | my $i = -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | # tested example sortcode: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | # '{ my $c; ($c= $a->[0] <=> $b->[0]) ? $c : ($c= $a->[1] <=> $b->[1]) ? $c : 0 }' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 8 | foreach my $prec (@{$cols}) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | # Ensure only integer values enter evalued code. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | # Invalid numbers get parsed to zero, as perl does normally. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 9 | ▶ | my $c = $prec =~ /^(\d+)/ ? $1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 9 | my $r = '$r'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 9 | my $a = '$a'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 9 | my $b = '$b'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 9 | ▶ | if(defined $down and $down->[++$i]) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $down and $$down[++$i]
MC/DC50%1/2
defined $down and $$down[++$i]
defined $down
$$down[++$i]
Truth table66%2/3
A and B
A= defined $downB= $$down[++$i]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 1 | $a = '$b'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 1 | $b = '$a'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 9 | $sortcode .= "($r= $a\->[$c] <=> $b\->[$c]) ? $r : "; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | 8 | $sortcode .= '0'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | # Not sure... is it better to eval that function here or to to put the eval into the sort call? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | #print STDERR "Sort code: $sortcode\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 8 | return eval 'sub {'.$sortcode.'}'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | sub sort_data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 8 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sort_data: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 8 | my $cols = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 8 | my $down = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 8 | my $sortfunc = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 8 | ▶ | unless(defined $sortfunc) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 8 | $sortfunc = $self->sort_func($cols,$down); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 8 | @{$self->{data}} = sort $sortfunc @{$self->{data}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 8 | return $sortfunc; # Possibility to reuse the sort function. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | # Heck, this is the gut of txdcalc. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | # I do wonder if I could make that use this function here... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | # ... or a line-oriented version, rather. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | sub calc | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
calc: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 1 | my $formula = shift; # formula string | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 1 | my $config = shift; # {'byrow'=>0, 'bycol'=>0 } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | 1 | my $files = shift; # list of files to use for [2,1] style refs | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 1 | my $workarray = shift; # \@A | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 1 | my $constants = shift; # \@C | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | 1 | my $ff = formula_function($formula); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 1 | ▶ | return 0 unless defined $ff; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 1 | require Text::NumericData::FileCalc; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | my $deletelist = Text::NumericData::FileCalc::file_calc | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | $ff | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | , $config | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | , $self->{data} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 1 | , $files | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | , $workarray | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | , $constants | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | 1 | ▶ | return 0 unless defined $deletelist; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | 1 | $self->delete_rows($deletelist); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | 1 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | # delete indicated rows from data set | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | sub delete_rows | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
delete_rows: called CC=10 SCAR=38.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 1 | my $delist = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | 1 | ▶ | return unless defined $delist; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | 1 | my @delis = sort {$a <=> $b} @{$delist}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | 1 | ▶ | while(@delis and $delis[0]<0){ shift(@delis); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@delis and $delis[0] < 0
MC/DC0%0/2
@delis and $delis[0] < 0
@delis
$delis[0] < 0
Truth table33%1/3
A and B
A= @delisB= $delis[0] < 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 1 | ▶ | while(@delis and $delis[$#delis]>$#{$self->{data}}){ pop(@delis); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@delis and $delis[$#delis] > $#{$$self{"data"};}
MC/DC0%0/2
@delis and $delis[$#delis] > $#{$$self{"data"};}
@delis
$delis[$#delis] > $#{$$self{"data"};}
Truth table33%1/3
A and B
A= @delisB= $delis[$#delis] > $#{$$self{"data"};}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | 1 | ▶ | return unless @delis; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | # This is designed to handle possibly many sparse deletes in one go. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | # One simple splice() wouldn't do it. Many would be wasteful. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | # This is a rather stupid approach, but at least linear and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | # light on index confusion. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | 0 | my @newdata; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | 0 | my $row = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | 0 | ▶ | while(@delis) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | 0 | my $pi = shift(@delis); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | # splice off the leading part including the to-be-deleted one | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | 0 | my @part = splice(@{$self->{data}}, 0, $pi-$row+1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 0 | $row += @part; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | 0 | pop(@part); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | 0 | push(@newdata, @part); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | # make sure the next index is different | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | 0 | ▶ | while(@delis and $delis[0] == $pi){ shift(@delis); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@delis and $delis[0] == $pi
MC/DC0%0/2
@delis and $delis[0] == $pi
@delis
$delis[0] == $pi
Truth table0%0/3
A and B
A= @delisB= $delis[0] == $pi
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | 0 | push(@newdata, splice(@{$self->{data}}, 0)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | 0 | $self->{data} = \@newdata; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | sub mean | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | 0 | ▶ | my ($self, $col, $xcol, $begin, $end) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mean: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | 0 | my $count = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | 0 | my $sum = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | 0 | ▶ | defined $self->{sorted_data}->[$xcol] or $self->compute_sorted_index([$xcol]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | 0 | foreach my $a (@{$self->{sorted_data}->[$xcol]}) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | 0 | ▶ | if($a->[$xcol] >= $start) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 0 | ▶ | if($a->[$xcol] <= $end){ $sum += $a->[$col]; ++$count; } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | 0 | else{ last; } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | 0 | ▶ | return $count > 0 ? $sum/$count : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | sub get_sorted_data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_sorted_data: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | 0 | my $x = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | 0 | ▶ | defined $self->{sorted_data}->[$x] or $self->compute_sorted_index([$x]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | 0 | return $self->{sorted_data}->[$x]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | sub columns | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | 15 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
columns: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | 15 | ▶ | return @{$self->{data}} ? $#{$self->{data}[0]}+1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | 7 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||