| 1 |
|
| package Chart::GGPlot::Util::Scales; |
| 2 |
|
| |
| 3 |
|
| # ABSTRACT: R 'scales' package functions used by Chart::GGPlot |
| 4 |
|
| |
| 5 |
|
| # TODO: make a separate library, e.g. Color::Scales for the color palettes. |
| 6 |
|
| # Some of the color palette function's signature may change. |
| 7 |
|
| |
| 8 |
24 |
▶ | use Chart::GGPlot::Setup qw(:base :pdl); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
|
| 9 |
|
| |
| 10 |
24 |
| our $VERSION = '0.002003'; # VERSION |
| 11 |
|
| |
| 12 |
24 |
▶ | use Color::Brewer; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
|
| 13 |
24 |
▶ | use Color::Library; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
|
| 14 |
24 |
▶ | use Convert::Color::LCh; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
|
| 15 |
24 |
▶ | use Data::Munge qw(elem); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
|
| 16 |
24 |
▶ | use Machine::Epsilon qw(machine_epsilon); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
|
| 17 |
24 |
▶ | use Math::Round qw(round); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
|
| 18 |
24 |
▶ | use Memoize; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
|
| 19 |
24 |
▶ | use PDL::Primitive qw(which interpol); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
|
| 20 |
24 |
▶ | use PDL::Graphics::ColorSpace 0.203 qw(rgb_to_lab lab_to_rgb); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
|
| 21 |
24 |
▶ | use Number::Format 1.75; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
|
| 22 |
24 |
▶ | use Scalar::Util qw(looks_like_number); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
|
| 23 |
24 |
▶ | use Time::Moment; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
|
| 24 |
24 |
▶ | use Types::Standard qw(Int); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
|
| 25 |
|
| |
| 26 |
24 |
▶ | use POSIX qw(ceil floor log10); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
|
| 27 |
|
| |
| 28 |
24 |
▶ | use Role::Tiny (); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
|
| 29 |
|
| |
| 30 |
24 |
▶ | use Type::Params; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
|
| 31 |
24 |
▶ | use Types::PDL qw(Piddle Piddle1D PiddleFromAny); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
|
| 32 |
24 |
▶ | use Types::Standard qw(ArrayRef ConsumerOf Num Optional Str Maybe); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
|
| 33 |
|
| |
| 34 |
24 |
▶ | use Chart::GGPlot::Types qw(:all); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
|
| 35 |
24 |
▶ | use Chart::GGPlot::Util::_Base qw(:all); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
|
| 36 |
24 |
▶ | use Chart::GGPlot::Util::_Labeling qw(:all); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
|
| 37 |
24 |
▶ | use Chart::GGPlot::Util::Scales::_Viridis; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
|
| 38 |
|
| |
| 39 |
24 |
▶ | use parent qw(Exporter::Tiny); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
|
| 40 |
|
| |
| 41 |
24 |
| our @EXPORT_OK = qw( |
| 42 |
|
| censor discard expand_range zero_range |
| 43 |
|
| rescale squish |
| 44 |
|
| hue_pal brewer_pal gradient_n_pal rescale_pal viridis_pal |
| 45 |
|
| seq_gradient_pal div_gradient_pal |
| 46 |
|
| area_pal |
| 47 |
|
| identity_pal |
| 48 |
|
| extended_breaks regular_minor_breaks log_breaks |
| 49 |
|
| pretty pretty_breaks |
| 50 |
|
| number comma percent dollar |
| 51 |
|
| rgb255_to_csshex rgb_to_csshex |
| 52 |
|
| csshex_to_rgb255 |
| 53 |
|
| colorname_to_csshex |
| 54 |
|
| ); |
| 55 |
24 |
| our %EXPORT_TAGS = ( all => \@EXPORT_OK ); |
| 56 |
|
| |
| 57 |
|
| |
| 58 |
50 |
▶ | fun censor ( $p, $range = pdl([ 0, 1 ]), $only_finite = true ) { |
|
Subroutine
censor: called CC=6 SCAR=18.0
Pod
documented
Branch: 4 branches
| Branch | True | False | Total |
| @_ < 1 and Function::Parameters::_croak('Too few arguments for fun censor (expected 1, got ' . @_ . ')') |
0 |
50 |
50 |
| @_ > 3 and Function::Parameters::_croak('Too many arguments for fun censor (expected 3, got ' . @_ . ')') |
0 |
50 |
50 |
| @_ < 3 and do {
@_ < 2 and $range = pdl([0, 1]);
$only_finite = &true()
} |
33 |
17 |
50 |
| @_ < 2 and $range = pdl([0, 1]) |
1 |
32 |
33 |
|
| 59 |
50 |
| my ( $min, $max ) = $range->minmax; |
| 60 |
50 |
▶ | my $finite = $only_finite ? $p->isfinite : PDL->ones( $p->length ); |
Branch: 1 branch
| Branch | True | False | Total |
| $only_finite ? : |
33 |
17 |
50 |
|
| 61 |
50 |
| return $p->setbadif( $finite & ( ( $p < $min ) | ( $p > $max ) ) ); |
| 62 |
24 |
| } |
| 63 |
|
| |
| 64 |
|
| |
| 65 |
30 |
▶ | fun discard ( $p, $range = pdl([ 0, 1 ]) ) { |
|
Subroutine
discard: called CC=4 SCAR=14.0
Pod
documented
Branch: 3 branches
| Branch | True | False | Total |
| @_ < 1 and Function::Parameters::_croak('Too few arguments for fun discard (expected 1, got ' . @_ . ')') |
0 |
30 |
30 |
| @_ > 2 and Function::Parameters::_croak('Too many arguments for fun discard (expected 2, got ' . @_ . ')') |
0 |
30 |
30 |
| @_ < 2 and $range = pdl([0, 1]) |
1 |
29 |
30 |
|
| 66 |
30 |
| my ( $min, $max ) = $range->minmax; |
| 67 |
30 |
| return $p->where( ( ( $p >= $min ) & ( $p <= $max ) ) ); |
| 68 |
24 |
| } |
| 69 |
|
| |
| 70 |
|
| # Expand a range with a multiplicative or additive constant |
| 71 |
35 |
▶ | fun expand_range ( $range, $mul = 0, $add = 0, $zero_width = 1 ) { |
|
Subroutine
expand_range: called CC=8 SCAR=23.7
Pod
undocumented
Branch: 5 branches
| Branch | True | False | Total |
| @_ < 1 and Function::Parameters::_croak('Too few arguments for fun expand_range (expected 1, got ' . @_ . ')') |
0 |
35 |
35 |
| @_ > 4 and Function::Parameters::_croak('Too many arguments for fun expand_range (expected 4, got ' . @_ . ')') |
0 |
35 |
35 |
| @_ < 4 and do {
@_ < 3 and do {
@_ < 2 and $mul = 0;
$add = 0
};
$zero_width = 1
} |
35 |
0 |
35 |
| @_ < 3 and do {
@_ < 2 and $mul = 0;
$add = 0
} |
0 |
35 |
35 |
| @_ < 2 and $mul = 0 |
0 |
0 |
0 |
|
| 72 |
35 |
| state $check = |
| 73 |
|
| Type::Params::compile( Piddle->plus_coercions(PiddleFromAny) ); |
| 74 |
35 |
| ($range) = $check->($range); |
| 75 |
|
| |
| 76 |
35 |
▶ | return if ( $range->isempty ); # TODO: return undef or return empty $range? |
Branch: 1 branch
| Branch | True | False | Total |
| if $range->isempty |
0 |
35 |
35 |
|
| 77 |
|
| |
| 78 |
35 |
| my ( $min, $max ) = $range->minmax; |
| 79 |
35 |
▶ | if ( zero_range($range) ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (zero_range($range)) { } |
0 |
35 |
35 |
|
| 80 |
0 |
| return pdl( [ $max - $zero_width / 2, $min + $zero_width / 2 ] ); |
| 81 |
|
| } |
| 82 |
|
| else { |
| 83 |
35 |
| my $delta = ( $max - $min ) * $mul + $add; |
| 84 |
35 |
| return pdl( [ $min - $delta, $max + $delta ] ); |
| 85 |
|
| } |
| 86 |
24 |
| } |
| 87 |
|
| |
| 88 |
|
| |
| 89 |
78 |
▶ | fun zero_range ( $range, $tol = 1000 * machine_epsilon() ) { |
|
Subroutine
zero_range: called CC=4 SCAR=14.2
Pod
documented
Branch: 3 branches
| Branch | True | False | Total |
| @_ < 1 and Function::Parameters::_croak('Too few arguments for fun zero_range (expected 1, got ' . @_ . ')') |
0 |
78 |
78 |
| @_ > 2 and Function::Parameters::_croak('Too many arguments for fun zero_range (expected 2, got ' . @_ . ')') |
0 |
78 |
78 |
| @_ < 2 and $tol = 1000 * machine_epsilon() |
78 |
0 |
78 |
|
| 90 |
|
| state $check = |
| 91 |
78 |
▶ | Type::Params::compile( Piddle1D->where( sub { $_->length == 2 } ) ); |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
|
| 92 |
78 |
| ($range) = $check->($range); |
| 93 |
78 |
| return ( abs( $range->at(1) - $range->at(0) ) < $tol ); |
| 94 |
24 |
| } |
| 95 |
|
| |
| 96 |
|
| |
| 97 |
2 |
▶ | fun squish ( $p, $range = pdl([ 0, 1 ]), $only_finite = true ) { |
|
Subroutine
squish: called CC=6 SCAR=18.4
Pod
documented
Branch: 4 branches
| Branch | True | False | Total |
| @_ < 1 and Function::Parameters::_croak('Too few arguments for fun squish (expected 1, got ' . @_ . ')') |
0 |
2 |
2 |
| @_ > 3 and Function::Parameters::_croak('Too many arguments for fun squish (expected 3, got ' . @_ . ')') |
0 |
2 |
2 |
| @_ < 3 and do {
@_ < 2 and $range = pdl([0, 1]);
$only_finite = &true()
} |
2 |
0 |
2 |
| @_ < 2 and $range = pdl([0, 1]) |
1 |
1 |
2 |
|
| 98 |
2 |
| my ( $min, $max ) = $range->minmax; |
| 99 |
2 |
▶ | my $finite = $only_finite ? $p->isfinite : PDL->ones( $p->length ); |
Branch: 1 branch
| Branch | True | False | Total |
| $only_finite ? : |
2 |
0 |
2 |
|
| 100 |
2 |
| my $r = $p->copy; |
| 101 |
|
| |
| 102 |
2 |
| $r->where( ( $finite & ( $r < $min ) ) ) .= $min; |
| 103 |
2 |
| $r->where( ( $finite & ( $r > $max ) ) ) .= $max; |
| 104 |
2 |
| return $r; |
| 105 |
24 |
| } |
| 106 |
|
| |
| 107 |
|
| ## scale |
| 108 |
|
| |
| 109 |
|
| # Rescale range to have specified minimum and maximum |
| 110 |
28 |
▶ | fun rescale ( $p, $to = pdl([0, 1]), $from = range_($p) ) { |
|
Subroutine
rescale: called CC=6 SCAR=18.4
Pod
undocumented
Branch: 4 branches
| Branch | True | False | Total |
| @_ < 1 and Function::Parameters::_croak('Too few arguments for fun rescale (expected 1, got ' . @_ . ')') |
0 |
28 |
28 |
| @_ > 3 and Function::Parameters::_croak('Too many arguments for fun rescale (expected 3, got ' . @_ . ')') |
0 |
28 |
28 |
| @_ < 3 and do {
@_ < 2 and $to = pdl([0, 1]);
$from = range_($p)
} |
3 |
25 |
28 |
| @_ < 2 and $to = pdl([0, 1]) |
2 |
1 |
3 |
|
| 111 |
28 |
| my $from_diff = $from->at(1) - $from->at(0); |
| 112 |
28 |
| my $to_diff = $to->at(1) - $to->at(0); |
| 113 |
28 |
▶ | if ($from_diff == 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ($from_diff == 0) |
0 |
28 |
28 |
|
| 114 |
0 |
| return pdl([($to->at(0) + $to_diff/2) x $p->length]); |
| 115 |
|
| } |
| 116 |
28 |
| my $slope = $to_diff / $from_diff; |
| 117 |
28 |
| return ( $p - $from->at(0) ) * $slope + $to->at(0); |
| 118 |
24 |
| } |
| 119 |
|
| |
| 120 |
|
| ## palette |
| 121 |
|
| |
| 122 |
24 |
| my %brewer = ( |
| 123 |
|
| div => [ |
| 124 |
|
| "BrBG", "PiYG", "PRGn", "PuOr", "RdBu", "RdGy", |
| 125 |
|
| "RdYlBu", "RdYlGn", "Spectral" |
| 126 |
|
| ], |
| 127 |
|
| qual => [ |
| 128 |
|
| "Accent", "Dark2", "Paired", "Pastel1", |
| 129 |
|
| "Pastel2", "Set1", "Set2", "Set3" |
| 130 |
|
| ], |
| 131 |
|
| seq => [ |
| 132 |
|
| "Blues", "BuGn", "BuPu", "GnBu", "Greens", "Greys", |
| 133 |
|
| "Oranges", "OrRd", "PuBu", "PuBuGn", "PuRd", "Purples", |
| 134 |
|
| "RdPu", "Reds", "YlGn", "YlGnBu", "YlOrBr", "YlOrRd" |
| 135 |
|
| ], |
| 136 |
|
| ); |
| 137 |
|
| |
| 138 |
24 |
| my %pal_names = map { $_ => 1 } map { @$_ } values %brewer; |
| 139 |
|
| |
| 140 |
1 |
▶ | fun _pal_name ( $palette, $type ) { |
|
Subroutine
_pal_name: called CC=5 SCAR=18.9
Branch: 2 branches
| Branch | True | False | Total |
| @_ < 2 and Function::Parameters::_croak('Too few arguments for fun _pal_name (expected 2, got ' . @_ . ')') |
0 |
1 |
1 |
| @_ > 2 and Function::Parameters::_croak('Too many arguments for fun _pal_name (expected 2, got ' . @_ . ')') |
0 |
1 |
1 |
|
| 141 |
1 |
▶ | if ( !looks_like_number($palette) ) { |
Branch: 1 branch
| Branch | True | False | Total |
| unless (&looks_like_number($palette)) |
0 |
1 |
1 |
|
| 142 |
0 |
▶ | return exists( $pal_names{$palette} ) ? $palette : 'Greens'; |
Branch: 1 branch
| Branch | True | False | Total |
| exists $pal_names{$palette} ? : |
0 |
0 |
0 |
|
| 143 |
|
| } |
| 144 |
1 |
| return $brewer{$type}[$palette]; |
| 145 |
24 |
| } |
| 146 |
|
| |
| 147 |
|
| |
| 148 |
|
| # This method would result color slightly different from R's equivalent |
| 149 |
|
| # method, maybe it's because Convert::Color::LCh does rounding in a |
| 150 |
|
| # different way from R's grDevices::hcl(). But it's fine as the |
| 151 |
|
| # difference in result color channel is at max just 1/256. |
| 152 |
31 |
▶ | fun hcl ($h, $c, $l) { |
|
Subroutine
hcl: called CC=3 SCAR=11.2
Pod
undocumented
Branch: 2 branches
| Branch | True | False | Total |
| @_ < 3 and Function::Parameters::_croak('Too few arguments for fun hcl (expected 3, got ' . @_ . ')') |
0 |
31 |
31 |
| @_ > 3 and Function::Parameters::_croak('Too many arguments for fun hcl (expected 3, got ' . @_ . ')') |
0 |
31 |
31 |
|
| 153 |
31 |
| my $c = Convert::Color::LCh->new( $l, $c, $h ); |
| 154 |
31 |
| return rgb_to_csshex($c->rgb); |
| 155 |
24 |
| } |
| 156 |
|
| |
| 157 |
5 |
▶ | fun hue_pal (:$h=pdl([0, 360])+15, :$c=100, :$l=65, :$h_start=0, :$direction=1) { |
|
Subroutine
hue_pal: called CC=9 SCAR=22.2
Pod
documented
Branch: 7 branches
| Branch | True | False | Total |
| @_ > 0 and @_ % 2 and Function::Parameters::_croak("Odd number of paired arguments for fun hue_pal") |
0 |
5 |
5 |
| exists ${__rest}{'h'} ? : |
3 |
2 |
5 |
| exists ${__rest}{'c'} ? : |
2 |
3 |
5 |
| exists ${__rest}{'l'} ? : |
3 |
2 |
5 |
| exists ${__rest}{'h_start'} ? : |
2 |
3 |
5 |
| exists ${__rest}{'direction'} ? : |
2 |
3 |
5 |
| keys %{__rest} and Function::Parameters::_croak('In fun hue_pal: no such named parameter: ' . join(", ", sort(keys %{__rest}))) |
0 |
5 |
5 |
MC/DC0%0/2
@_ > 0 and @_ % 2
@_ > 0
@_ % 2
Truth table66%2/3
A and B
A= @_ > 0B= @_ % 2
|
| 158 |
|
| my $check = |
| 159 |
9 |
▶ | Type::Params::compile( Piddle1D->where( sub { $_->length == 2 } ) |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
|
| 160 |
5 |
| ->plus_coercions(PiddleFromAny) ); |
| 161 |
5 |
| ($h) = $check->($h); |
| 162 |
|
| |
| 163 |
6 |
▶ | return fun(Int $n) { |
|
Subroutine
__ANON__: called CC=6 SCAR=18.4
Branch: 3 branches
| Branch | True | False | Total |
| @_ < 1 and Function::Parameters::_croak('Too few arguments for fun (anon) (expected 1, got ' . @_ . ')') |
0 |
6 |
6 |
| @_ > 1 and Function::Parameters::_croak('Too many arguments for fun (anon) (expected 1, got ' . @_ . ')') |
0 |
6 |
6 |
| Type::Tiny::XS::Int($n) or Function::Parameters::_croak('In fun (anon): parameter 1 ($n): ' . ${my $v = bless( {"_is_core" => 1,"_overload_coderef" => sub { package Type::Tiny; BEGIN {${^WARNING_BITS} = "\x10\x01\x00\x00\x00\x50\x04\x00\x00\x00\x00\x00\x01\x40\x05\x45\x55\x15\x55\x55\x01\x00\x00"} use strict; Type::Tiny::XS::Int($_[0]) or _failed_check(13, 'Int', $_[0], 'exception_class', 'Error::TypeTiny::Assertion'); $_[0];},"_overrides_assert_return" => !!0,"coercion" => bless( {"_compiled_type_constraint_check" => sub ;,"display_name" => "to_Int","frozen" => 1,"name" => "__ANON__","type_coercion_map" => [],"type_constraint" => {}}, 'Type::Coercion' ),"compiled_type_constraint" => do{my $o},"constraint" => sub { package Types::Standard; no warnings; use strict; /\A-?[0-9]+\z/;},"definition_context" => {"file" => "/usr/local/lib/perl5/site_perl/5.44.0/Types/Standard.pm","line" => 361,"package" => "Types::Standard"},"deprecated" => !!0,"display_name" => "Int","exception_class" => "Error::TypeTiny::Assertion","inlined" => sub { package Types::Standard; use warnings; use strict; $Type::Tiny::AvoidCallbacks ? goto $orig_inlined : "$xsubname($_[1])";},"library" => "Types::Standard","name" => "Int","parent" => bless( {"_overload_coderef" => sub { package Type::Tiny; BEGIN {${^WARNING_BITS} = "\x10\x01\x00\x00\x00\x50\x04\x00\x00\x00\x00\x00\x01\x40\x05\x45\x55\x15\x55\x55\x01\x00\x00"} use strict; defined $_[0] and not ref $_[0] and &Scalar::Util::looks_like_number($_[0]) or _failed_check(12, 'Num', $_[0], 'exception_class', 'Error::TypeTiny::Assertion'); $_[0];},"_overrides_assert_return" => !!0,"coercion" => bless( {"_compiled_type_constraint_check" => sub ($) { package Eval::TypeTiny::Sandbox; use strict; defined $_[0] and not ref $_[0] and &Scalar::Util::looks_like_number($_[0]);},"display_name" => "to_Num","frozen" => 1,"name" => "__ANON__","type_coercion_map" => [],"type_constraint" => {}}, 'Type::Coercion' ),"compiled_type_constraint" => do{my $o},"constraint" => sub { package Type::Tiny; use warnings; use strict; !0;},"definition_context" => {"file" => "/usr/local/lib/perl5/site_perl/5.44.0/Types/Standard.pm","line" => 344,"package" => "Types::Standard"},"deprecated" => !!0,"display_name" => "Num","exception_class" => "Error::TypeTiny::Assertion","library" => "Types::Standard","moose_type" => bless( {"Types::TypeTiny::to_TypeTiny" => {},"_default_message" => sub { package Moose::Meta::TypeConstraint; use warnings; use strict; my $value = shift(); my $can_partialdump = &try(sub { require Devel::PartialDump; 'Devel::PartialDump'->VERSION(0.14); 1; } ); if ($can_partialdump) { $value = 'Devel::PartialDump'->new->dump($value); } else { $value = defined $value ? overload::StrVal($value) : 'undef'; } return q[Validation failed for '] . $name . "' with value $value";},"compiled_type_constraint" => sub { package Eval::Closure::Sandbox_184; use warnings; use strict; do { defined $_[0] and not ref $_[0] and &Scalar::Util::looks_like_number($_[0]) };},"constraint" => sub { package Moose::Meta::TypeConstraint; use warnings; use strict; 1;},"inline_environment" => {},"name" => "Types::Standard::Num","parent" => bless( {"Types::TypeTiny::to_TypeTiny" => bless( {"_overload_coderef" => sub { package Type::Tiny; BEGIN {${^WARNING_BITS} = "\x10\x01\x00\x00\x00\x50\x04\x00\x00\x00\x00\x00\x01\x40\x05\x45\x55\x15\x55\x55\x01\x00\x00"} use strict; defined $_[0] and not ref $_[0] and &Scalar::Util::looks_like_number($_[0]) or _failed_check(10, 'LaxNum', $_[0], 'exception_class', 'Error::TypeTiny::Assertion'); $_[0];},"_overrides_assert_return" => !!0,"coercion" => bless( {"_compiled_type_constraint_check" => do{my $o},"display_name" => "to_LaxNum","frozen" => 1,"name" => "__ANON__","type_coercion_map" => [],"type_constraint" => {}}, 'Type::Coercion' ),"compiled_type_constraint" => do{my $o},"constraint" => sub { package Types::Standard; no warnings; use strict; looks_like_number $_ and ref \$_ ne 'GLOB';},"definition_context" => {"file" => "/usr/local/lib/perl5/site_perl/5.44.0/Types/Standard.pm","line" => 309,"package" => "Types::Standard"},"deprecated" => !!0,"display_name" => "LaxNum","exception_class" => "Error::TypeTiny::Assertion","inlined" => sub { package Types::Standard; no warnings; use strict; &$maybe_load_modules('Scalar::Util', 'Scalar::Util'->VERSION ge '1.18' ? "defined($_[1]) && !ref($_[1]) && Scalar::Util::looks_like_number($_[1])" : "defined($_[1]) && !ref($_[1]) && Scalar::Util::looks_like_number($_[1]) && ref(\\($_[1])) ne 'GLOB'");},"library" => "Types::Standard","moose_type" => {},"name" => "LaxNum","parent" => bless( {"_is_core" => 1,"_overload_coderef" => sub { package Type::Tiny; BEGIN {${^WARNING_BITS} = "\x10\x01\x00\x00\x00\x50\x04\x00\x00\x00\x00\x00\x01\x40\x05\x45\x55\x15\x55\x55\x01\x00\x00"} use strict; Type::Tiny::XS::Str($_[0]) or _failed_check(9, 'Str', $_[0], 'exception_class', 'Error::TypeTiny::Assertion'); $_[0];},"_overrides_assert_return" => !!0,"coercion" => bless( {"_compiled_type_constraint_check" => sub ;,"display_name" => "to_Str","frozen" => 1,"name" => "__ANON__","type_coercion_map" => [],"type_constraint" => {}}, 'Type::Coercion' ),"compiled_type_constraint" => do{my $o},"constraint" => sub { package Types::Standard; no warnings; use strict; ref \$_ eq 'SCALAR' or ref \(my $val = $_) eq 'SCALAR';},"definition_context" => {"file" => "/usr/local/lib/perl5/site_perl/5.44.0/Types/Standard.pm","line" => 291,"package" => "Types::Standard"},"deprecated" => !!0,"display_name" => "Str","exception_class" => "Error::TypeTiny::Assertion","inlined" => sub { package Types::Standard; use warnings; use strict; $Type::Tiny::AvoidCallbacks ? goto $orig_inlined : "$xsubname($_[1])";},"library" => "Types::Standard","moose_type" => bless( {"Types::TypeTiny::to_TypeTiny" => {},"_default_message" => sub { package Moose::Meta::TypeConstraint; use warnings; use strict; my $value = shift(); my $can_partialdump = &try(sub { require Devel::PartialDump; 'Devel::PartialDump'->VERSION(0.14); 1; } ); if ($can_partialdump) { $value = 'Devel::PartialDump'->new->dump($value); } else { $value = defined $value ? overload::StrVal($value) : 'undef'; } return q[Validation failed for '] . $name . "' with value $value";},"compiled_type_constraint" => sub { package Eval::Closure::Sandbox_51; use warnings; use strict; do { do { do { defined $_[0] } and not ref $_[0] } and ref \$_[0] eq 'SCALAR' || ref \(my $val = $_[0]) eq 'SCALAR' };},"constraint" => sub { package Moose::Util::TypeConstraints::Builtins; use warnings; use strict; ref \$_ eq 'SCALAR' or ref \(my $val = $_) eq 'SCALAR';},"inline_environment" => {},"inlined" => sub { package Moose::Util::TypeConstraints::Builtins; use warnings; use strict; $_[0]->parent->_inline_check($_[1]) . ' && (' . 'ref(\\' . $_[1] . ') eq "SCALAR"' . ' || ref(\\(my $val = ' . $_[1] . ')) eq "SCALAR"' . ')';},"name" => "Str","package_defined_in" => "Moose::Util::TypeConstraints::Builtins","parent" => bless( {"_default_message" => sub { package Moose::Meta::TypeConstraint; use warnings; use strict; my $value = shift(); my $can_partialdump = &try(sub { require Devel::PartialDump; 'Devel::PartialDump'->VERSION(0.14); 1; } ); if ($can_partialdump) { $value = 'Devel::PartialDump'->new->dump($value); } else { $value = defined $value ? overload::StrVal($value) : 'undef'; } return q[Validation failed for '] . $name . "' with value $value";},"compiled_type_constraint" => sub { package Eval::Closure::Sandbox_49; use warnings; use strict; do { do { defined $_[0] } and not ref $_[0] };},"constraint" => sub { package Moose::Util::TypeConstraints::Builtins; use warnings; use strict; not ref $_;},"inline_environment" => {},"inlined" => sub { package Moose::Util::TypeConstraints::Builtins; use warnings; use strict; $_[0]->parent->_inline_check($_[1]) . ' && !ref(' . $_[1] . ')';},"name" => "Value","package_defined_in" => "Moose::Util::TypeConstraints::Builtins","parent" => bless( {"Types::TypeTiny::to_TypeTiny" => bless( {"_is_core" => 1,"_overload_coderef" => sub { package Type::Tiny; BEGIN {${^WARNING_BITS} = "\x10\x01\x00\x00\x00\x50\x04\x00\x00\x00\x00\x00\x01\x40\x05\x45\x55\x15\x55\x55\x01\x00\x00"} use strict; defined $_[0] or _failed_check(7, 'Defined', $_[0], 'exception_class', 'Error::TypeTiny::Assertion'); $_[0];},"_overrides_assert_return" => !!0,"coercion" => bless( {"_compiled_type_constraint_check" => sub ;,"display_name" => "to_Defined","frozen" => 1,"name" => "__ANON__","type_coercion_map" => [],"type_constraint" => {}}, 'Type::Coercion' ),"compiled_type_constraint" => do{my $o},"complementary_type" => bless( {"_is_core" => 1,"_overload_coderef" => sub { package Type::Tiny; BEGIN {${^WARNING_BITS} = "\x10\x01\x00\x00\x00\x50\x04\x00\x00\x00\x00\x00\x01\x40\x05\x45\x55\x15\x55\x55\x01\x00\x00"} use strict; defined $_[0] and _failed_check(6, 'Undef', $_[0], 'exception_class', 'Error::TypeTiny::Assertion'); $_[0];},"_overrides_assert_return" => !!0,"coercion" => bless( {"_compiled_type_constraint_check" => sub ;,"display_name" => "to_Undef","frozen" => 1,"name" => "__ANON__","type_coercion_map" => [],"type_constraint" => {}}, 'Type::Coercion' ),"compiled_type_constraint" => do{my $o},"complementary_type" => {},"constraint" => sub { package Types::Standard; no warnings; use strict; not defined $_;},"definition_context" => {"file" => "/usr/local/lib/perl5/site_perl/5.44.0/Types/Standard.pm","line" => 254,"package" => "Types::Standard"},"deprecated" => !!0,"display_name" => "Undef","exception_class" => "Error::TypeTiny::Assertion","inlined" => sub { package Types::Standard; no warnings; use strict; "!defined($_[1])";},"library" => "Types::Standard","name" => "Undef","parent" => bless( {"_is_core" => 1,"_overload_coderef" => sub { package Type::Tiny; BEGIN {${^WARNING_BITS} = "\x10\x01\x00\x00\x00\x50\x04\x00\x00\x00\x00\x00\x01\x40\x05\x45\x55\x15\x55\x55\x01\x00\x00"} use strict; '???'; $_[0];},"_overrides_assert_return" => !!0,"coercion" => bless( {"_compiled_type_constraint_check" => sub ;,"display_name" => "to_Item","frozen" => 1,"name" => "__ANON__","type_coercion_map" => [],"type_constraint" => {}}, 'Type::Coercion' ),"compiled_type_constraint" => do{my $o},"constraint" => do{my $o},"definition_context" => {"file" => "/usr/local/lib/perl5/site_perl/5.44.0/Types/Standard.pm","line" => 226,"package" => "Types::Standard"},"deprecated" => !!0,"display_name" => "Item","exception_class" => "Error::TypeTiny::Assertion","inlined" => sub { package Types::Standard; no warnings; use strict; '!!1';},"library" => "Types::Standard","name" => "Item","parent" => bless( {"_is_core" => 1,"_overload_coderef" => sub { package Type::Tiny; BEGIN {${^WARNING_BITS} = "\x10\x01\x00\x00\x00\x50\x04\x00\x00\x00\x00\x00\x01\x40\x05\x45\x55\x15\x55\x55\x01\x00\x00"} use strict; '???'; $_[0];},"_overrides_assert_return" => !!0,"coercion" => bless( {"_compiled_type_constraint_check" => do{my $o},"display_name" => "to_Any","frozen" => 1,"name" => "__ANON__","type_coercion_map" => [],"type_constraint" => {}}, 'Type::Coercion' ),"compiled_type_constraint" => do{my $o},"complement_name" => "None","constraint" => do{my $o},"definition_context" => {"file" => "/usr/local/lib/perl5/site_perl/5.44.0/Types/Standard.pm","line" => 220,"package" => "Types::Standard"},"deprecated" => !!0,"display_name" => "Any","exception_class" => "Error::TypeTiny::Assertion","inlined" => sub { package Types::Standard; no warnings; use strict; '!!1';},"library" => "Types::Standard","moose_type" => bless( {"Types::TypeTiny::to_TypeTiny" => {},"_default_message" => sub { package Moose::Meta::TypeConstraint; use warnings; use strict; my $value = shift(); my $can_partialdump = &try(sub { require Devel::PartialDump; 'Devel::PartialDump'->VERSION(0.14); 1; } ); if ($can_partialdump) { $value = 'Devel::PartialDump'->new->dump($value); } else { $value = defined $value ? overload::StrVal($value) : 'undef'; } return q[Validation failed for '] . $name . "' with value $value";},"compiled_type_constraint" => sub { package Eval::Closure::Sandbox_44; use warnings; use strict; do { 1 };},"constraint" => sub { package Moose::Util::TypeConstraints::Builtins; use warnings; use strict; 1;},"inline_environment" => {},"inlined" => sub { package Moose::Util::TypeConstraints::Builtins; use warnings; use strict; '1';},"name" => "Any","package_defined_in" => "Moose::Util::TypeConstraints::Builtins"}, 'Moose::Meta::TypeConstraint' ),"name" => "Any","type_default" => sub { package Types::Standard; no warnings; use strict; return undef;},"uniq" => 1}, 'Type::Tiny' ),"uniq" => 2}, 'Type::Tiny' ),"type_default" => sub { package Types::Standard; no warnings; use strict; return undef;},"uniq" => 6}, 'Type::Tiny' ),"constraint" => sub { package Types::Standard; no warnings; use strict; defined $_;},"definition_context" => {"file" => "/usr/local/lib/perl5/site_perl/5.44.0/Types/Standard.pm","line" => 262,"package" => "Types::Standard"},"deprecated" => !!0,"display_name" => "Defined","exception_class" => "Error::TypeTiny::Assertion","inlined" => sub { package Types::Standard; no warnings; use strict; "defined($_[1])";},"library" => "Types::Standard","moose_type" => {},"name" => "Defined","parent" => {},"uniq" => 7}, 'Type::Tiny' ),"_default_message" => sub { package Moose::Meta::TypeConstraint; use warnings; use strict; my $value = shift(); my $can_partialdump = &try(sub { require Devel::PartialDump; 'Devel::PartialDump'->VERSION(0.14); 1; } ); if ($can_partialdump) { $value = 'Devel::PartialDump'->new->dump($value); } else { $value = defined $value ? overload::StrVal($value) : 'undef'; } return q[Validation failed for '] . $name . "' with value $value";},"compiled_type_constraint" => sub { package Eval::Closure::Sandbox_47; use warnings; use strict; do { defined $_[0] };},"constraint" => sub { package Moose::Util::TypeConstraints::Builtins; use warnings; use strict; defined $_;},"inline_environment" => {},"inlined" => sub { package Moose::Util::TypeConstraints::Builtins; use warnings; use strict; 'defined(' . $_[1] . ')';},"name" => "Defined","package_defined_in" => "Moose::Util::TypeConstraints::Builtins","parent" => bless( {"_default_message" => sub { package Moose::Meta::TypeConstraint; use warnings; use strict; my $value = shift(); my $can_partialdump = &try(sub { require Devel::PartialDump; 'Devel::PartialDump'->VERSION(0.14); 1; } ); if ($can_partialdump) { $value = 'Devel::PartialDump'->new->dump($value); } else { $value = defined $value ? overload::StrVal($value) : 'undef'; } return q[Validation failed for '] . $name . "' with value $value";},"compiled_type_constraint" => sub { package Eval::Closure::Sandbox_45; use warnings; use strict; do { 1 };},"constraint" => do{my $o},"inline_environment" => {},"inlined" => sub { package Moose::Util::TypeConstraints::Builtins; use warnings; use strict; '1';},"name" => "Item","package_defined_in" => "Moose::Util::TypeConstraints::Builtins","parent" => {}}, 'Moose::Meta::TypeConstraint' )}, 'Moose::Meta::TypeConstraint' )}, 'Moose::Meta::TypeConstraint' )}, 'Moose::Meta::TypeConstraint' ),"name" => "Str","parent" => bless( {"_is_core" => 1,"_overload_coderef" => sub { package Type::Tiny; BEGIN {${^WARNING_BITS} = "\x10\x01\x00\x00\x00\x50\x04\x00\x00\x00\x00\x00\x01\x40\x05\x45\x55\x15\x55\x55\x01\x00\x00"} use strict; defined $_[0] and not ref $_[0] or _failed_check(8, 'Value', $_[0], 'exception_class', 'Error::TypeTiny::Assertion'); $_[0];},"_overrides_assert_return" => !!0,"coercion" => bless( {"_compiled_type_constraint_check" => sub ;,"display_name" => "to_Value","frozen" => 1,"name" => "__ANON__","type_coercion_map" => [],"type_constraint" => {}}, 'Type::Coercion' ),"compiled_type_constraint" => do{my $o},"constraint" => sub { package Types::Standard; no warnings; use strict; not ref $_;},"definition_context" => {"file" => "/usr/local/lib/perl5/site_perl/5.44.0/Types/Standard.pm","line" => 276,"package" => "Types::Standard"},"deprecated" => !!0,"display_name" => "Value","exception_class" => "Error::TypeTiny::Assertion","inlined" => sub { package Types::Standard; no warnings; use strict; "defined($_[1]) and not ref($_[1])";},"library" => "Types::Standard","name" => "Value","parent" => {},"uniq" => 8}, 'Type::Tiny' ),"sorter" => sub { package Types::Standard; no warnings; use strict; $_[0] cmp $_[1];},"type_default" => sub { package Types::Standard; no warnings; use strict; return '';},"uniq" => 9}, 'Type::Tiny' ),"sorter" => sub { package Types::Standard; no warnings; use strict; $_[0] <=> $_[1];},"type_default" => sub { package Types::Standard; no warnings; use strict; return 0;},"uniq" => 10}, 'Type::Tiny' ),"_default_message" => sub { package Moose::Meta::TypeConstraint; use warnings; use strict; my $value = shift(); my $can_partialdump = &try(sub { require Devel::PartialDump; 'Devel::PartialDump'->VERSION(0.14); 1; } ); if ($can_partialdump) { $value = 'Devel::PartialDump'->new->dump($value); } else { $value = defined $value ? overload::StrVal($value) : 'undef'; } return q[Validation failed for '] . $name . "' with value $value";},"compiled_type_constraint" => sub { package Eval::Closure::Sandbox_183; use warnings; use strict; do { defined $_[0] and not ref $_[0] and &Scalar::Util::looks_like_number($_[0]) };},"constraint" => do{my $o},"inline_environment" => {},"inlined" => sub { package Type::Tiny; use warnings; use strict; shift(); $self->inline_check(@_);},"name" => "Types::Standard::LaxNum","parent" => {}}, 'Moose::Meta::TypeConstraint' )}, 'Moose::Meta::TypeConstraint' ),"name" => "Num","parent" => {},"uniq" => 12}, 'Type::Tiny' ),"type_default" => sub { package Types::Standard; no warnings; use strict; return 0;},"uniq" => 13}, 'Type::Tiny' );$v->{"coercion"}{"type_constraint"} = $v;$v->{"compiled_type_constraint"} = $v->{"coercion"}{"_compiled_type_constraint_check"};$v->{"parent"}{"coercion"}{"type_constraint"} = $v->{"parent"};$v->{"parent"}{"compiled_type_constraint"} = $v->{"parent"}{"coercion"}{"_compiled_type_constraint_check"};$v->{"parent"}{"moose_type"}{"Types::TypeTiny::to_TypeTiny"} = $v->{"parent"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"coercion"}{"_compiled_type_constraint_check"} = $v->{"parent"}{"coercion"}{"_compiled_type_constraint_check"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"coercion"}{"type_constraint"} = $v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"compiled_type_constraint"} = $v->{"parent"}{"coercion"}{"_compiled_type_constraint_check"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"moose_type"} = $v->{"parent"}{"moose_type"}{"parent"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"coercion"}{"type_constraint"} = $v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"compiled_type_constraint"} = $v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"coercion"}{"_compiled_type_constraint_check"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"Types::TypeTiny::to_TypeTiny"} = $v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"coercion"}{"type_constraint"} = $v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"compiled_type_constraint"} = $v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"coercion"}{"_compiled_type_constraint_check"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"complementary_type"}{"coercion"}{"type_constraint"} = $v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"complementary_type"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"complementary_type"}{"compiled_type_constraint"} = $v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"complementary_type"}{"coercion"}{"_compiled_type_constraint_check"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"complementary_type"}{"complementary_type"} = $v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"complementary_type"}{"parent"}{"coercion"}{"type_constraint"} = $v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"complementary_type"}{"parent"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"complementary_type"}{"parent"}{"compiled_type_constraint"} = $v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"complementary_type"}{"parent"}{"coercion"}{"_compiled_type_constraint_check"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"complementary_type"}{"parent"}{"constraint"} = $v->{"parent"}{"constraint"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"complementary_type"}{"parent"}{"parent"}{"coercion"}{"_compiled_type_constraint_check"} = $v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"complementary_type"}{"parent"}{"coercion"}{"_compiled_type_constraint_check"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"complementary_type"}{"parent"}{"parent"}{"coercion"}{"type_constraint"} = $v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"complementary_type"}{"parent"}{"parent"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"complementary_type"}{"parent"}{"parent"}{"compiled_type_constraint"} = $v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"complementary_type"}{"parent"}{"coercion"}{"_compiled_type_constraint_check"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"complementary_type"}{"parent"}{"parent"}{"constraint"} = $v->{"parent"}{"constraint"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"complementary_type"}{"parent"}{"parent"}{"moose_type"}{"Types::TypeTiny::to_TypeTiny"} = $v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"complementary_type"}{"parent"}{"parent"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"moose_type"} = $v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"} = $v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"complementary_type"}{"parent"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"parent"}{"constraint"} = $v->{"parent"}{"moose_type"}{"constraint"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"parent"}{"parent"} = $v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"complementary_type"}{"parent"}{"parent"}{"moose_type"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"parent"}{"coercion"}{"type_constraint"} = $v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"parent"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"parent"}{"compiled_type_constraint"} = $v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"parent"}{"coercion"}{"_compiled_type_constraint_check"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"parent"}{"parent"} = $v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"};$v->{"parent"}{"moose_type"}{"parent"}{"constraint"} = $v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"constraint"};$v->{"parent"}{"moose_type"}{"parent"}{"parent"} = $v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"};$v->{"parent"}{"parent"} = $v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}; \$v}->get_message($n)) |
6 |
0 |
6 |
|
| 164 |
6 |
▶ | if ( $n == 0 ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ($n == 0) |
0 |
6 |
6 |
|
| 165 |
0 |
| die "Must request at least one color from a hue palette."; |
| 166 |
|
| } |
| 167 |
|
| |
| 168 |
6 |
| my $h_tmp = $h->copy; |
| 169 |
6 |
▶ | if ( ( $h_tmp->at(1) - $h_tmp->at(0) ) % 360 < 1 ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (($h_tmp->at(1) - $h_tmp->at(0)) % 360 < 1) |
5 |
1 |
6 |
|
| 170 |
5 |
| $h_tmp = pdl( [ $h_tmp->at(0), $h_tmp->at(1) - 360 / $n ] ); |
| 171 |
|
| } |
| 172 |
6 |
▶ | my $rotate = sub { ( ( $_[0] + $h_start ) % 360 ) * $direction }; |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
|
| 173 |
6 |
| my $hues = $rotate->( pdl( seq_n( $h_tmp->list, $n ) ) ); |
| 174 |
|
| return PDL::SV->new( |
| 175 |
6 |
▶ | $hues->unpdl->map( sub { hcl( $_, $c, $l ); } ) ); |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
|
| 176 |
5 |
| }; |
| 177 |
24 |
| } |
| 178 |
|
| |
| 179 |
1 |
▶ | fun brewer_pal ( $type, $palette = 0, $direction = 1 ) { |
|
Subroutine
brewer_pal: called CC=5 SCAR=17.3
Pod
undocumented
Branch: 4 branches
| Branch | True | False | Total |
| @_ < 1 and Function::Parameters::_croak('Too few arguments for fun brewer_pal (expected 1, got ' . @_ . ')') |
0 |
1 |
1 |
| @_ > 3 and Function::Parameters::_croak('Too many arguments for fun brewer_pal (expected 3, got ' . @_ . ')') |
0 |
1 |
1 |
| @_ < 3 and do {
@_ < 2 and $palette = 0;
$direction = 1
} |
0 |
1 |
1 |
| @_ < 2 and $palette = 0 |
0 |
0 |
0 |
|
| 180 |
1 |
| my $pal_name = _pal_name( $palette, $type ); |
| 181 |
|
| |
| 182 |
|
| # $n is number of colors |
| 183 |
3 |
▶ | return fun(Int $n) { |
|
Subroutine
__ANON__: called CC=5 SCAR=16.8
Branch: 3 branches
| Branch | True | False | Total |
| @_ < 1 and Function::Parameters::_croak('Too few arguments for fun (anon) (expected 1, got ' . @_ . ')') |
0 |
3 |
3 |
| @_ > 1 and Function::Parameters::_croak('Too many arguments for fun (anon) (expected 1, got ' . @_ . ')') |
0 |
3 |
3 |
| Type::Tiny::XS::Int($n) or Function::Parameters::_croak('In fun (anon): parameter 1 ($n): ' . ${my $v = bless( {"_is_core" => 1,"_overload_coderef" => sub { package Type::Tiny; BEGIN {${^WARNING_BITS} = "\x10\x01\x00\x00\x00\x50\x04\x00\x00\x00\x00\x00\x01\x40\x05\x45\x55\x15\x55\x55\x01\x00\x00"} use strict; Type::Tiny::XS::Int($_[0]) or _failed_check(13, 'Int', $_[0], 'exception_class', 'Error::TypeTiny::Assertion'); $_[0];},"_overrides_assert_return" => !!0,"coercion" => bless( {"_compiled_type_constraint_check" => sub ;,"display_name" => "to_Int","frozen" => 1,"name" => "__ANON__","type_coercion_map" => [],"type_constraint" => {}}, 'Type::Coercion' ),"compiled_type_constraint" => do{my $o},"constraint" => sub { package Types::Standard; no warnings; use strict; /\A-?[0-9]+\z/;},"definition_context" => {"file" => "/usr/local/lib/perl5/site_perl/5.44.0/Types/Standard.pm","line" => 361,"package" => "Types::Standard"},"deprecated" => !!0,"display_name" => "Int","exception_class" => "Error::TypeTiny::Assertion","inlined" => sub { package Types::Standard; use warnings; use strict; $Type::Tiny::AvoidCallbacks ? goto $orig_inlined : "$xsubname($_[1])";},"library" => "Types::Standard","name" => "Int","parent" => bless( {"_overload_coderef" => sub { package Type::Tiny; BEGIN {${^WARNING_BITS} = "\x10\x01\x00\x00\x00\x50\x04\x00\x00\x00\x00\x00\x01\x40\x05\x45\x55\x15\x55\x55\x01\x00\x00"} use strict; defined $_[0] and not ref $_[0] and &Scalar::Util::looks_like_number($_[0]) or _failed_check(12, 'Num', $_[0], 'exception_class', 'Error::TypeTiny::Assertion'); $_[0];},"_overrides_assert_return" => !!0,"coercion" => bless( {"_compiled_type_constraint_check" => sub ($) { package Eval::TypeTiny::Sandbox; use strict; defined $_[0] and not ref $_[0] and &Scalar::Util::looks_like_number($_[0]);},"display_name" => "to_Num","frozen" => 1,"name" => "__ANON__","type_coercion_map" => [],"type_constraint" => {}}, 'Type::Coercion' ),"compiled_type_constraint" => do{my $o},"constraint" => sub { package Type::Tiny; use warnings; use strict; !0;},"definition_context" => {"file" => "/usr/local/lib/perl5/site_perl/5.44.0/Types/Standard.pm","line" => 344,"package" => "Types::Standard"},"deprecated" => !!0,"display_name" => "Num","exception_class" => "Error::TypeTiny::Assertion","library" => "Types::Standard","moose_type" => bless( {"Types::TypeTiny::to_TypeTiny" => {},"_default_message" => sub { package Moose::Meta::TypeConstraint; use warnings; use strict; my $value = shift(); my $can_partialdump = &try(sub { require Devel::PartialDump; 'Devel::PartialDump'->VERSION(0.14); 1; } ); if ($can_partialdump) { $value = 'Devel::PartialDump'->new->dump($value); } else { $value = defined $value ? overload::StrVal($value) : 'undef'; } return q[Validation failed for '] . $name . "' with value $value";},"compiled_type_constraint" => sub { package Eval::Closure::Sandbox_184; use warnings; use strict; do { defined $_[0] and not ref $_[0] and &Scalar::Util::looks_like_number($_[0]) };},"constraint" => sub { package Moose::Meta::TypeConstraint; use warnings; use strict; 1;},"inline_environment" => {},"name" => "Types::Standard::Num","parent" => bless( {"Types::TypeTiny::to_TypeTiny" => bless( {"_overload_coderef" => sub { package Type::Tiny; BEGIN {${^WARNING_BITS} = "\x10\x01\x00\x00\x00\x50\x04\x00\x00\x00\x00\x00\x01\x40\x05\x45\x55\x15\x55\x55\x01\x00\x00"} use strict; defined $_[0] and not ref $_[0] and &Scalar::Util::looks_like_number($_[0]) or _failed_check(10, 'LaxNum', $_[0], 'exception_class', 'Error::TypeTiny::Assertion'); $_[0];},"_overrides_assert_return" => !!0,"coercion" => bless( {"_compiled_type_constraint_check" => do{my $o},"display_name" => "to_LaxNum","frozen" => 1,"name" => "__ANON__","type_coercion_map" => [],"type_constraint" => {}}, 'Type::Coercion' ),"compiled_type_constraint" => do{my $o},"constraint" => sub { package Types::Standard; no warnings; use strict; looks_like_number $_ and ref \$_ ne 'GLOB';},"definition_context" => {"file" => "/usr/local/lib/perl5/site_perl/5.44.0/Types/Standard.pm","line" => 309,"package" => "Types::Standard"},"deprecated" => !!0,"display_name" => "LaxNum","exception_class" => "Error::TypeTiny::Assertion","inlined" => sub { package Types::Standard; no warnings; use strict; &$maybe_load_modules('Scalar::Util', 'Scalar::Util'->VERSION ge '1.18' ? "defined($_[1]) && !ref($_[1]) && Scalar::Util::looks_like_number($_[1])" : "defined($_[1]) && !ref($_[1]) && Scalar::Util::looks_like_number($_[1]) && ref(\\($_[1])) ne 'GLOB'");},"library" => "Types::Standard","moose_type" => {},"name" => "LaxNum","parent" => bless( {"_is_core" => 1,"_overload_coderef" => sub { package Type::Tiny; BEGIN {${^WARNING_BITS} = "\x10\x01\x00\x00\x00\x50\x04\x00\x00\x00\x00\x00\x01\x40\x05\x45\x55\x15\x55\x55\x01\x00\x00"} use strict; Type::Tiny::XS::Str($_[0]) or _failed_check(9, 'Str', $_[0], 'exception_class', 'Error::TypeTiny::Assertion'); $_[0];},"_overrides_assert_return" => !!0,"coercion" => bless( {"_compiled_type_constraint_check" => sub ;,"display_name" => "to_Str","frozen" => 1,"name" => "__ANON__","type_coercion_map" => [],"type_constraint" => {}}, 'Type::Coercion' ),"compiled_type_constraint" => do{my $o},"constraint" => sub { package Types::Standard; no warnings; use strict; ref \$_ eq 'SCALAR' or ref \(my $val = $_) eq 'SCALAR';},"definition_context" => {"file" => "/usr/local/lib/perl5/site_perl/5.44.0/Types/Standard.pm","line" => 291,"package" => "Types::Standard"},"deprecated" => !!0,"display_name" => "Str","exception_class" => "Error::TypeTiny::Assertion","inlined" => sub { package Types::Standard; use warnings; use strict; $Type::Tiny::AvoidCallbacks ? goto $orig_inlined : "$xsubname($_[1])";},"library" => "Types::Standard","moose_type" => bless( {"Types::TypeTiny::to_TypeTiny" => {},"_default_message" => sub { package Moose::Meta::TypeConstraint; use warnings; use strict; my $value = shift(); my $can_partialdump = &try(sub { require Devel::PartialDump; 'Devel::PartialDump'->VERSION(0.14); 1; } ); if ($can_partialdump) { $value = 'Devel::PartialDump'->new->dump($value); } else { $value = defined $value ? overload::StrVal($value) : 'undef'; } return q[Validation failed for '] . $name . "' with value $value";},"compiled_type_constraint" => sub { package Eval::Closure::Sandbox_51; use warnings; use strict; do { do { do { defined $_[0] } and not ref $_[0] } and ref \$_[0] eq 'SCALAR' || ref \(my $val = $_[0]) eq 'SCALAR' };},"constraint" => sub { package Moose::Util::TypeConstraints::Builtins; use warnings; use strict; ref \$_ eq 'SCALAR' or ref \(my $val = $_) eq 'SCALAR';},"inline_environment" => {},"inlined" => sub { package Moose::Util::TypeConstraints::Builtins; use warnings; use strict; $_[0]->parent->_inline_check($_[1]) . ' && (' . 'ref(\\' . $_[1] . ') eq "SCALAR"' . ' || ref(\\(my $val = ' . $_[1] . ')) eq "SCALAR"' . ')';},"name" => "Str","package_defined_in" => "Moose::Util::TypeConstraints::Builtins","parent" => bless( {"_default_message" => sub { package Moose::Meta::TypeConstraint; use warnings; use strict; my $value = shift(); my $can_partialdump = &try(sub { require Devel::PartialDump; 'Devel::PartialDump'->VERSION(0.14); 1; } ); if ($can_partialdump) { $value = 'Devel::PartialDump'->new->dump($value); } else { $value = defined $value ? overload::StrVal($value) : 'undef'; } return q[Validation failed for '] . $name . "' with value $value";},"compiled_type_constraint" => sub { package Eval::Closure::Sandbox_49; use warnings; use strict; do { do { defined $_[0] } and not ref $_[0] };},"constraint" => sub { package Moose::Util::TypeConstraints::Builtins; use warnings; use strict; not ref $_;},"inline_environment" => {},"inlined" => sub { package Moose::Util::TypeConstraints::Builtins; use warnings; use strict; $_[0]->parent->_inline_check($_[1]) . ' && !ref(' . $_[1] . ')';},"name" => "Value","package_defined_in" => "Moose::Util::TypeConstraints::Builtins","parent" => bless( {"Types::TypeTiny::to_TypeTiny" => bless( {"_is_core" => 1,"_overload_coderef" => sub { package Type::Tiny; BEGIN {${^WARNING_BITS} = "\x10\x01\x00\x00\x00\x50\x04\x00\x00\x00\x00\x00\x01\x40\x05\x45\x55\x15\x55\x55\x01\x00\x00"} use strict; defined $_[0] or _failed_check(7, 'Defined', $_[0], 'exception_class', 'Error::TypeTiny::Assertion'); $_[0];},"_overrides_assert_return" => !!0,"coercion" => bless( {"_compiled_type_constraint_check" => sub ;,"display_name" => "to_Defined","frozen" => 1,"name" => "__ANON__","type_coercion_map" => [],"type_constraint" => {}}, 'Type::Coercion' ),"compiled_type_constraint" => do{my $o},"complementary_type" => bless( {"_is_core" => 1,"_overload_coderef" => sub { package Type::Tiny; BEGIN {${^WARNING_BITS} = "\x10\x01\x00\x00\x00\x50\x04\x00\x00\x00\x00\x00\x01\x40\x05\x45\x55\x15\x55\x55\x01\x00\x00"} use strict; defined $_[0] and _failed_check(6, 'Undef', $_[0], 'exception_class', 'Error::TypeTiny::Assertion'); $_[0];},"_overrides_assert_return" => !!0,"coercion" => bless( {"_compiled_type_constraint_check" => sub ;,"display_name" => "to_Undef","frozen" => 1,"name" => "__ANON__","type_coercion_map" => [],"type_constraint" => {}}, 'Type::Coercion' ),"compiled_type_constraint" => do{my $o},"complementary_type" => {},"constraint" => sub { package Types::Standard; no warnings; use strict; not defined $_;},"definition_context" => {"file" => "/usr/local/lib/perl5/site_perl/5.44.0/Types/Standard.pm","line" => 254,"package" => "Types::Standard"},"deprecated" => !!0,"display_name" => "Undef","exception_class" => "Error::TypeTiny::Assertion","inlined" => sub { package Types::Standard; no warnings; use strict; "!defined($_[1])";},"library" => "Types::Standard","name" => "Undef","parent" => bless( {"_is_core" => 1,"_overload_coderef" => sub { package Type::Tiny; BEGIN {${^WARNING_BITS} = "\x10\x01\x00\x00\x00\x50\x04\x00\x00\x00\x00\x00\x01\x40\x05\x45\x55\x15\x55\x55\x01\x00\x00"} use strict; '???'; $_[0];},"_overrides_assert_return" => !!0,"coercion" => bless( {"_compiled_type_constraint_check" => sub ;,"display_name" => "to_Item","frozen" => 1,"name" => "__ANON__","type_coercion_map" => [],"type_constraint" => {}}, 'Type::Coercion' ),"compiled_type_constraint" => do{my $o},"constraint" => do{my $o},"definition_context" => {"file" => "/usr/local/lib/perl5/site_perl/5.44.0/Types/Standard.pm","line" => 226,"package" => "Types::Standard"},"deprecated" => !!0,"display_name" => "Item","exception_class" => "Error::TypeTiny::Assertion","inlined" => sub { package Types::Standard; no warnings; use strict; '!!1';},"library" => "Types::Standard","name" => "Item","parent" => bless( {"_is_core" => 1,"_overload_coderef" => sub { package Type::Tiny; BEGIN {${^WARNING_BITS} = "\x10\x01\x00\x00\x00\x50\x04\x00\x00\x00\x00\x00\x01\x40\x05\x45\x55\x15\x55\x55\x01\x00\x00"} use strict; '???'; $_[0];},"_overrides_assert_return" => !!0,"coercion" => bless( {"_compiled_type_constraint_check" => do{my $o},"display_name" => "to_Any","frozen" => 1,"name" => "__ANON__","type_coercion_map" => [],"type_constraint" => {}}, 'Type::Coercion' ),"compiled_type_constraint" => do{my $o},"complement_name" => "None","constraint" => do{my $o},"definition_context" => {"file" => "/usr/local/lib/perl5/site_perl/5.44.0/Types/Standard.pm","line" => 220,"package" => "Types::Standard"},"deprecated" => !!0,"display_name" => "Any","exception_class" => "Error::TypeTiny::Assertion","inlined" => sub { package Types::Standard; no warnings; use strict; '!!1';},"library" => "Types::Standard","moose_type" => bless( {"Types::TypeTiny::to_TypeTiny" => {},"_default_message" => sub { package Moose::Meta::TypeConstraint; use warnings; use strict; my $value = shift(); my $can_partialdump = &try(sub { require Devel::PartialDump; 'Devel::PartialDump'->VERSION(0.14); 1; } ); if ($can_partialdump) { $value = 'Devel::PartialDump'->new->dump($value); } else { $value = defined $value ? overload::StrVal($value) : 'undef'; } return q[Validation failed for '] . $name . "' with value $value";},"compiled_type_constraint" => sub { package Eval::Closure::Sandbox_44; use warnings; use strict; do { 1 };},"constraint" => sub { package Moose::Util::TypeConstraints::Builtins; use warnings; use strict; 1;},"inline_environment" => {},"inlined" => sub { package Moose::Util::TypeConstraints::Builtins; use warnings; use strict; '1';},"name" => "Any","package_defined_in" => "Moose::Util::TypeConstraints::Builtins"}, 'Moose::Meta::TypeConstraint' ),"name" => "Any","type_default" => sub { package Types::Standard; no warnings; use strict; return undef;},"uniq" => 1}, 'Type::Tiny' ),"uniq" => 2}, 'Type::Tiny' ),"type_default" => sub { package Types::Standard; no warnings; use strict; return undef;},"uniq" => 6}, 'Type::Tiny' ),"constraint" => sub { package Types::Standard; no warnings; use strict; defined $_;},"definition_context" => {"file" => "/usr/local/lib/perl5/site_perl/5.44.0/Types/Standard.pm","line" => 262,"package" => "Types::Standard"},"deprecated" => !!0,"display_name" => "Defined","exception_class" => "Error::TypeTiny::Assertion","inlined" => sub { package Types::Standard; no warnings; use strict; "defined($_[1])";},"library" => "Types::Standard","moose_type" => {},"name" => "Defined","parent" => {},"uniq" => 7}, 'Type::Tiny' ),"_default_message" => sub { package Moose::Meta::TypeConstraint; use warnings; use strict; my $value = shift(); my $can_partialdump = &try(sub { require Devel::PartialDump; 'Devel::PartialDump'->VERSION(0.14); 1; } ); if ($can_partialdump) { $value = 'Devel::PartialDump'->new->dump($value); } else { $value = defined $value ? overload::StrVal($value) : 'undef'; } return q[Validation failed for '] . $name . "' with value $value";},"compiled_type_constraint" => sub { package Eval::Closure::Sandbox_47; use warnings; use strict; do { defined $_[0] };},"constraint" => sub { package Moose::Util::TypeConstraints::Builtins; use warnings; use strict; defined $_;},"inline_environment" => {},"inlined" => sub { package Moose::Util::TypeConstraints::Builtins; use warnings; use strict; 'defined(' . $_[1] . ')';},"name" => "Defined","package_defined_in" => "Moose::Util::TypeConstraints::Builtins","parent" => bless( {"_default_message" => sub { package Moose::Meta::TypeConstraint; use warnings; use strict; my $value = shift(); my $can_partialdump = &try(sub { require Devel::PartialDump; 'Devel::PartialDump'->VERSION(0.14); 1; } ); if ($can_partialdump) { $value = 'Devel::PartialDump'->new->dump($value); } else { $value = defined $value ? overload::StrVal($value) : 'undef'; } return q[Validation failed for '] . $name . "' with value $value";},"compiled_type_constraint" => sub { package Eval::Closure::Sandbox_45; use warnings; use strict; do { 1 };},"constraint" => do{my $o},"inline_environment" => {},"inlined" => sub { package Moose::Util::TypeConstraints::Builtins; use warnings; use strict; '1';},"name" => "Item","package_defined_in" => "Moose::Util::TypeConstraints::Builtins","parent" => {}}, 'Moose::Meta::TypeConstraint' )}, 'Moose::Meta::TypeConstraint' )}, 'Moose::Meta::TypeConstraint' )}, 'Moose::Meta::TypeConstraint' ),"name" => "Str","parent" => bless( {"_is_core" => 1,"_overload_coderef" => sub { package Type::Tiny; BEGIN {${^WARNING_BITS} = "\x10\x01\x00\x00\x00\x50\x04\x00\x00\x00\x00\x00\x01\x40\x05\x45\x55\x15\x55\x55\x01\x00\x00"} use strict; defined $_[0] and not ref $_[0] or _failed_check(8, 'Value', $_[0], 'exception_class', 'Error::TypeTiny::Assertion'); $_[0];},"_overrides_assert_return" => !!0,"coercion" => bless( {"_compiled_type_constraint_check" => sub ;,"display_name" => "to_Value","frozen" => 1,"name" => "__ANON__","type_coercion_map" => [],"type_constraint" => {}}, 'Type::Coercion' ),"compiled_type_constraint" => do{my $o},"constraint" => sub { package Types::Standard; no warnings; use strict; not ref $_;},"definition_context" => {"file" => "/usr/local/lib/perl5/site_perl/5.44.0/Types/Standard.pm","line" => 276,"package" => "Types::Standard"},"deprecated" => !!0,"display_name" => "Value","exception_class" => "Error::TypeTiny::Assertion","inlined" => sub { package Types::Standard; no warnings; use strict; "defined($_[1]) and not ref($_[1])";},"library" => "Types::Standard","name" => "Value","parent" => {},"uniq" => 8}, 'Type::Tiny' ),"sorter" => sub { package Types::Standard; no warnings; use strict; $_[0] cmp $_[1];},"type_default" => sub { package Types::Standard; no warnings; use strict; return '';},"uniq" => 9}, 'Type::Tiny' ),"sorter" => sub { package Types::Standard; no warnings; use strict; $_[0] <=> $_[1];},"type_default" => sub { package Types::Standard; no warnings; use strict; return 0;},"uniq" => 10}, 'Type::Tiny' ),"_default_message" => sub { package Moose::Meta::TypeConstraint; use warnings; use strict; my $value = shift(); my $can_partialdump = &try(sub { require Devel::PartialDump; 'Devel::PartialDump'->VERSION(0.14); 1; } ); if ($can_partialdump) { $value = 'Devel::PartialDump'->new->dump($value); } else { $value = defined $value ? overload::StrVal($value) : 'undef'; } return q[Validation failed for '] . $name . "' with value $value";},"compiled_type_constraint" => sub { package Eval::Closure::Sandbox_183; use warnings; use strict; do { defined $_[0] and not ref $_[0] and &Scalar::Util::looks_like_number($_[0]) };},"constraint" => do{my $o},"inline_environment" => {},"inlined" => sub { package Type::Tiny; use warnings; use strict; shift(); $self->inline_check(@_);},"name" => "Types::Standard::LaxNum","parent" => {}}, 'Moose::Meta::TypeConstraint' )}, 'Moose::Meta::TypeConstraint' ),"name" => "Num","parent" => {},"uniq" => 12}, 'Type::Tiny' ),"type_default" => sub { package Types::Standard; no warnings; use strict; return 0;},"uniq" => 13}, 'Type::Tiny' );$v->{"coercion"}{"type_constraint"} = $v;$v->{"compiled_type_constraint"} = $v->{"coercion"}{"_compiled_type_constraint_check"};$v->{"parent"}{"coercion"}{"type_constraint"} = $v->{"parent"};$v->{"parent"}{"compiled_type_constraint"} = $v->{"parent"}{"coercion"}{"_compiled_type_constraint_check"};$v->{"parent"}{"moose_type"}{"Types::TypeTiny::to_TypeTiny"} = $v->{"parent"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"coercion"}{"_compiled_type_constraint_check"} = $v->{"parent"}{"coercion"}{"_compiled_type_constraint_check"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"coercion"}{"type_constraint"} = $v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"compiled_type_constraint"} = $v->{"parent"}{"coercion"}{"_compiled_type_constraint_check"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"moose_type"} = $v->{"parent"}{"moose_type"}{"parent"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"coercion"}{"type_constraint"} = $v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"compiled_type_constraint"} = $v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"coercion"}{"_compiled_type_constraint_check"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"Types::TypeTiny::to_TypeTiny"} = $v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"coercion"}{"type_constraint"} = $v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"compiled_type_constraint"} = $v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"coercion"}{"_compiled_type_constraint_check"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"complementary_type"}{"coercion"}{"type_constraint"} = $v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"complementary_type"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"complementary_type"}{"compiled_type_constraint"} = $v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"complementary_type"}{"coercion"}{"_compiled_type_constraint_check"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"complementary_type"}{"complementary_type"} = $v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"complementary_type"}{"parent"}{"coercion"}{"type_constraint"} = $v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"complementary_type"}{"parent"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"complementary_type"}{"parent"}{"compiled_type_constraint"} = $v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"complementary_type"}{"parent"}{"coercion"}{"_compiled_type_constraint_check"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"complementary_type"}{"parent"}{"constraint"} = $v->{"parent"}{"constraint"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"complementary_type"}{"parent"}{"parent"}{"coercion"}{"_compiled_type_constraint_check"} = $v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"complementary_type"}{"parent"}{"coercion"}{"_compiled_type_constraint_check"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"complementary_type"}{"parent"}{"parent"}{"coercion"}{"type_constraint"} = $v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"complementary_type"}{"parent"}{"parent"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"complementary_type"}{"parent"}{"parent"}{"compiled_type_constraint"} = $v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"complementary_type"}{"parent"}{"coercion"}{"_compiled_type_constraint_check"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"complementary_type"}{"parent"}{"parent"}{"constraint"} = $v->{"parent"}{"constraint"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"complementary_type"}{"parent"}{"parent"}{"moose_type"}{"Types::TypeTiny::to_TypeTiny"} = $v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"complementary_type"}{"parent"}{"parent"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"moose_type"} = $v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"} = $v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"complementary_type"}{"parent"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"parent"}{"constraint"} = $v->{"parent"}{"moose_type"}{"constraint"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"parent"}{"parent"} = $v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"complementary_type"}{"parent"}{"parent"}{"moose_type"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"parent"}{"coercion"}{"type_constraint"} = $v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"parent"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"parent"}{"compiled_type_constraint"} = $v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"parent"}{"coercion"}{"_compiled_type_constraint_check"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"parent"}{"parent"} = $v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"};$v->{"parent"}{"moose_type"}{"parent"}{"constraint"} = $v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"constraint"};$v->{"parent"}{"moose_type"}{"parent"}{"parent"} = $v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"};$v->{"parent"}{"parent"} = $v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}; \$v}->get_message($n)) |
3 |
0 |
3 |
|
| 184 |
3 |
| my @colors = Color::Brewer::named_color_scheme( |
| 185 |
|
| number_of_data_classes => List::AllUtils::max( $n, 3 ), |
| 186 |
|
| name => $pal_name |
| 187 |
|
| ); |
| 188 |
|
| |
| 189 |
|
| # convert to Graphics::Color object |
| 190 |
|
| @colors = map { |
| 191 |
3 |
| my ( $r, $g, $b ) = $_ =~ /^rgb\((\d+),(\d+),(\d+)\)/; |
| 192 |
9 |
| rgb255_to_csshex($r, $g, $b); |
| 193 |
|
| } @colors[ 0 .. $n - 1 ]; |
| 194 |
|
| |
| 195 |
3 |
▶ | if ( $direction == -1 ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ($direction == -1) |
0 |
3 |
3 |
|
| 196 |
0 |
| @colors = reverse @colors; |
| 197 |
|
| } |
| 198 |
3 |
| return PDL::SV->new( \@colors ); |
| 199 |
1 |
| }; |
| 200 |
24 |
| } |
| 201 |
|
| |
| 202 |
|
| # Returns a function that maps the interval [0,1] to a set of colors. |
| 203 |
|
| # Interpolation is performed in the CIELAB color space. |
| 204 |
4 |
▶ | fun _color_ramp ($colors) { |
|
Subroutine
_color_ramp: called CC=5 SCAR=16.3
Branch: 2 branches
| Branch | True | False | Total |
| @_ < 1 and Function::Parameters::_croak('Too few arguments for fun _color_ramp (expected 1, got ' . @_ . ')') |
0 |
4 |
4 |
| @_ > 1 and Function::Parameters::_croak('Too many arguments for fun _color_ramp (expected 1, got ' . @_ . ')') |
0 |
4 |
4 |
|
| 205 |
4 |
▶ | if ( $colors->isempty ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ($colors->isempty) |
0 |
4 |
4 |
|
| 206 |
0 |
| die("Must provide at least one color to create a color ramp"); |
| 207 |
|
| } |
| 208 |
|
| |
| 209 |
|
| my $hot_spots = rgb_to_lab( |
| 210 |
|
| pdl( |
| 211 |
|
| map { |
| 212 |
4 |
▶ | /^\#/ |
Branch: 1 branch
| Branch | True | False | Total |
| /^\#/u ? : |
4 |
5 |
9 |
|
| 213 |
|
| ? pdl( csshex_to_rgb255($_) ) |
| 214 |
|
| : pdl( colorname_to_rgb255($_) ) |
| 215 |
|
| } ( $colors->flatten ) |
| 216 |
|
| ) / 255.0, |
| 217 |
|
| 'sRGB' |
| 218 |
|
| ); # Lab space |
| 219 |
|
| |
| 220 |
4 |
| my $x = seq_n(0, 1, $colors->length); |
| 221 |
|
| |
| 222 |
3 |
▶ | return fun( Piddle $p ) { |
|
Subroutine
__ANON__: called CC=5 SCAR=16.2
Branch: 3 branches
| Branch | True | False | Total |
| @_ < 1 and Function::Parameters::_croak('Too few arguments for fun (anon) (expected 1, got ' . @_ . ')') |
0 |
3 |
3 |
| @_ > 1 and Function::Parameters::_croak('Too many arguments for fun (anon) (expected 1, got ' . @_ . ')') |
0 |
3 |
3 |
| Type::Tiny::XS::AUTO::TC1($p) or Function::Parameters::_croak('In fun (anon): parameter 1 ($p): ' . ${my $v = bless( {"_caller_level" => 1,"_overload_coderef" => sub { package Type::Tiny; BEGIN {${^WARNING_BITS} = "\x10\x01\x00\x00\x00\x50\x04\x00\x00\x00\x00\x00\x01\x40\x05\x45\x55\x15\x55\x55\x01\x00\x00"} use strict; Type::Tiny::XS::AUTO::TC1($_[0]) or _failed_check(46, 'Piddle', $_[0], 'exception_class', 'Error::TypeTiny::Assertion'); $_[0];},"_overrides_assert_return" => !!0,"class" => "PDL","compiled_type_constraint" => sub ;,"constraint" => sub { package Type::Tiny::Class; use warnings; use strict; builtin::blessed($_) and $_->isa($class);},"constraint_generator" => sub { package Type::TinyX::Facets; use warnings; use strict; my $base = do { BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x45\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55\x55"} $Type::Tiny::parameterize_type }; my(%params) = @_ or return $base; my(@checks) = &$IG(%params)->($base, '$_[0]'); $checks[0] = $base->inline_check('$_[0]'); my $sub = sprintf('sub { %s }', join(' and ', map(("($_)"), @checks))); eval $sub or _croak("could not build sub: $@\n\nCODE: $sub\n");},"definition_context" => {"file" => "/usr/local/lib/perl5/site_perl/5.44.0/Types/PDL.pm","line" => 138,"package" => "Types::PDL"},"deprecated" => !!0,"display_name" => "Piddle","exception_class" => "Error::TypeTiny::Assertion","inline_generator" => sub { package Type::TinyX::Facets; use warnings; use strict; my(%p_not_destroyed) = @_; return sub { my(%p) = %p_not_destroyed; my $var = $_[1]; my(@r) = map($_->[1]->(\%p, $var, $_->[0]), @facets); _croak(sprintf('Attempt to parameterize type "%s" with unrecognised parameter%s %s', $_[0]->name, scalar keys %p == 1 ? '' : 's', Type::Utils::english_list(map((qq["$_"]), sort(keys %p))))) if keys %p; return undef, @r; } ;},"inlined" => sub { package Type::Tiny::Class; use warnings; use strict; my $var = $_[1]; return "do { use Scalar::Util (); Scalar::Util::blessed($var) and $var->isa(q[$class]) }" if $Type::Tiny::AvoidCallbacks; return "$xsub($var)" if $xsub; "Scalar::Util::blessed($var) and $var->isa(q[$class])";},"library" => "Types::PDL","moose_type" => bless( {"Types::TypeTiny::to_TypeTiny" => {},"_default_message" => sub { package Moose::Meta::TypeConstraint; use warnings; use strict; my $value = shift(); my $can_partialdump = &try(sub { require Devel::PartialDump; 'Devel::PartialDump'->VERSION(0.14); 1; } ); if ($can_partialdump) { $value = 'Devel::PartialDump'->new->dump($value); } else { $value = defined $value ? overload::StrVal($value) : 'undef'; } return q[Validation failed for '] . $name . "' with value $value";},"class" => "PDL","compiled_type_constraint" => sub { package Eval::Closure::Sandbox_186; use warnings; use strict; do { builtin::blessed($_[0]) and $_[0]->isa('PDL') };},"constraint" => sub { package Moose::Meta::TypeConstraint::Class; use warnings; use strict; $_[0]->isa($class_name);},"inline_environment" => {},"inlined" => sub { package Moose::Meta::TypeConstraint::Class; use warnings; use strict; my $self = shift(); my $val = shift(); return 'Scalar::Util::blessed(' . $val . ')' . ' && ' . $val . '->isa(' . B::perlstring($self->class) . ')';},"name" => "Types::PDL::Piddle","parent" => bless( {"Types::TypeTiny::to_TypeTiny" => bless( {"_is_core" => 1,"_overload_coderef" => sub { package Type::Tiny; BEGIN {${^WARNING_BITS} = "\x10\x01\x00\x00\x00\x50\x04\x00\x00\x00\x00\x00\x01\x40\x05\x45\x55\x15\x55\x55\x01\x00\x00"} use strict; Ref::Util::XS::is_blessed_ref($_[0]) or _failed_check(24, 'Object', $_[0], 'exception_class', 'Error::TypeTiny::Assertion'); $_[0];},"_overrides_assert_return" => !!0,"coercion" => bless( {"_compiled_type_constraint_check" => sub ;,"display_name" => "to_Object","frozen" => 1,"name" => "__ANON__","type_coercion_map" => [],"type_constraint" => {}}, 'Type::Coercion' ),"compiled_type_constraint" => do{my $o},"constraint" => sub { package Types::Standard; no warnings; use strict; builtin::blessed($_);},"definition_context" => {"file" => "/usr/local/lib/perl5/site_perl/5.44.0/Types/Standard.pm","line" => 578,"package" => "Types::Standard"},"deprecated" => !!0,"display_name" => "Object","exception_class" => "Error::TypeTiny::Assertion","inlined" => sub { package Types::Standard; no warnings; use strict; !$Type::Tiny::AvoidCallbacks ? "Ref::Util::XS::is_blessed_ref($_[1])" : &$maybe_load_modules('Scalar::Util', "Scalar::Util::blessed($_[1])");},"is_object" => 1,"library" => "Types::Standard","moose_type" => {},"name" => "Object","parent" => bless( {"_is_core" => 1,"_overload_coderef" => sub { package Type::Tiny; BEGIN {${^WARNING_BITS} = "\x10\x01\x00\x00\x00\x50\x04\x00\x00\x00\x00\x00\x01\x40\x05\x45\x55\x15\x55\x55\x01\x00\x00"} use strict; not ref $_[0] and _failed_check(16, 'Ref', $_[0], 'exception_class', 'Error::TypeTiny::Assertion'); $_[0];},"_overrides_assert_return" => !!0,"coercion" => bless( {"_compiled_type_constraint_check" => sub ;,"display_name" => "to_Ref","frozen" => 1,"name" => "__ANON__","type_coercion_map" => [],"type_constraint" => {}}, 'Type::Coercion' ),"compiled_type_constraint" => do{my $o},"constraint" => sub { package Types::Standard; no warnings; use strict; ref $_;},"constraint_generator" => sub { package Types::Standard; no warnings; use strict; return $meta->get_type('Ref') unless @_; Type::Tiny::check_parameter_count_for_parameterized_type('Types::Standard', 'Ref', \@_, 1); my $reftype = shift(); $reftype =~ /^(SCALAR|ARRAY|HASH|CODE|REF|GLOB|LVALUE|FORMAT|IO|VSTRING|REGEXP|Regexp)$/i or _croak "Parameter to Ref[`a] expected to be a Perl ref type; got $reftype"; $reftype = "$reftype"; return sub { ref $_[0] and builtin::reftype($_[0]) eq $reftype; } ;},"deep_explanation" => sub { package Types::Standard; no warnings; use strict; require B; my($type, $value, $varname) = @_; my $param = $type->parameters->[0]; return if $type->check($value); my $reftype = builtin::reftype($value); return [sprintf('"%s" constrains reftype(%s) to be equal to %s', $type, $varname, B::perlstring($param)), sprintf('reftype(%s) is %s', $varname, defined $reftype ? B::perlstring($reftype) : 'undef')];},"definition_context" => {"file" => "/usr/local/lib/perl5/site_perl/5.44.0/Types/Standard.pm","line" => 438,"package" => "Types::Standard"},"deprecated" => !!0,"display_name" => "Ref","exception_class" => "Error::TypeTiny::Assertion","inline_generator" => sub { package Types::Standard; no warnings; use strict; my $reftype = shift(); return sub { my $v = $_[1]; &$maybe_load_modules('Scalar::Util', "ref($v) and Scalar::Util::reftype($v) eq q($reftype)"); } ;},"inlined" => sub { package Types::Standard; no warnings; use strict; "!!ref($_[1])";},"library" => "Types::Standard","name" => "Ref","parent" => bless( {"_is_core" => 1,"_overload_coderef" => sub { package Type::Tiny; BEGIN {${^WARNING_BITS} = "\x10\x01\x00\x00\x00\x50\x04\x00\x00\x00\x00\x00\x01\x40\x05\x45\x55\x15\x55\x55\x01\x00\x00"} use strict; defined $_[0] or _failed_check(7, 'Defined', $_[0], 'exception_class', 'Error::TypeTiny::Assertion'); $_[0];},"_overrides_assert_return" => !!0,"coercion" => bless( {"_compiled_type_constraint_check" => sub ;,"display_name" => "to_Defined","frozen" => 1,"name" => "__ANON__","type_coercion_map" => [],"type_constraint" => {}}, 'Type::Coercion' ),"compiled_type_constraint" => do{my $o},"complementary_type" => bless( {"_is_core" => 1,"_overload_coderef" => sub { package Type::Tiny; BEGIN {${^WARNING_BITS} = "\x10\x01\x00\x00\x00\x50\x04\x00\x00\x00\x00\x00\x01\x40\x05\x45\x55\x15\x55\x55\x01\x00\x00"} use strict; defined $_[0] and _failed_check(6, 'Undef', $_[0], 'exception_class', 'Error::TypeTiny::Assertion'); $_[0];},"_overrides_assert_return" => !!0,"coercion" => bless( {"_compiled_type_constraint_check" => sub ;,"display_name" => "to_Undef","frozen" => 1,"name" => "__ANON__","type_coercion_map" => [],"type_constraint" => {}}, 'Type::Coercion' ),"compiled_type_constraint" => do{my $o},"complementary_type" => {},"constraint" => sub { package Types::Standard; no warnings; use strict; not defined $_;},"definition_context" => {"file" => "/usr/local/lib/perl5/site_perl/5.44.0/Types/Standard.pm","line" => 254,"package" => "Types::Standard"},"deprecated" => !!0,"display_name" => "Undef","exception_class" => "Error::TypeTiny::Assertion","inlined" => sub { package Types::Standard; no warnings; use strict; "!defined($_[1])";},"library" => "Types::Standard","name" => "Undef","parent" => bless( {"_is_core" => 1,"_overload_coderef" => sub { package Type::Tiny; BEGIN {${^WARNING_BITS} = "\x10\x01\x00\x00\x00\x50\x04\x00\x00\x00\x00\x00\x01\x40\x05\x45\x55\x15\x55\x55\x01\x00\x00"} use strict; '???'; $_[0];},"_overrides_assert_return" => !!0,"coercion" => bless( {"_compiled_type_constraint_check" => sub ;,"display_name" => "to_Item","frozen" => 1,"name" => "__ANON__","type_coercion_map" => [],"type_constraint" => {}}, 'Type::Coercion' ),"compiled_type_constraint" => do{my $o},"constraint" => sub { package Type::Tiny; use warnings; use strict; !0;},"definition_context" => {"file" => "/usr/local/lib/perl5/site_perl/5.44.0/Types/Standard.pm","line" => 226,"package" => "Types::Standard"},"deprecated" => !!0,"display_name" => "Item","exception_class" => "Error::TypeTiny::Assertion","inlined" => sub { package Types::Standard; no warnings; use strict; '!!1';},"library" => "Types::Standard","name" => "Item","parent" => bless( {"_is_core" => 1,"_overload_coderef" => sub { package Type::Tiny; BEGIN {${^WARNING_BITS} = "\x10\x01\x00\x00\x00\x50\x04\x00\x00\x00\x00\x00\x01\x40\x05\x45\x55\x15\x55\x55\x01\x00\x00"} use strict; '???'; $_[0];},"_overrides_assert_return" => !!0,"coercion" => bless( {"_compiled_type_constraint_check" => do{my $o},"display_name" => "to_Any","frozen" => 1,"name" => "__ANON__","type_coercion_map" => [],"type_constraint" => {}}, 'Type::Coercion' ),"compiled_type_constraint" => do{my $o},"complement_name" => "None","constraint" => do{my $o},"definition_context" => {"file" => "/usr/local/lib/perl5/site_perl/5.44.0/Types/Standard.pm","line" => 220,"package" => "Types::Standard"},"deprecated" => !!0,"display_name" => "Any","exception_class" => "Error::TypeTiny::Assertion","inlined" => sub { package Types::Standard; no warnings; use strict; '!!1';},"library" => "Types::Standard","moose_type" => bless( {"Types::TypeTiny::to_TypeTiny" => {},"_default_message" => sub { package Moose::Meta::TypeConstraint; use warnings; use strict; my $value = shift(); my $can_partialdump = &try(sub { require Devel::PartialDump; 'Devel::PartialDump'->VERSION(0.14); 1; } ); if ($can_partialdump) { $value = 'Devel::PartialDump'->new->dump($value); } else { $value = defined $value ? overload::StrVal($value) : 'undef'; } return q[Validation failed for '] . $name . "' with value $value";},"compiled_type_constraint" => sub { package Eval::Closure::Sandbox_44; use warnings; use strict; do { 1 };},"constraint" => sub { package Moose::Util::TypeConstraints::Builtins; use warnings; use strict; 1;},"inline_environment" => {},"inlined" => sub { package Moose::Util::TypeConstraints::Builtins; use warnings; use strict; '1';},"name" => "Any","package_defined_in" => "Moose::Util::TypeConstraints::Builtins"}, 'Moose::Meta::TypeConstraint' ),"name" => "Any","type_default" => sub { package Types::Standard; no warnings; use strict; return undef;},"uniq" => 1}, 'Type::Tiny' ),"uniq" => 2}, 'Type::Tiny' ),"type_default" => sub { package Types::Standard; no warnings; use strict; return undef;},"uniq" => 6}, 'Type::Tiny' ),"constraint" => sub { package Types::Standard; no warnings; use strict; defined $_;},"definition_context" => {"file" => "/usr/local/lib/perl5/site_perl/5.44.0/Types/Standard.pm","line" => 262,"package" => "Types::Standard"},"deprecated" => !!0,"display_name" => "Defined","exception_class" => "Error::TypeTiny::Assertion","inlined" => sub { package Types::Standard; no warnings; use strict; "defined($_[1])";},"library" => "Types::Standard","moose_type" => bless( {"Types::TypeTiny::to_TypeTiny" => {},"_default_message" => sub { package Moose::Meta::TypeConstraint; use warnings; use strict; my $value = shift(); my $can_partialdump = &try(sub { require Devel::PartialDump; 'Devel::PartialDump'->VERSION(0.14); 1; } ); if ($can_partialdump) { $value = 'Devel::PartialDump'->new->dump($value); } else { $value = defined $value ? overload::StrVal($value) : 'undef'; } return q[Validation failed for '] . $name . "' with value $value";},"compiled_type_constraint" => sub { package Eval::Closure::Sandbox_47; use warnings; use strict; do { defined $_[0] };},"constraint" => sub { package Moose::Util::TypeConstraints::Builtins; use warnings; use strict; defined $_;},"inline_environment" => {},"inlined" => sub { package Moose::Util::TypeConstraints::Builtins; use warnings; use strict; 'defined(' . $_[1] . ')';},"name" => "Defined","package_defined_in" => "Moose::Util::TypeConstraints::Builtins","parent" => bless( {"_default_message" => sub { package Moose::Meta::TypeConstraint; use warnings; use strict; my $value = shift(); my $can_partialdump = &try(sub { require Devel::PartialDump; 'Devel::PartialDump'->VERSION(0.14); 1; } ); if ($can_partialdump) { $value = 'Devel::PartialDump'->new->dump($value); } else { $value = defined $value ? overload::StrVal($value) : 'undef'; } return q[Validation failed for '] . $name . "' with value $value";},"compiled_type_constraint" => sub { package Eval::Closure::Sandbox_45; use warnings; use strict; do { 1 };},"constraint" => sub { package Moose::Meta::TypeConstraint; use warnings; use strict; 1;},"inline_environment" => {},"inlined" => sub { package Moose::Util::TypeConstraints::Builtins; use warnings; use strict; '1';},"name" => "Item","package_defined_in" => "Moose::Util::TypeConstraints::Builtins","parent" => {}}, 'Moose::Meta::TypeConstraint' )}, 'Moose::Meta::TypeConstraint' ),"name" => "Defined","parent" => {},"uniq" => 7}, 'Type::Tiny' ),"uniq" => 16}, 'Type::Tiny' ),"uniq" => 24}, 'Type::Tiny' ),"_default_message" => sub { package Moose::Meta::TypeConstraint; use warnings; use strict; my $value = shift(); my $can_partialdump = &try(sub { require Devel::PartialDump; 'Devel::PartialDump'->VERSION(0.14); 1; } ); if ($can_partialdump) { $value = 'Devel::PartialDump'->new->dump($value); } else { $value = defined $value ? overload::StrVal($value) : 'undef'; } return q[Validation failed for '] . $name . "' with value $value";},"compiled_type_constraint" => sub { package Eval::Closure::Sandbox_58; use warnings; use strict; do { builtin::blessed($_[0]) };},"constraint" => sub { package Moose::Util::TypeConstraints::Builtins; use warnings; use strict; builtin::blessed($_);},"inline_environment" => {},"inlined" => sub { package Moose::Util::TypeConstraints::Builtins; use warnings; use strict; 'Scalar::Util::blessed(' . $_[1] . ')';},"name" => "Object","package_defined_in" => "Moose::Util::TypeConstraints::Builtins","parent" => bless( {"_default_message" => sub { package Moose::Meta::TypeConstraint; use warnings; use strict; my $value = shift(); my $can_partialdump = &try(sub { require Devel::PartialDump; 'Devel::PartialDump'->VERSION(0.14); 1; } ); if ($can_partialdump) { $value = 'Devel::PartialDump'->new->dump($value); } else { $value = defined $value ? overload::StrVal($value) : 'undef'; } return q[Validation failed for '] . $name . "' with value $value";},"compiled_type_constraint" => sub { package Eval::Closure::Sandbox_50; use warnings; use strict; do { ref $_[0] };},"constraint" => sub { package Moose::Util::TypeConstraints::Builtins; use warnings; use strict; ref $_;},"inline_environment" => {},"inlined" => sub { package Moose::Util::TypeConstraints::Builtins; use warnings; use strict; 'ref(' . $_[1] . ')';},"name" => "Ref","package_defined_in" => "Moose::Util::TypeConstraints::Builtins","parent" => {}}, 'Moose::Meta::TypeConstraint' )}, 'Moose::Meta::TypeConstraint' )}, 'Moose::Meta::TypeConstraint::Class' ),"name" => "Piddle","name_generator" => sub { package Type::TinyX::Facets; use warnings; use strict; my($s, %a) = @_; sprintf '%s[%s]', $s, join(',', map(sprintf('%s=>%s', $_, B::perlstring($a{$_})), sort(keys %a)));},"parent" => {},"uniq" => 46}, 'Type::Tiny::Class' );$v->{"moose_type"}{"Types::TypeTiny::to_TypeTiny"} = $v;$v->{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"coercion"}{"type_constraint"} = $v->{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"};$v->{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"compiled_type_constraint"} = $v->{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"coercion"}{"_compiled_type_constraint_check"};$v->{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"moose_type"} = $v->{"moose_type"}{"parent"};$v->{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"coercion"}{"type_constraint"} = $v->{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"};$v->{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"compiled_type_constraint"} = $v->{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"coercion"}{"_compiled_type_constraint_check"};$v->{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"parent"}{"coercion"}{"type_constraint"} = $v->{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"parent"};$v->{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"parent"}{"compiled_type_constraint"} = $v->{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"parent"}{"coercion"}{"_compiled_type_constraint_check"};$v->{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"parent"}{"complementary_type"}{"coercion"}{"type_constraint"} = $v->{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"parent"}{"complementary_type"};$v->{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"parent"}{"complementary_type"}{"compiled_type_constraint"} = $v->{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"parent"}{"complementary_type"}{"coercion"}{"_compiled_type_constraint_check"};$v->{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"parent"}{"complementary_type"}{"complementary_type"} = $v->{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"parent"};$v->{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"parent"}{"complementary_type"}{"parent"}{"coercion"}{"type_constraint"} = $v->{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"parent"}{"complementary_type"}{"parent"};$v->{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"parent"}{"complementary_type"}{"parent"}{"compiled_type_constraint"} = $v->{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"parent"}{"complementary_type"}{"parent"}{"coercion"}{"_compiled_type_constraint_check"};$v->{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"parent"}{"complementary_type"}{"parent"}{"parent"}{"coercion"}{"_compiled_type_constraint_check"} = $v->{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"parent"}{"complementary_type"}{"parent"}{"coercion"}{"_compiled_type_constraint_check"};$v->{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"parent"}{"complementary_type"}{"parent"}{"parent"}{"coercion"}{"type_constraint"} = $v->{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"parent"}{"complementary_type"}{"parent"}{"parent"};$v->{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"parent"}{"complementary_type"}{"parent"}{"parent"}{"compiled_type_constraint"} = $v->{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"parent"}{"complementary_type"}{"parent"}{"coercion"}{"_compiled_type_constraint_check"};$v->{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"parent"}{"complementary_type"}{"parent"}{"parent"}{"constraint"} = $v->{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"parent"}{"complementary_type"}{"parent"}{"constraint"};$v->{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"parent"}{"complementary_type"}{"parent"}{"parent"}{"moose_type"}{"Types::TypeTiny::to_TypeTiny"} = $v->{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"parent"}{"complementary_type"}{"parent"}{"parent"};$v->{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"parent"}{"moose_type"}{"Types::TypeTiny::to_TypeTiny"} = $v->{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"parent"};$v->{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"parent"}{"moose_type"}{"parent"}{"parent"} = $v->{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"parent"}{"complementary_type"}{"parent"}{"parent"}{"moose_type"};$v->{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"parent"}{"parent"} = $v->{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"parent"}{"complementary_type"}{"parent"};$v->{"moose_type"}{"parent"}{"parent"}{"parent"} = $v->{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"parent"}{"moose_type"};$v->{"parent"} = $v->{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}; \$v}->get_message($p)) |
3 |
0 |
3 |
|
| 223 |
3 |
| my @mapped = do { |
| 224 |
|
| map { |
| 225 |
3 |
| my $xin = pdl($_); |
| 226 |
30 |
| my $l = $xin->interpol($x, $hot_spots->index(0)); |
| 227 |
30 |
| my $a = $xin->interpol($x, $hot_spots->index(1)); |
| 228 |
30 |
| my $b = $xin->interpol($x, $hot_spots->index(2)); |
| 229 |
30 |
| my $rgb = lab_to_rgb(pdl($l, $a, $b), 'sRGB'); |
| 230 |
30 |
| rgb_to_csshex($rgb->flatten); |
| 231 |
|
| } $p->flatten; |
| 232 |
|
| }; |
| 233 |
3 |
| my $rslt = PDL::SV->new( \@mapped ); |
| 234 |
3 |
▶ | $rslt = $rslt->setbadif( $p->isbad ) if $p->badflag; |
Branch: 1 branch
| Branch | True | False | Total |
| if $p->badflag |
1 |
2 |
3 |
|
| 235 |
3 |
| return $rslt; |
| 236 |
4 |
| }; |
| 237 |
24 |
| } |
| 238 |
|
| |
| 239 |
|
| # Arbitrary color gradient palette (continous). |
| 240 |
4 |
▶ | fun gradient_n_pal ( $colors, $values = [] ) { |
|
Subroutine
gradient_n_pal: called CC=5 SCAR=16.3
Pod
undocumented
Branch: 3 branches
| Branch | True | False | Total |
| @_ < 1 and Function::Parameters::_croak('Too few arguments for fun gradient_n_pal (expected 1, got ' . @_ . ')') |
0 |
4 |
4 |
| @_ > 2 and Function::Parameters::_croak('Too many arguments for fun gradient_n_pal (expected 2, got ' . @_ . ')') |
0 |
4 |
4 |
| @_ < 2 and $values = [] |
3 |
1 |
4 |
|
| 241 |
4 |
| my $ramp = _color_ramp($colors); |
| 242 |
|
| |
| 243 |
4 |
| my $length = $values->length; |
| 244 |
4 |
▶ | my $xs = $length ? seq_n( 0, 1, $length ) : undef; |
Branch: 1 branch
| Branch | True | False | Total |
| $length ? : |
1 |
3 |
4 |
|
| 245 |
|
| |
| 246 |
3 |
▶ | return fun($p) { |
|
Subroutine
__ANON__: called CC=5 SCAR=16.4
Branch: 2 branches
| Branch | True | False | Total |
| @_ < 1 and Function::Parameters::_croak('Too few arguments for fun (anon) (expected 1, got ' . @_ . ')') |
0 |
3 |
3 |
| @_ > 1 and Function::Parameters::_croak('Too many arguments for fun (anon) (expected 1, got ' . @_ . ')') |
0 |
3 |
3 |
|
| 247 |
3 |
▶ | return PDL->null if ( $p->isempty ); |
Branch: 1 branch
| Branch | True | False | Total |
| if $p->isempty |
0 |
3 |
3 |
|
| 248 |
|
| |
| 249 |
3 |
▶ | if (defined $xs) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (defined $xs) { } |
1 |
2 |
3 |
|
| 250 |
1 |
| my $p_adjusted = interpol($p, pdl($values), $xs); |
| 251 |
1 |
| return $ramp->($p_adjusted); |
| 252 |
|
| } |
| 253 |
|
| else { |
| 254 |
2 |
| return $ramp->($p); |
| 255 |
|
| } |
| 256 |
4 |
| }; |
| 257 |
24 |
| } |
| 258 |
|
| |
| 259 |
2 |
▶ | fun seq_gradient_pal ($low, $high) { |
|
Subroutine
seq_gradient_pal: called CC=3 SCAR=11.3
Pod
undocumented
Branch: 2 branches
| Branch | True | False | Total |
| @_ < 2 and Function::Parameters::_croak('Too few arguments for fun seq_gradient_pal (expected 2, got ' . @_ . ')') |
0 |
2 |
2 |
| @_ > 2 and Function::Parameters::_croak('Too many arguments for fun seq_gradient_pal (expected 2, got ' . @_ . ')') |
0 |
2 |
2 |
|
| 260 |
2 |
| return gradient_n_pal( [ $low, $high ] ); |
| 261 |
24 |
| } |
| 262 |
|
| |
| 263 |
0 |
▶ | fun div_gradient_pal ($low, $mid, $high) { |
|
Subroutine
div_gradient_pal: not called CC=3 SCAR=24.8
Pod
undocumented
Branch: 2 branches
| Branch | True | False | Total |
| @_ < 3 and Function::Parameters::_croak('Too few arguments for fun div_gradient_pal (expected 3, got ' . @_ . ')') |
0 |
0 |
0 |
| @_ > 3 and Function::Parameters::_croak('Too many arguments for fun div_gradient_pal (expected 3, got ' . @_ . ')') |
0 |
0 |
0 |
|
| 264 |
0 |
| return gradient_n_pal( [ $low, $mid, $high ] ); |
| 265 |
24 |
| } |
| 266 |
|
| |
| 267 |
|
| # Rescale palette (continuous). |
| 268 |
0 |
▶ | fun rescale_pal ( $range = PDL->new( [ 0.1, 1 ] ) ) { |
|
Subroutine
rescale_pal: not called CC=3 SCAR=24.8
Pod
undocumented
Branch: 2 branches
| Branch | True | False | Total |
| @_ > 1 and Function::Parameters::_croak('Too many arguments for fun rescale_pal (expected 1, got ' . @_ . ')') |
0 |
0 |
0 |
| @_ < 1 and $range = "PDL"->new(["0.1", 1]) |
0 |
0 |
0 |
|
| 269 |
0 |
▶ | return fun($p) { |
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
Branch: 2 branches
| Branch | True | False | Total |
| @_ < 1 and Function::Parameters::_croak('Too few arguments for fun (anon) (expected 1, got ' . @_ . ')') |
0 |
0 |
0 |
| @_ > 1 and Function::Parameters::_croak('Too many arguments for fun (anon) (expected 1, got ' . @_ . ')') |
0 |
0 |
0 |
|
| 270 |
0 |
| rescale( $p, $range, PDL->new( [ 0, 1 ] ) ); |
| 271 |
0 |
| }; |
| 272 |
24 |
| } |
| 273 |
|
| |
| 274 |
1 |
▶ | fun viridis_pal ($begin=0, $end=1, $direction=1, $option='viridis') { |
|
Subroutine
viridis_pal: called CC=6 SCAR=19.1
Pod
undocumented
Branch: 5 branches
| Branch | True | False | Total |
| @_ > 4 and Function::Parameters::_croak('Too many arguments for fun viridis_pal (expected 4, got ' . @_ . ')') |
0 |
1 |
1 |
| @_ < 4 and do {
@_ < 3 and do {
@_ < 2 and do {
@_ < 1 and $begin = 0;
$end = 1
};
$direction = 1
};
$option = "viridis"
} |
1 |
0 |
1 |
| @_ < 3 and do {
@_ < 2 and do {
@_ < 1 and $begin = 0;
$end = 1
};
$direction = 1
} |
1 |
0 |
1 |
| @_ < 2 and do {
@_ < 1 and $begin = 0;
$end = 1
} |
1 |
0 |
1 |
| @_ < 1 and $begin = 0 |
1 |
0 |
1 |
|
| 275 |
1 |
▶ | return fun(Int $n) { |
|
Subroutine
__ANON__: called CC=4 SCAR=14.2
Branch: 3 branches
| Branch | True | False | Total |
| @_ < 1 and Function::Parameters::_croak('Too few arguments for fun (anon) (expected 1, got ' . @_ . ')') |
0 |
1 |
1 |
| @_ > 1 and Function::Parameters::_croak('Too many arguments for fun (anon) (expected 1, got ' . @_ . ')') |
0 |
1 |
1 |
| Type::Tiny::XS::Int($n) or Function::Parameters::_croak('In fun (anon): parameter 1 ($n): ' . ${my $v = bless( {"_is_core" => 1,"_overload_coderef" => sub { package Type::Tiny; BEGIN {${^WARNING_BITS} = "\x10\x01\x00\x00\x00\x50\x04\x00\x00\x00\x00\x00\x01\x40\x05\x45\x55\x15\x55\x55\x01\x00\x00"} use strict; Type::Tiny::XS::Int($_[0]) or _failed_check(13, 'Int', $_[0], 'exception_class', 'Error::TypeTiny::Assertion'); $_[0];},"_overrides_assert_return" => !!0,"coercion" => bless( {"_compiled_type_constraint_check" => sub ;,"display_name" => "to_Int","frozen" => 1,"name" => "__ANON__","type_coercion_map" => [],"type_constraint" => {}}, 'Type::Coercion' ),"compiled_type_constraint" => do{my $o},"constraint" => sub { package Types::Standard; no warnings; use strict; /\A-?[0-9]+\z/;},"definition_context" => {"file" => "/usr/local/lib/perl5/site_perl/5.44.0/Types/Standard.pm","line" => 361,"package" => "Types::Standard"},"deprecated" => !!0,"display_name" => "Int","exception_class" => "Error::TypeTiny::Assertion","inlined" => sub { package Types::Standard; use warnings; use strict; $Type::Tiny::AvoidCallbacks ? goto $orig_inlined : "$xsubname($_[1])";},"library" => "Types::Standard","name" => "Int","parent" => bless( {"_overload_coderef" => sub { package Type::Tiny; BEGIN {${^WARNING_BITS} = "\x10\x01\x00\x00\x00\x50\x04\x00\x00\x00\x00\x00\x01\x40\x05\x45\x55\x15\x55\x55\x01\x00\x00"} use strict; defined $_[0] and not ref $_[0] and &Scalar::Util::looks_like_number($_[0]) or _failed_check(12, 'Num', $_[0], 'exception_class', 'Error::TypeTiny::Assertion'); $_[0];},"_overrides_assert_return" => !!0,"coercion" => bless( {"_compiled_type_constraint_check" => sub ($) { package Eval::TypeTiny::Sandbox; use strict; defined $_[0] and not ref $_[0] and &Scalar::Util::looks_like_number($_[0]);},"display_name" => "to_Num","frozen" => 1,"name" => "__ANON__","type_coercion_map" => [],"type_constraint" => {}}, 'Type::Coercion' ),"compiled_type_constraint" => do{my $o},"constraint" => sub { package Type::Tiny; use warnings; use strict; !0;},"definition_context" => {"file" => "/usr/local/lib/perl5/site_perl/5.44.0/Types/Standard.pm","line" => 344,"package" => "Types::Standard"},"deprecated" => !!0,"display_name" => "Num","exception_class" => "Error::TypeTiny::Assertion","library" => "Types::Standard","moose_type" => bless( {"Types::TypeTiny::to_TypeTiny" => {},"_default_message" => sub { package Moose::Meta::TypeConstraint; use warnings; use strict; my $value = shift(); my $can_partialdump = &try(sub { require Devel::PartialDump; 'Devel::PartialDump'->VERSION(0.14); 1; } ); if ($can_partialdump) { $value = 'Devel::PartialDump'->new->dump($value); } else { $value = defined $value ? overload::StrVal($value) : 'undef'; } return q[Validation failed for '] . $name . "' with value $value";},"compiled_type_constraint" => sub { package Eval::Closure::Sandbox_184; use warnings; use strict; do { defined $_[0] and not ref $_[0] and &Scalar::Util::looks_like_number($_[0]) };},"constraint" => sub { package Moose::Meta::TypeConstraint; use warnings; use strict; 1;},"inline_environment" => {},"name" => "Types::Standard::Num","parent" => bless( {"Types::TypeTiny::to_TypeTiny" => bless( {"_overload_coderef" => sub { package Type::Tiny; BEGIN {${^WARNING_BITS} = "\x10\x01\x00\x00\x00\x50\x04\x00\x00\x00\x00\x00\x01\x40\x05\x45\x55\x15\x55\x55\x01\x00\x00"} use strict; defined $_[0] and not ref $_[0] and &Scalar::Util::looks_like_number($_[0]) or _failed_check(10, 'LaxNum', $_[0], 'exception_class', 'Error::TypeTiny::Assertion'); $_[0];},"_overrides_assert_return" => !!0,"coercion" => bless( {"_compiled_type_constraint_check" => do{my $o},"display_name" => "to_LaxNum","frozen" => 1,"name" => "__ANON__","type_coercion_map" => [],"type_constraint" => {}}, 'Type::Coercion' ),"compiled_type_constraint" => do{my $o},"constraint" => sub { package Types::Standard; no warnings; use strict; looks_like_number $_ and ref \$_ ne 'GLOB';},"definition_context" => {"file" => "/usr/local/lib/perl5/site_perl/5.44.0/Types/Standard.pm","line" => 309,"package" => "Types::Standard"},"deprecated" => !!0,"display_name" => "LaxNum","exception_class" => "Error::TypeTiny::Assertion","inlined" => sub { package Types::Standard; no warnings; use strict; &$maybe_load_modules('Scalar::Util', 'Scalar::Util'->VERSION ge '1.18' ? "defined($_[1]) && !ref($_[1]) && Scalar::Util::looks_like_number($_[1])" : "defined($_[1]) && !ref($_[1]) && Scalar::Util::looks_like_number($_[1]) && ref(\\($_[1])) ne 'GLOB'");},"library" => "Types::Standard","moose_type" => {},"name" => "LaxNum","parent" => bless( {"_is_core" => 1,"_overload_coderef" => sub { package Type::Tiny; BEGIN {${^WARNING_BITS} = "\x10\x01\x00\x00\x00\x50\x04\x00\x00\x00\x00\x00\x01\x40\x05\x45\x55\x15\x55\x55\x01\x00\x00"} use strict; Type::Tiny::XS::Str($_[0]) or _failed_check(9, 'Str', $_[0], 'exception_class', 'Error::TypeTiny::Assertion'); $_[0];},"_overrides_assert_return" => !!0,"coercion" => bless( {"_compiled_type_constraint_check" => sub ;,"display_name" => "to_Str","frozen" => 1,"name" => "__ANON__","type_coercion_map" => [],"type_constraint" => {}}, 'Type::Coercion' ),"compiled_type_constraint" => do{my $o},"constraint" => sub { package Types::Standard; no warnings; use strict; ref \$_ eq 'SCALAR' or ref \(my $val = $_) eq 'SCALAR';},"definition_context" => {"file" => "/usr/local/lib/perl5/site_perl/5.44.0/Types/Standard.pm","line" => 291,"package" => "Types::Standard"},"deprecated" => !!0,"display_name" => "Str","exception_class" => "Error::TypeTiny::Assertion","inlined" => sub { package Types::Standard; use warnings; use strict; $Type::Tiny::AvoidCallbacks ? goto $orig_inlined : "$xsubname($_[1])";},"library" => "Types::Standard","moose_type" => bless( {"Types::TypeTiny::to_TypeTiny" => {},"_default_message" => sub { package Moose::Meta::TypeConstraint; use warnings; use strict; my $value = shift(); my $can_partialdump = &try(sub { require Devel::PartialDump; 'Devel::PartialDump'->VERSION(0.14); 1; } ); if ($can_partialdump) { $value = 'Devel::PartialDump'->new->dump($value); } else { $value = defined $value ? overload::StrVal($value) : 'undef'; } return q[Validation failed for '] . $name . "' with value $value";},"compiled_type_constraint" => sub { package Eval::Closure::Sandbox_51; use warnings; use strict; do { do { do { defined $_[0] } and not ref $_[0] } and ref \$_[0] eq 'SCALAR' || ref \(my $val = $_[0]) eq 'SCALAR' };},"constraint" => sub { package Moose::Util::TypeConstraints::Builtins; use warnings; use strict; ref \$_ eq 'SCALAR' or ref \(my $val = $_) eq 'SCALAR';},"inline_environment" => {},"inlined" => sub { package Moose::Util::TypeConstraints::Builtins; use warnings; use strict; $_[0]->parent->_inline_check($_[1]) . ' && (' . 'ref(\\' . $_[1] . ') eq "SCALAR"' . ' || ref(\\(my $val = ' . $_[1] . ')) eq "SCALAR"' . ')';},"name" => "Str","package_defined_in" => "Moose::Util::TypeConstraints::Builtins","parent" => bless( {"_default_message" => sub { package Moose::Meta::TypeConstraint; use warnings; use strict; my $value = shift(); my $can_partialdump = &try(sub { require Devel::PartialDump; 'Devel::PartialDump'->VERSION(0.14); 1; } ); if ($can_partialdump) { $value = 'Devel::PartialDump'->new->dump($value); } else { $value = defined $value ? overload::StrVal($value) : 'undef'; } return q[Validation failed for '] . $name . "' with value $value";},"compiled_type_constraint" => sub { package Eval::Closure::Sandbox_49; use warnings; use strict; do { do { defined $_[0] } and not ref $_[0] };},"constraint" => sub { package Moose::Util::TypeConstraints::Builtins; use warnings; use strict; not ref $_;},"inline_environment" => {},"inlined" => sub { package Moose::Util::TypeConstraints::Builtins; use warnings; use strict; $_[0]->parent->_inline_check($_[1]) . ' && !ref(' . $_[1] . ')';},"name" => "Value","package_defined_in" => "Moose::Util::TypeConstraints::Builtins","parent" => bless( {"Types::TypeTiny::to_TypeTiny" => bless( {"_is_core" => 1,"_overload_coderef" => sub { package Type::Tiny; BEGIN {${^WARNING_BITS} = "\x10\x01\x00\x00\x00\x50\x04\x00\x00\x00\x00\x00\x01\x40\x05\x45\x55\x15\x55\x55\x01\x00\x00"} use strict; defined $_[0] or _failed_check(7, 'Defined', $_[0], 'exception_class', 'Error::TypeTiny::Assertion'); $_[0];},"_overrides_assert_return" => !!0,"coercion" => bless( {"_compiled_type_constraint_check" => sub ;,"display_name" => "to_Defined","frozen" => 1,"name" => "__ANON__","type_coercion_map" => [],"type_constraint" => {}}, 'Type::Coercion' ),"compiled_type_constraint" => do{my $o},"complementary_type" => bless( {"_is_core" => 1,"_overload_coderef" => sub { package Type::Tiny; BEGIN {${^WARNING_BITS} = "\x10\x01\x00\x00\x00\x50\x04\x00\x00\x00\x00\x00\x01\x40\x05\x45\x55\x15\x55\x55\x01\x00\x00"} use strict; defined $_[0] and _failed_check(6, 'Undef', $_[0], 'exception_class', 'Error::TypeTiny::Assertion'); $_[0];},"_overrides_assert_return" => !!0,"coercion" => bless( {"_compiled_type_constraint_check" => sub ;,"display_name" => "to_Undef","frozen" => 1,"name" => "__ANON__","type_coercion_map" => [],"type_constraint" => {}}, 'Type::Coercion' ),"compiled_type_constraint" => do{my $o},"complementary_type" => {},"constraint" => sub { package Types::Standard; no warnings; use strict; not defined $_;},"definition_context" => {"file" => "/usr/local/lib/perl5/site_perl/5.44.0/Types/Standard.pm","line" => 254,"package" => "Types::Standard"},"deprecated" => !!0,"display_name" => "Undef","exception_class" => "Error::TypeTiny::Assertion","inlined" => sub { package Types::Standard; no warnings; use strict; "!defined($_[1])";},"library" => "Types::Standard","name" => "Undef","parent" => bless( {"_is_core" => 1,"_overload_coderef" => sub { package Type::Tiny; BEGIN {${^WARNING_BITS} = "\x10\x01\x00\x00\x00\x50\x04\x00\x00\x00\x00\x00\x01\x40\x05\x45\x55\x15\x55\x55\x01\x00\x00"} use strict; '???'; $_[0];},"_overrides_assert_return" => !!0,"coercion" => bless( {"_compiled_type_constraint_check" => sub ;,"display_name" => "to_Item","frozen" => 1,"name" => "__ANON__","type_coercion_map" => [],"type_constraint" => {}}, 'Type::Coercion' ),"compiled_type_constraint" => do{my $o},"constraint" => do{my $o},"definition_context" => {"file" => "/usr/local/lib/perl5/site_perl/5.44.0/Types/Standard.pm","line" => 226,"package" => "Types::Standard"},"deprecated" => !!0,"display_name" => "Item","exception_class" => "Error::TypeTiny::Assertion","inlined" => sub { package Types::Standard; no warnings; use strict; '!!1';},"library" => "Types::Standard","name" => "Item","parent" => bless( {"_is_core" => 1,"_overload_coderef" => sub { package Type::Tiny; BEGIN {${^WARNING_BITS} = "\x10\x01\x00\x00\x00\x50\x04\x00\x00\x00\x00\x00\x01\x40\x05\x45\x55\x15\x55\x55\x01\x00\x00"} use strict; '???'; $_[0];},"_overrides_assert_return" => !!0,"coercion" => bless( {"_compiled_type_constraint_check" => do{my $o},"display_name" => "to_Any","frozen" => 1,"name" => "__ANON__","type_coercion_map" => [],"type_constraint" => {}}, 'Type::Coercion' ),"compiled_type_constraint" => do{my $o},"complement_name" => "None","constraint" => do{my $o},"definition_context" => {"file" => "/usr/local/lib/perl5/site_perl/5.44.0/Types/Standard.pm","line" => 220,"package" => "Types::Standard"},"deprecated" => !!0,"display_name" => "Any","exception_class" => "Error::TypeTiny::Assertion","inlined" => sub { package Types::Standard; no warnings; use strict; '!!1';},"library" => "Types::Standard","moose_type" => bless( {"Types::TypeTiny::to_TypeTiny" => {},"_default_message" => sub { package Moose::Meta::TypeConstraint; use warnings; use strict; my $value = shift(); my $can_partialdump = &try(sub { require Devel::PartialDump; 'Devel::PartialDump'->VERSION(0.14); 1; } ); if ($can_partialdump) { $value = 'Devel::PartialDump'->new->dump($value); } else { $value = defined $value ? overload::StrVal($value) : 'undef'; } return q[Validation failed for '] . $name . "' with value $value";},"compiled_type_constraint" => sub { package Eval::Closure::Sandbox_44; use warnings; use strict; do { 1 };},"constraint" => sub { package Moose::Util::TypeConstraints::Builtins; use warnings; use strict; 1;},"inline_environment" => {},"inlined" => sub { package Moose::Util::TypeConstraints::Builtins; use warnings; use strict; '1';},"name" => "Any","package_defined_in" => "Moose::Util::TypeConstraints::Builtins"}, 'Moose::Meta::TypeConstraint' ),"name" => "Any","type_default" => sub { package Types::Standard; no warnings; use strict; return undef;},"uniq" => 1}, 'Type::Tiny' ),"uniq" => 2}, 'Type::Tiny' ),"type_default" => sub { package Types::Standard; no warnings; use strict; return undef;},"uniq" => 6}, 'Type::Tiny' ),"constraint" => sub { package Types::Standard; no warnings; use strict; defined $_;},"definition_context" => {"file" => "/usr/local/lib/perl5/site_perl/5.44.0/Types/Standard.pm","line" => 262,"package" => "Types::Standard"},"deprecated" => !!0,"display_name" => "Defined","exception_class" => "Error::TypeTiny::Assertion","inlined" => sub { package Types::Standard; no warnings; use strict; "defined($_[1])";},"library" => "Types::Standard","moose_type" => {},"name" => "Defined","parent" => {},"uniq" => 7}, 'Type::Tiny' ),"_default_message" => sub { package Moose::Meta::TypeConstraint; use warnings; use strict; my $value = shift(); my $can_partialdump = &try(sub { require Devel::PartialDump; 'Devel::PartialDump'->VERSION(0.14); 1; } ); if ($can_partialdump) { $value = 'Devel::PartialDump'->new->dump($value); } else { $value = defined $value ? overload::StrVal($value) : 'undef'; } return q[Validation failed for '] . $name . "' with value $value";},"compiled_type_constraint" => sub { package Eval::Closure::Sandbox_47; use warnings; use strict; do { defined $_[0] };},"constraint" => sub { package Moose::Util::TypeConstraints::Builtins; use warnings; use strict; defined $_;},"inline_environment" => {},"inlined" => sub { package Moose::Util::TypeConstraints::Builtins; use warnings; use strict; 'defined(' . $_[1] . ')';},"name" => "Defined","package_defined_in" => "Moose::Util::TypeConstraints::Builtins","parent" => bless( {"_default_message" => sub { package Moose::Meta::TypeConstraint; use warnings; use strict; my $value = shift(); my $can_partialdump = &try(sub { require Devel::PartialDump; 'Devel::PartialDump'->VERSION(0.14); 1; } ); if ($can_partialdump) { $value = 'Devel::PartialDump'->new->dump($value); } else { $value = defined $value ? overload::StrVal($value) : 'undef'; } return q[Validation failed for '] . $name . "' with value $value";},"compiled_type_constraint" => sub { package Eval::Closure::Sandbox_45; use warnings; use strict; do { 1 };},"constraint" => do{my $o},"inline_environment" => {},"inlined" => sub { package Moose::Util::TypeConstraints::Builtins; use warnings; use strict; '1';},"name" => "Item","package_defined_in" => "Moose::Util::TypeConstraints::Builtins","parent" => {}}, 'Moose::Meta::TypeConstraint' )}, 'Moose::Meta::TypeConstraint' )}, 'Moose::Meta::TypeConstraint' )}, 'Moose::Meta::TypeConstraint' ),"name" => "Str","parent" => bless( {"_is_core" => 1,"_overload_coderef" => sub { package Type::Tiny; BEGIN {${^WARNING_BITS} = "\x10\x01\x00\x00\x00\x50\x04\x00\x00\x00\x00\x00\x01\x40\x05\x45\x55\x15\x55\x55\x01\x00\x00"} use strict; defined $_[0] and not ref $_[0] or _failed_check(8, 'Value', $_[0], 'exception_class', 'Error::TypeTiny::Assertion'); $_[0];},"_overrides_assert_return" => !!0,"coercion" => bless( {"_compiled_type_constraint_check" => sub ;,"display_name" => "to_Value","frozen" => 1,"name" => "__ANON__","type_coercion_map" => [],"type_constraint" => {}}, 'Type::Coercion' ),"compiled_type_constraint" => do{my $o},"constraint" => sub { package Types::Standard; no warnings; use strict; not ref $_;},"definition_context" => {"file" => "/usr/local/lib/perl5/site_perl/5.44.0/Types/Standard.pm","line" => 276,"package" => "Types::Standard"},"deprecated" => !!0,"display_name" => "Value","exception_class" => "Error::TypeTiny::Assertion","inlined" => sub { package Types::Standard; no warnings; use strict; "defined($_[1]) and not ref($_[1])";},"library" => "Types::Standard","name" => "Value","parent" => {},"uniq" => 8}, 'Type::Tiny' ),"sorter" => sub { package Types::Standard; no warnings; use strict; $_[0] cmp $_[1];},"type_default" => sub { package Types::Standard; no warnings; use strict; return '';},"uniq" => 9}, 'Type::Tiny' ),"sorter" => sub { package Types::Standard; no warnings; use strict; $_[0] <=> $_[1];},"type_default" => sub { package Types::Standard; no warnings; use strict; return 0;},"uniq" => 10}, 'Type::Tiny' ),"_default_message" => sub { package Moose::Meta::TypeConstraint; use warnings; use strict; my $value = shift(); my $can_partialdump = &try(sub { require Devel::PartialDump; 'Devel::PartialDump'->VERSION(0.14); 1; } ); if ($can_partialdump) { $value = 'Devel::PartialDump'->new->dump($value); } else { $value = defined $value ? overload::StrVal($value) : 'undef'; } return q[Validation failed for '] . $name . "' with value $value";},"compiled_type_constraint" => sub { package Eval::Closure::Sandbox_183; use warnings; use strict; do { defined $_[0] and not ref $_[0] and &Scalar::Util::looks_like_number($_[0]) };},"constraint" => do{my $o},"inline_environment" => {},"inlined" => sub { package Type::Tiny; use warnings; use strict; shift(); $self->inline_check(@_);},"name" => "Types::Standard::LaxNum","parent" => {}}, 'Moose::Meta::TypeConstraint' )}, 'Moose::Meta::TypeConstraint' ),"name" => "Num","parent" => {},"uniq" => 12}, 'Type::Tiny' ),"type_default" => sub { package Types::Standard; no warnings; use strict; return 0;},"uniq" => 13}, 'Type::Tiny' );$v->{"coercion"}{"type_constraint"} = $v;$v->{"compiled_type_constraint"} = $v->{"coercion"}{"_compiled_type_constraint_check"};$v->{"parent"}{"coercion"}{"type_constraint"} = $v->{"parent"};$v->{"parent"}{"compiled_type_constraint"} = $v->{"parent"}{"coercion"}{"_compiled_type_constraint_check"};$v->{"parent"}{"moose_type"}{"Types::TypeTiny::to_TypeTiny"} = $v->{"parent"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"coercion"}{"_compiled_type_constraint_check"} = $v->{"parent"}{"coercion"}{"_compiled_type_constraint_check"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"coercion"}{"type_constraint"} = $v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"compiled_type_constraint"} = $v->{"parent"}{"coercion"}{"_compiled_type_constraint_check"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"moose_type"} = $v->{"parent"}{"moose_type"}{"parent"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"coercion"}{"type_constraint"} = $v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"compiled_type_constraint"} = $v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"coercion"}{"_compiled_type_constraint_check"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"Types::TypeTiny::to_TypeTiny"} = $v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"coercion"}{"type_constraint"} = $v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"compiled_type_constraint"} = $v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"coercion"}{"_compiled_type_constraint_check"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"complementary_type"}{"coercion"}{"type_constraint"} = $v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"complementary_type"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"complementary_type"}{"compiled_type_constraint"} = $v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"complementary_type"}{"coercion"}{"_compiled_type_constraint_check"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"complementary_type"}{"complementary_type"} = $v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"complementary_type"}{"parent"}{"coercion"}{"type_constraint"} = $v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"complementary_type"}{"parent"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"complementary_type"}{"parent"}{"compiled_type_constraint"} = $v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"complementary_type"}{"parent"}{"coercion"}{"_compiled_type_constraint_check"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"complementary_type"}{"parent"}{"constraint"} = $v->{"parent"}{"constraint"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"complementary_type"}{"parent"}{"parent"}{"coercion"}{"_compiled_type_constraint_check"} = $v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"complementary_type"}{"parent"}{"coercion"}{"_compiled_type_constraint_check"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"complementary_type"}{"parent"}{"parent"}{"coercion"}{"type_constraint"} = $v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"complementary_type"}{"parent"}{"parent"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"complementary_type"}{"parent"}{"parent"}{"compiled_type_constraint"} = $v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"complementary_type"}{"parent"}{"coercion"}{"_compiled_type_constraint_check"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"complementary_type"}{"parent"}{"parent"}{"constraint"} = $v->{"parent"}{"constraint"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"complementary_type"}{"parent"}{"parent"}{"moose_type"}{"Types::TypeTiny::to_TypeTiny"} = $v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"complementary_type"}{"parent"}{"parent"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"moose_type"} = $v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"} = $v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"complementary_type"}{"parent"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"parent"}{"constraint"} = $v->{"parent"}{"moose_type"}{"constraint"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"parent"}{"parent"} = $v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"complementary_type"}{"parent"}{"parent"}{"moose_type"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"parent"}{"coercion"}{"type_constraint"} = $v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"parent"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"parent"}{"compiled_type_constraint"} = $v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"parent"}{"coercion"}{"_compiled_type_constraint_check"};$v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"parent"}{"parent"} = $v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"}{"parent"}{"parent"}{"Types::TypeTiny::to_TypeTiny"};$v->{"parent"}{"moose_type"}{"parent"}{"constraint"} = $v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"constraint"};$v->{"parent"}{"moose_type"}{"parent"}{"parent"} = $v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}{"parent"}{"moose_type"};$v->{"parent"}{"parent"} = $v->{"parent"}{"moose_type"}{"parent"}{"Types::TypeTiny::to_TypeTiny"}; \$v}->get_message($n)) |
1 |
0 |
1 |
|
| 276 |
1 |
| my $colors = |
| 277 |
|
| Chart::GGPlot::Util::Scales::_Viridis::viridis( $n, $begin, $end, |
| 278 |
|
| $direction, $option ); |
| 279 |
1 |
| my @palette = map { rgb_to_csshex(@$_); } @$colors; |
| 280 |
1 |
| return PDL::SV->new( \@palette ); |
| 281 |
1 |
| }; |
| 282 |
24 |
| } |
| 283 |
|
| |
| 284 |
0 |
▶ | fun area_pal ($range) { |
|
Subroutine
area_pal: not called CC=3 SCAR=24.8
Pod
undocumented
Branch: 2 branches
| Branch | True | False | Total |
| @_ < 1 and Function::Parameters::_croak('Too few arguments for fun area_pal (expected 1, got ' . @_ . ')') |
0 |
0 |
0 |
| @_ > 1 and Function::Parameters::_croak('Too many arguments for fun area_pal (expected 1, got ' . @_ . ')') |
0 |
0 |
0 |
|
| 285 |
0 |
| state $check = |
| 286 |
|
| Type::Params::compile( Piddle1D->plus_coercions(PiddleFromAny) ); |
| 287 |
0 |
| ($range) = $check->($range); |
| 288 |
|
| |
| 289 |
0 |
▶ | return fun($x) { return rescale( $x->sqrt, $range, pdl( [ 0, 1 ] ) ); }; |
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
Branch: 2 branches
| Branch | True | False | Total |
| @_ < 1 and Function::Parameters::_croak('Too few arguments for fun (anon) (expected 1, got ' . @_ . ')') |
0 |
0 |
0 |
| @_ > 1 and Function::Parameters::_croak('Too many arguments for fun (anon) (expected 1, got ' . @_ . ')') |
0 |
0 |
0 |
|
| 290 |
24 |
| } |
| 291 |
|
| |
| 292 |
0 |
▶ | fun identity_pal() { |
|
Subroutine
identity_pal: not called CC=2 SCAR=17.9
Pod
undocumented
Branch: 1 branch
| Branch | True | False | Total |
| @_ > 0 and Function::Parameters::_croak('Too many arguments for fun identity_pal (expected 0, got ' . @_ . ')') |
0 |
0 |
0 |
|
| 293 |
0 |
▶ | return fun($x) { $x }; |
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
Branch: 2 branches
| Branch | True | False | Total |
| @_ < 1 and Function::Parameters::_croak('Too few arguments for fun (anon) (expected 1, got ' . @_ . ')') |
0 |
0 |
0 |
| @_ > 1 and Function::Parameters::_croak('Too many arguments for fun (anon) (expected 1, got ' . @_ . ')') |
0 |
0 |
0 |
|
| 294 |
24 |
| } |
| 295 |
|
| |
| 296 |
|
| ## trans |
| 297 |
|
| |
| 298 |
57 |
▶ | fun extended_breaks ( $n = 5, @rest ) { |
|
Subroutine
extended_breaks: called CC=2 SCAR=7.1
Pod
undocumented
Branch: 1 branch
| Branch | True | False | Total |
| @_ < 1 and $n = 5 |
57 |
0 |
57 |
|
| 299 |
14 |
▶ | return fun($p) { |
|
Subroutine
__ANON__: called CC=4 SCAR=14.2
Branch: 2 branches
| Branch | True | False | Total |
| @_ < 1 and Function::Parameters::_croak('Too few arguments for fun (anon) (expected 1, got ' . @_ . ')') |
0 |
14 |
14 |
| @_ > 1 and Function::Parameters::_croak('Too many arguments for fun (anon) (expected 1, got ' . @_ . ')') |
0 |
14 |
14 |
|
| 300 |
14 |
| $p = $p->where( $p->isfinite ); |
| 301 |
14 |
▶ | return null if ( $p->isempty ); |
Branch: 1 branch
| Branch | True | False | Total |
| if $p->isempty |
0 |
14 |
14 |
|
| 302 |
|
| |
| 303 |
14 |
| my $range = range_($p); |
| 304 |
14 |
| return labeling_extended( $range->at(0), $range->at(1), $n, @rest ); |
| 305 |
57 |
| }; |
| 306 |
24 |
| } |
| 307 |
|
| |
| 308 |
|
| # Minor breaks. Places minor breaks between major breaks. |
| 309 |
91 |
▶ | fun regular_minor_breaks ( $reverse = false ) { |
|
Subroutine
regular_minor_breaks: called CC=3 SCAR=11.0
Pod
undocumented
Branch: 2 branches
| Branch | True | False | Total |
| @_ > 1 and Function::Parameters::_croak('Too many arguments for fun regular_minor_breaks (expected 1, got ' . @_ . ')') |
0 |
91 |
91 |
| @_ < 1 and $reverse = &false() |
1 |
90 |
91 |
|
| 310 |
|
| |
| 311 |
|
| # $n : To create $n - 1 minor breaks between two major breaks |
| 312 |
16 |
▶ | return fun( $b, $limits, $n ) { |
|
Subroutine
__ANON__: called CC=9 SCAR=22.1
Branch: 2 branches
| Branch | True | False | Total |
| @_ < 3 and Function::Parameters::_croak('Too few arguments for fun (anon) (expected 3, got ' . @_ . ')') |
0 |
16 |
16 |
| @_ > 3 and Function::Parameters::_croak('Too many arguments for fun (anon) (expected 3, got ' . @_ . ')') |
0 |
16 |
16 |
|
| 313 |
16 |
| my $b1 = $b->where( !is_na($b) ); |
| 314 |
|
| |
| 315 |
16 |
▶ | return PDL->null if ( $b1->length < 2 ); |
Branch: 1 branch
| Branch | True | False | Total |
| if $b1->length < 2 |
0 |
16 |
16 |
|
| 316 |
|
| |
| 317 |
16 |
| my ( $min_b, $max_b ) = ( $b1->min, $b1->max ); |
| 318 |
16 |
| my ( $min_limit, $max_limit ) = ( $limits->min, $limits->max ); |
| 319 |
|
| |
| 320 |
16 |
| my @b = @{ $b1->unpdl }; |
| 321 |
16 |
| my $bd = $b[1] - $b[0]; |
| 322 |
16 |
▶ | if ( !$reverse ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (not $reverse) { } |
2 |
14 |
16 |
|
| 323 |
2 |
▶ | if ( $min_limit < $min_b ) { unshift @b, ( $b[0] - $bd ); } |
Branch: 1 branch
| Branch | True | False | Total |
| if ($min_limit < $min_b) |
1 |
1 |
2 |
|
| 324 |
2 |
▶ | if ( $max_limit > $max_b ) { push @b, ( $b[-1] + $bd ); } |
Branch: 1 branch
| Branch | True | False | Total |
| if ($max_limit > $max_b) |
1 |
1 |
2 |
|
| 325 |
|
| } |
| 326 |
|
| else { |
| 327 |
14 |
▶ | if ( $max_limit > $max_b ) { unshift @b, ( $b[0] - $bd ); } |
Branch: 1 branch
| Branch | True | False | Total |
| if ($max_limit > $max_b) |
11 |
3 |
14 |
|
| 328 |
14 |
▶ | if ( $min_limit < $min_b ) { push @b, ( $b[-1] + $bd ); } |
Branch: 1 branch
| Branch | True | False | Total |
| if ($min_limit < $min_b) |
11 |
3 |
14 |
|
| 329 |
|
| } |
| 330 |
|
| |
| 331 |
72 |
▶ | my $seq_between = fun( $a, $b ) { |
|
Subroutine
__ANON__: called CC=3 SCAR=11.2
Branch: 2 branches
| Branch | True | False | Total |
| @_ < 2 and Function::Parameters::_croak('Too few arguments for fun (anon) (expected 2, got ' . @_ . ')') |
0 |
72 |
72 |
| @_ > 2 and Function::Parameters::_croak('Too many arguments for fun (anon) (expected 2, got ' . @_ . ')') |
0 |
72 |
72 |
|
| 332 |
72 |
| my $rslt = seq_n( $a, $b, $n + 1 )->unpdl; |
| 333 |
72 |
| pop @$rslt; |
| 334 |
72 |
| return $rslt; |
| 335 |
16 |
| }; |
| 336 |
|
| |
| 337 |
|
| my @breaks = |
| 338 |
16 |
| map { @{ $seq_between->( $b[$_], $b[ $_ + 1 ] ) } } ( 0 .. $#b - 1 ); |
| 339 |
16 |
| return discard( PDL->new( [ @breaks, $b[-1] ] ), $limits ); |
| 340 |
91 |
| } |
| 341 |
24 |
| } |
| 342 |
|
| |
| 343 |
|
| |
| 344 |
|
| |
| 345 |
|
| # Intermediate log-scale breaks |
| 346 |
|
| # Integer powers of base do not always return sufficient breaks. This function |
| 347 |
|
| # adds intermediate breaks which are integer multiples of integer powers of |
| 348 |
|
| # base. |
| 349 |
|
| |
| 350 |
|
| # $rng is $base-base log range |
| 351 |
1 |
▶ | fun log_sub_breaks ($base, $n, $rng) { |
|
Subroutine
log_sub_breaks: called CC=7 SCAR=20.0
Pod
undocumented
Branch: 2 branches
| Branch | True | False | Total |
| @_ < 3 and Function::Parameters::_croak('Too few arguments for fun log_sub_breaks (expected 3, got ' . @_ . ')') |
0 |
1 |
1 |
| @_ > 3 and Function::Parameters::_croak('Too many arguments for fun log_sub_breaks (expected 3, got ' . @_ . ')') |
0 |
1 |
1 |
|
| 352 |
1 |
| my $min = floor( $rng->at(0) ); |
| 353 |
1 |
| my $max = ceil( $rng->at(1) ); |
| 354 |
1 |
▶ | if ( $base <= 2 ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ($base <= 2) |
0 |
1 |
1 |
|
| 355 |
0 |
| return $base**pdl( [ $min .. $max ] ); |
| 356 |
|
| } |
| 357 |
1 |
| my @steps = (1); |
| 358 |
|
| |
| 359 |
|
| # delta() calculates the smallest distance in the log scale between the |
| 360 |
|
| # currectly selected breaks and a new candidate 'x' |
| 361 |
8 |
▶ | my $delta = sub { |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
|
| 362 |
8 |
| my ($x) = @_; |
| 363 |
8 |
| return ( pdl( [ $x, @steps, $base ] )->qsort->log / log($base) ) |
| 364 |
|
| ->diff->min; |
| 365 |
1 |
| }; |
| 366 |
1 |
▶ | my $candidate = |
Branch: 1 branch
| Branch | True | False | Total |
| floor($base) == $base ? : |
1 |
0 |
1 |
|
| 367 |
|
| pdl( [ 2 .. ( floor($base) == $base ? $base - 1 : $base ) ] ); |
| 368 |
1 |
▶ | while ( $candidate->length ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ($candidate->length) |
1 |
0 |
1 |
|
| 369 |
|
| my $best = |
| 370 |
1 |
| pdl( [ map { $delta->($_) } $candidate->flatten ] )->maximum_ind; |
| 371 |
1 |
| push @steps, $candidate->at($best); |
| 372 |
1 |
| $candidate = $candidate->slice( |
| 373 |
|
| pdl( |
| 374 |
|
| [ ( 0 .. $best - 1 ), ( $best + 1 .. $candidate->length - 1 ) ] |
| 375 |
|
| ) |
| 376 |
|
| ); |
| 377 |
|
| |
| 378 |
1 |
| my $breaks = pdl( map { ( $base**pdl( [ $min .. $max ] ) * $_ )->flatten } |
| 379 |
|
| @steps ); |
| 380 |
1 |
| my $relevant_breaks = |
| 381 |
|
| ( ( $base**$rng->at(0) <= $breaks ) & |
| 382 |
|
| ( $breaks <= $base**$rng->at(1) ) ); |
| 383 |
1 |
▶ | if ( $relevant_breaks->sum >= $n - 2 ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ($relevant_breaks->sum >= $n - 2) |
1 |
0 |
1 |
|
| 384 |
1 |
| my $breaks = $breaks->qsort; |
| 385 |
1 |
| my $lower_end = |
| 386 |
|
| List::AllUtils::max( |
| 387 |
|
| which( $base**$rng->at(0) <= $breaks )->min - 1, 0 ); |
| 388 |
1 |
| my $upper_end = |
| 389 |
|
| List::AllUtils::min( |
| 390 |
|
| which( $breaks <= $base**$rng->at(1) )->max + 1, |
| 391 |
|
| $breaks->length - 1 ); |
| 392 |
1 |
| return $breaks->slice( pdl( [ $lower_end .. $upper_end ] ) ); |
| 393 |
|
| } |
| 394 |
|
| } |
| 395 |
|
| |
| 396 |
0 |
| return extended_breaks($n)->( $base**$rng ); |
| 397 |
24 |
| } |
| 398 |
|
| |
| 399 |
25 |
▶ | fun log_breaks ($base=10, $n=5) { |
|
Subroutine
log_breaks: called CC=4 SCAR=14.9
Pod
documented
Branch: 3 branches
| Branch | True | False | Total |
| @_ > 2 and Function::Parameters::_croak('Too many arguments for fun log_breaks (expected 2, got ' . @_ . ')') |
0 |
25 |
25 |
| @_ < 2 and do {
@_ < 1 and $base = 10;
$n = 5
} |
25 |
0 |
25 |
| @_ < 1 and $base = 10 |
1 |
24 |
25 |
|
| 400 |
1 |
▶ | return fun($x) { |
|
Subroutine
__ANON__: called CC=6 SCAR=19.9
Branch: 2 branches
| Branch | True | False | Total |
| @_ < 1 and Function::Parameters::_croak('Too few arguments for fun (anon) (expected 1, got ' . @_ . ')') |
0 |
1 |
1 |
| @_ > 1 and Function::Parameters::_croak('Too many arguments for fun (anon) (expected 1, got ' . @_ . ')') |
0 |
1 |
1 |
|
| 401 |
1 |
| my $rng = range_( $x, true )->log / pdl($base)->log; |
| 402 |
1 |
| my $min = floor( $rng->at(0) ); |
| 403 |
1 |
| my $max = ceil( $rng->at(1) ); |
| 404 |
1 |
▶ | if ( $max == $min ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ($max == $min) |
0 |
1 |
1 |
|
| 405 |
0 |
| return $base**$min; |
| 406 |
|
| } |
| 407 |
1 |
| my $by = floor( ( $max - $min ) / $n + 1 ); |
| 408 |
1 |
▶ | do { |
Branch: 1 branch
| Branch | True | False | Total |
| $by > 0 and do {
do {
my $breaks = $base ** seq_by($min, $max, $by);
my $relevant_breaks = $base ** $rng->at(0) <= $breaks & $breaks <= $base ** $rng->at(1);
if ($relevant_breaks->sum >= $n - 2) {
return $breaks;
};
$by -= 1
}
} |
0 |
0 |
0 |
|
| 409 |
1 |
| my $breaks = $base**seq_by( $min, $max, $by ); |
| 410 |
1 |
| my $relevant_breaks = |
| 411 |
|
| ( ( $base**$rng->at(0) <= $breaks ) & |
| 412 |
|
| ( $breaks <= $base**$rng->at(1) ) ); |
| 413 |
1 |
▶ | if ( $relevant_breaks->sum >= $n - 2 ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ($relevant_breaks->sum >= $n - 2) |
1 |
0 |
1 |
|
| 414 |
1 |
| return $breaks; |
| 415 |
|
| } |
| 416 |
0 |
| $by -= 1; |
| 417 |
|
| } while ( $by > 0 ); |
| 418 |
0 |
| return log_sub_breaks( $base, $n, $rng ); |
| 419 |
25 |
| }; |
| 420 |
24 |
| } |
| 421 |
|
| |
| 422 |
|
| |
| 423 |
|
| # This is ported from R "labeling" package's rpretty(), which is unlike R's |
| 424 |
|
| # pretty() function in that it does not handle DateTime objects. |
| 425 |
9 |
▶ | fun pretty($x, :$n=5, :$min_n = $n % 3, :$shrink_sml = 0.75, |
|
Subroutine
pretty: called CC=24 SCAR=39.3
Pod
documented
|
| 426 |
9 |
▶ | :$high_u_bias = 1.5, :$u5_bias = 0.5 + 1.5 * $high_u_bias) { |
Branch: 8 branches
| Branch | True | False | Total |
| @_ < 1 and Function::Parameters::_croak('Too few arguments for fun pretty (expected 1, got ' . @_ . ')') |
0 |
9 |
9 |
| @_ > 1 and (@_ - 1) % 2 and Function::Parameters::_croak("Odd number of paired arguments for fun pretty") |
0 |
9 |
9 |
| exists ${__rest}{'n'} ? : |
5 |
4 |
9 |
| exists ${__rest}{'min_n'} ? : |
0 |
9 |
9 |
| exists ${__rest}{'shrink_sml'} ? : |
0 |
9 |
9 |
| exists ${__rest}{'high_u_bias'} ? : |
1 |
8 |
9 |
| exists ${__rest}{'u5_bias'} ? : |
0 |
9 |
9 |
| keys %{__rest} and Function::Parameters::_croak('In fun pretty: no such named parameter: ' . join(", ", sort(keys %{__rest}))) |
0 |
9 |
9 |
MC/DC0%0/2
@_ > 1 and (@_ - 1) % 2
@_ > 1
(@_ - 1) % 2
Truth table66%2/3
A and B
A= @_ > 1B= (@_ - 1) % 2
|
| 427 |
9 |
| my ($dmin, $dmax) = $x->minmax; |
| 428 |
9 |
| my $ndiv = $n; |
| 429 |
9 |
| my $h = $high_u_bias; |
| 430 |
9 |
| my $h5 = $u5_bias; |
| 431 |
9 |
| my $dx = $dmax - $dmin; |
| 432 |
|
| |
| 433 |
9 |
| my $cell; |
| 434 |
|
| my $i_small; |
| 435 |
9 |
| my $u; |
| 436 |
9 |
▶ | if ($dx == 0 and $dmax == 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ($dx == 0 and $dmax == 0) { } |
0 |
9 |
9 |
MC/DC0%0/2
$dx == 0 and $dmax == 0
$dx == 0
$dmax == 0
Truth table33%1/3
A and B
A= $dx == 0B= $dmax == 0
|
| 437 |
0 |
| $cell = $u = 1; |
| 438 |
0 |
| $i_small = true; |
| 439 |
|
| } else { |
| 440 |
9 |
| $cell = List::AllUtils::max(abs($dmin), abs($dmax)); |
| 441 |
9 |
▶ | $u = 1 + (($h5 >= 1.5 * $h + 0.5) ? 1 / (1 + $h) : 1.5/(1 + $h5)); |
Branch: 1 branch
| Branch | True | False | Total |
| $h5 >= 1.5 * $h + 0.5 ? : |
9 |
0 |
9 |
|
| 442 |
9 |
| $i_small = $dx < ($cell * $u * List::AllUtils::max(1, $ndiv) * 1e-7 * 3); |
| 443 |
|
| } |
| 444 |
9 |
▶ | if ($i_small) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ($i_small) { } |
0 |
9 |
9 |
|
| 445 |
0 |
▶ | if ($cell > 10) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ($cell > 10) |
0 |
0 |
0 |
|
| 446 |
0 |
| $cell = 9 + $cell / 10; |
| 447 |
|
| } |
| 448 |
0 |
| $cell = $cell * $shrink_sml; |
| 449 |
0 |
▶ | if ($min_n > 1) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ($min_n > 1) |
0 |
0 |
0 |
|
| 450 |
0 |
| $cell = $cell / $min_n; |
| 451 |
|
| } |
| 452 |
|
| } |
| 453 |
|
| else { |
| 454 |
9 |
| $cell = $dx; |
| 455 |
9 |
▶ | if ($ndiv > 1) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ($ndiv > 1) |
9 |
0 |
9 |
|
| 456 |
9 |
| $cell = $cell / $ndiv; |
| 457 |
|
| } |
| 458 |
|
| } |
| 459 |
9 |
| $cell = List::AllUtils::max($cell, 20 * 1e-7); |
| 460 |
|
| |
| 461 |
9 |
| my $base = 10 ** floor(log10($cell)); |
| 462 |
9 |
| my $unit = $base; |
| 463 |
9 |
▶ | if ((2 * $base) - $cell < $h * ($cell - $unit)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (2 * $base - $cell < $h * ($cell - $unit)) |
9 |
0 |
9 |
|
| 464 |
9 |
| $unit = 2 * $base; |
| 465 |
9 |
▶ | if ((5 * $base) - $cell < $h5 * ($cell - $unit)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (5 * $base - $cell < $h5 * ($cell - $unit)) |
5 |
4 |
9 |
|
| 466 |
5 |
| $unit = 5 * $base; |
| 467 |
5 |
▶ | if ((10 * $base) - $cell < $h * ($cell - $unit)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (10 * $base - $cell < $h * ($cell - $unit)) |
1 |
4 |
5 |
|
| 468 |
1 |
| $unit = 10 * $base; |
| 469 |
|
| } |
| 470 |
|
| } |
| 471 |
|
| } |
| 472 |
|
| |
| 473 |
9 |
| my $ns = floor($dmin/$unit + 1e-07); |
| 474 |
9 |
| my $nu = ceil($dmax/$unit - 1e-07); |
| 475 |
0 |
▶ | while ($ns * $unit > $dmin + (1e-07 * $unit)) { $ns--; } |
Branch: 1 branch
| Branch | True | False | Total |
| if ($ns * $unit > $dmin + "1e-07" * $unit) |
0 |
9 |
9 |
|
| 476 |
0 |
▶ | while ($nu * $unit < $dmax - (1e-07 * $unit)) { $nu++; } |
Branch: 1 branch
| Branch | True | False | Total |
| if ($nu * $unit < $dmax - "1e-07" * $unit) |
0 |
9 |
9 |
|
| 477 |
|
| |
| 478 |
9 |
| my $k = floor(0.5 + $nu - $ns); |
| 479 |
9 |
▶ | if ($k < $min_n) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ($k < $min_n) { } |
0 |
9 |
9 |
|
| 480 |
0 |
| $k = $min_n - $k; |
| 481 |
0 |
▶ | if ($ns >= 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ($ns >= 0) { } |
0 |
0 |
0 |
|
| 482 |
0 |
| $nu = $nu + $k/2; |
| 483 |
0 |
| $ns = $ns - $k/2 + $k % 2; |
| 484 |
|
| } |
| 485 |
|
| else { |
| 486 |
0 |
| $ns = $ns - $k/2; |
| 487 |
0 |
| $nu = $nu + $k/2 + $k % 2; |
| 488 |
|
| } |
| 489 |
0 |
| $ndiv = $min_n; |
| 490 |
|
| } |
| 491 |
|
| else { |
| 492 |
9 |
| $ndiv = $k; |
| 493 |
|
| } |
| 494 |
9 |
| my $graphmin = $ns * $unit; |
| 495 |
9 |
| my $graphmax = $nu * $unit; |
| 496 |
|
| |
| 497 |
9 |
| return seq_by($graphmin, $graphmax, $unit); |
| 498 |
24 |
| } |
| 499 |
|
| |
| 500 |
22 |
▶ | fun seq_dt (:$beg, :$end=undef, :$by, :$length=undef) { |
|
Subroutine
seq_dt: called CC=13 SCAR=26.2
Pod
undocumented
Branch: 5 branches
| Branch | True | False | Total |
| @_ < 4 and Function::Parameters::_croak('Too few arguments for fun seq_dt (expected 4, got ' . @_ . ')') |
0 |
22 |
22 |
| @_ > 0 and @_ % 2 and Function::Parameters::_croak("Odd number of paired arguments for fun seq_dt") |
0 |
22 |
22 |
| exists ${__rest}{'beg'} ? : |
22 |
0 |
22 |
| exists ${__rest}{'by'} ? : |
22 |
0 |
22 |
| keys %{__rest} and Function::Parameters::_croak('In fun seq_dt: no such named parameter: ' . join(", ", sort(keys %{__rest}))) |
0 |
22 |
22 |
MC/DC0%0/2
@_ > 0 and @_ % 2
@_ > 0
@_ % 2
Truth table33%1/3
A and B
A= @_ > 0B= @_ % 2
|
| 501 |
22 |
| state $check = Type::Params::compile( |
| 502 |
|
| ConsumerOf ['PDL::DateTime'], |
| 503 |
|
| Maybe [ ConsumerOf ['PDL::DateTime'] ], |
| 504 |
|
| Str |
| 505 |
|
| ); |
| 506 |
22 |
| ($beg, $end, $by) = $check->($beg, $end, $by); |
| 507 |
|
| |
| 508 |
22 |
| my $start_time = $beg->dt_at(0); |
| 509 |
|
| |
| 510 |
22 |
▶ | if ( $by ne 'halfmonth' ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ($by ne "halfmonth") |
21 |
1 |
22 |
|
| 511 |
21 |
| my ( $step, $unit ) = split( /\s+/, $by ); |
| 512 |
21 |
▶ | unless (defined $length) { |
Branch: 1 branch
| Branch | True | False | Total |
| unless (defined $length) |
14 |
7 |
21 |
|
| 513 |
14 |
| my $delta_f = "delta_${unit}s"; |
| 514 |
24 |
▶ | no strict 'refs'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
|
| 515 |
14 |
| $length = $beg->dt_unpdl('Time::Moment')->[0] |
| 516 |
|
| ->$delta_f( $end->dt_unpdl('Time::Moment')->[0] ) / $step; |
| 517 |
14 |
▶ | if ( ceil($length) == $length ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (ceil($length) == $length) |
7 |
7 |
14 |
|
| 518 |
7 |
| $length += 1; |
| 519 |
|
| } |
| 520 |
14 |
| $length = ceil($length); |
| 521 |
|
| } |
| 522 |
21 |
| return PDL::DateTime->new_sequence( $start_time, $length, $unit, |
| 523 |
|
| $step ); |
| 524 |
|
| } |
| 525 |
|
| |
| 526 |
|
| # else: by "halfmonth" |
| 527 |
1 |
▶ | my $at = |
Branch: 1 branch
| Branch | True | False | Total |
| defined $length ? : |
0 |
1 |
1 |
|
| 528 |
|
| defined $length |
| 529 |
|
| ? seq_dt( beg => $beg, by => '1 month', length => ceil( $length / 2 ) ) |
| 530 |
|
| : seq_dt( beg => $beg, by => '1 month', end => $end ); |
| 531 |
|
| |
| 532 |
|
| #TODO: $at->dt_day would hang here. For now let's workaround... |
| 533 |
|
| #my $md = List::AllUtils::uniq( @{ $at->dt_day } ); |
| 534 |
1 |
| my @md = List::AllUtils::uniq( map { $_->day_of_month } @{ $at->dt_unpdl('Time::Moment') } ); |
| 535 |
1 |
▶ | die unless @md == 1; |
Branch: 1 branch
| Branch | True | False | Total |
| unless @md == 1 |
0 |
1 |
1 |
|
| 536 |
|
| |
| 537 |
1 |
| my $md = $md[0]; |
| 538 |
1 |
▶ | my $at2 = |
Branch: 1 branch
| Branch | True | False | Total |
| $md < 15 ? : |
1 |
0 |
1 |
|
| 539 |
|
| $md < 15 |
| 540 |
|
| ? $at->dt_add( day => 14 ) |
| 541 |
|
| : $at->dt_add( day => 1 - $md, month => 1 ); |
| 542 |
|
| my $rslt = PDL::DateTime->new( |
| 543 |
1 |
| [ sort { $a <=> $b } ( @{ $at->unpdl }, @{ $at2->unpdl } ) ] ); |
| 544 |
1 |
| return $rslt; |
| 545 |
24 |
| } |
| 546 |
|
| |
| 547 |
11 |
▶ | fun dt_align ($pdldt, $unit, $start_on_monday=true) { |
|
Subroutine
dt_align: called CC=7 SCAR=19.7
Pod
undocumented
Branch: 3 branches
| Branch | True | False | Total |
| @_ < 2 and Function::Parameters::_croak('Too few arguments for fun dt_align (expected 2, got ' . @_ . ')') |
0 |
11 |
11 |
| @_ > 3 and Function::Parameters::_croak('Too many arguments for fun dt_align (expected 3, got ' . @_ . ')') |
0 |
11 |
11 |
| @_ < 3 and $start_on_monday = &true() |
11 |
0 |
11 |
|
| 548 |
11 |
▶ | if ( |
Branch: 1 branch
| Branch | True | False | Total |
| if (elem($unit, ["second", "minute", "hour", "day", "week", "month", "quarter", "year"])) |
4 |
7 |
11 |
|
| 549 |
|
| elem( |
| 550 |
|
| $unit, |
| 551 |
|
| [ |
| 552 |
|
| qw( |
| 553 |
|
| second minute hour |
| 554 |
|
| day week month quarter year |
| 555 |
|
| ) |
| 556 |
|
| ] |
| 557 |
|
| ) |
| 558 |
|
| ) |
| 559 |
|
| { |
| 560 |
4 |
| return $pdldt->dt_align($unit); |
| 561 |
|
| } |
| 562 |
|
| |
| 563 |
7 |
▶ | state $round_year = sub { |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
|
| 564 |
7 |
| my ( $x, $n ) = @_; |
| 565 |
|
| |
| 566 |
|
| return PDL::DateTime->new_from_datetime( |
| 567 |
|
| $x->dt_align('year')->dt_unpdl()->map( |
| 568 |
7 |
▶ | sub { |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
|
| 569 |
7 |
| my ( $y, $m, $d ) = split( /\-/, $_ ); |
| 570 |
7 |
| $y = int( $y / $n ) * $n; |
| 571 |
7 |
| "$y-$m-$d"; |
| 572 |
|
| } |
| 573 |
|
| ) |
| 574 |
7 |
| ); |
| 575 |
7 |
| }; |
| 576 |
|
| |
| 577 |
7 |
▶ | if ( $unit eq 'decade' ) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ($unit eq 'decade') { } |
3 |
4 |
7 |
| elsif ($unit eq 'century') { } |
4 |
0 |
4 |
|
| 578 |
3 |
| return $round_year->( $pdldt, 10 ); |
| 579 |
|
| } |
| 580 |
|
| elsif ( $unit eq 'century' ) { |
| 581 |
4 |
| return $round_year->( $pdldt, 100 ); |
| 582 |
|
| } |
| 583 |
24 |
| } |
| 584 |
|
| |
| 585 |
|
| # R pretty.Date() |
| 586 |
6 |
▶ | fun pretty_dt($x, :$n = 5, :$min_n = $n % 2, %rest) { |
|
Subroutine
pretty_dt: called CC=37 SCAR=51.1
Pod
undocumented
Branch: 4 branches
| Branch | True | False | Total |
| @_ < 1 and Function::Parameters::_croak('Too few arguments for fun pretty_dt (expected 1, got ' . @_ . ')') |
0 |
6 |
6 |
| @_ > 1 and (@_ - 1) % 2 and Function::Parameters::_croak("Odd number of paired arguments for fun pretty_dt") |
0 |
6 |
6 |
| exists $rest{'n'} ? : |
5 |
1 |
6 |
| exists $rest{'min_n'} ? : |
0 |
6 |
6 |
MC/DC0%0/2
@_ > 1 and (@_ - 1) % 2
@_ > 1
(@_ - 1) % 2
Truth table66%2/3
A and B
A= @_ > 1B= (@_ - 1) % 2
|
| 587 |
6 |
| state $check = Type::Params::compile(ConsumerOf['PDL::DateTime']); |
| 588 |
6 |
| ($x) = $check->($x); |
| 589 |
|
| |
| 590 |
6 |
| my $zz = my $rx = PDL::DateTime->new([$x->min, $x->max]); |
| 591 |
|
| |
| 592 |
6 |
| my $MIN = 60; |
| 593 |
6 |
| my $HOUR = $MIN * 60; |
| 594 |
6 |
| my $DAY = $HOUR * 24; |
| 595 |
6 |
| my $YEAR = $DAY * 365.25; |
| 596 |
6 |
| my $MONTH = $YEAR / 12; |
| 597 |
|
| |
| 598 |
12 |
▶ | state $diff_secs = sub { |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
|
| 599 |
12 |
| my ($zz) = @_; |
| 600 |
12 |
| my $x = $zz->double_epoch; |
| 601 |
12 |
| return ($x->at(1) - $x->at(0)); |
| 602 |
6 |
| }; |
| 603 |
|
| |
| 604 |
6 |
| my $D = $diff_secs->($zz); |
| 605 |
|
| |
| 606 |
6 |
▶ | state $make_output = sub { |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
|
| 607 |
6 |
| my ($at, $s, $round) = @_; |
| 608 |
|
| |
| 609 |
|
| # TODO: R implementation may round to date here if $x is Date. |
| 610 |
|
| # We don't do it so far because we don't have Date vs. DateTime yet. |
| 611 |
|
| # $round //= true; |
| 612 |
6 |
| Role::Tiny->apply_roles_to_object($at, 'PDL::Role::HasNames'); |
| 613 |
6 |
| $at->names($at->dt_unpdl($s->{format})); |
| 614 |
6 |
| return $at; |
| 615 |
6 |
| }; |
| 616 |
|
| |
| 617 |
6 |
▶ | if ($D < $n * $DAY) { |
Branch: 2 branches
| Branch | True | False | Total |
| if ($D < $n * $DAY) { } |
0 |
6 |
6 |
| elsif ($D < 1) { } |
0 |
6 |
6 |
|
| 618 |
|
| |
| 619 |
|
| # TODO: Shall not align to day before we have Date vs DateTime. |
| 620 |
|
| # $zz = $zz->dt_align('day'); |
| 621 |
0 |
| my $r = round($n - $D / $DAY); |
| 622 |
0 |
| my $m = List::AllUtils::max(0, $r % 2); |
| 623 |
0 |
| my $m2 = $m + ($r % 2); |
| 624 |
0 |
| my $dd = seq_dt( |
| 625 |
|
| beg => PDL::DateTime->new( $zz->at(0) - $m * $DAY ), |
| 626 |
|
| end => PDL::DateTime->new( $zz->at(1) + $m2 * $DAY ), |
| 627 |
|
| by => '1 day' |
| 628 |
|
| ); |
| 629 |
0 |
▶ | while ($dd->length < $min_n + 1) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ($dd->length < $min_n + 1) |
0 |
0 |
0 |
|
| 630 |
0 |
▶ | if ($m < $m2) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ($m < $m2) { } |
0 |
0 |
0 |
|
| 631 |
0 |
| $m = $m+1; |
| 632 |
|
| } else { |
| 633 |
0 |
| $m2 = $m2 + 1; |
| 634 |
|
| } |
| 635 |
|
| } |
| 636 |
0 |
| return $make_output->($dd, { format => "%b %d" }, false); |
| 637 |
|
| } elsif ($D < 1) { # unique values / sub-second ranges |
| 638 |
0 |
| my $m = List::AllUtils::min(30, List::AllUtils::max($D, $n/2)); |
| 639 |
|
| |
| 640 |
|
| # TODO: won't reach here now as we don't have Date vs. DateTime. |
| 641 |
|
| } |
| 642 |
6 |
| my $xspan = $diff_secs->($zz); |
| 643 |
6 |
▶ | my $steps = [ |
Branch: 2 branches
| Branch | True | False | Total |
| $xspan < $DAY ? : |
0 |
6 |
6 |
| $xspan < $YEAR ? : |
0 |
6 |
6 |
|
| 644 |
|
| { spec => '1 second', secs => 1, format => '%S', start => 'minute' }, |
| 645 |
|
| { spec => '2 second', secs => 2 }, |
| 646 |
|
| { spec => '5 second', secs => 5 }, |
| 647 |
|
| { spec => '10 second', secs => 10 }, |
| 648 |
|
| { spec => '15 second', secs => 15 }, |
| 649 |
|
| { spec => '30 second', secs => 30, format => '%H:%M:%S' }, |
| 650 |
|
| { spec => '1 minute', secs => $MIN, format => '%H:%M' }, |
| 651 |
|
| { spec => '2 minute', secs => 2 * $MIN, start => 'hour' }, |
| 652 |
|
| { spec => '5 minute', secs => 5 * $MIN }, |
| 653 |
|
| { spec => '10 minute', secs => 10 * $MIN }, |
| 654 |
|
| { spec => '15 minute', secs => 15 * $MIN }, |
| 655 |
|
| { spec => '30 minute', secs => 30 * $MIN }, |
| 656 |
|
| { |
| 657 |
|
| spec => '1 hour', |
| 658 |
|
| secs => $HOUR, |
| 659 |
|
| format => ( $xspan < $DAY ? '%H:%M' : '%b %d %H:%M' ) |
| 660 |
|
| }, |
| 661 |
|
| { spec => '3 hour', secs => 3 * $HOUR, start => 'day' }, |
| 662 |
|
| { spec => '6 hour', secs => 6 * $HOUR, format => '%b %d %H:%M' }, |
| 663 |
|
| { spec => '12 hour', secs => 12 * $HOUR }, |
| 664 |
|
| { spec => '1 day', secs => $DAY, format => '%b %d' }, |
| 665 |
|
| { spec => '2 day', secs => 2 * $DAY }, |
| 666 |
|
| { spec => '1 week', secs => 7 * $DAY, start => 'week' }, |
| 667 |
|
| { spec => 'halfmonth', secs => 0.5 * $MONTH, start => 'month' }, |
| 668 |
|
| { |
| 669 |
|
| spec => '1 month', |
| 670 |
|
| secs => $MONTH, |
| 671 |
|
| format => ( $xspan < $YEAR ? '%b' : '%b %Y' ) |
| 672 |
|
| }, |
| 673 |
|
| { spec => '3 month', secs => 3 * $MONTH, start => 'year' }, |
| 674 |
|
| { spec => '6 month', secs => 6 * $MONTH, format => '%Y-%m' }, |
| 675 |
|
| { spec => '1 year', secs => $YEAR, format => '%Y' }, |
| 676 |
|
| { spec => '2 year', secs => 2 * $YEAR, start => 'decade' }, |
| 677 |
|
| { spec => '5 year', secs => 5 * $YEAR }, |
| 678 |
|
| { spec => '10 year', secs => 10 * $YEAR }, |
| 679 |
|
| { spec => '20 year', secs => 20 * $YEAR, start => 'century' }, |
| 680 |
|
| { spec => '50 year', secs => 50 * $YEAR }, |
| 681 |
|
| { spec => '100 year', secs => 100 * $YEAR }, |
| 682 |
|
| { spec => '200 year', secs => 200 * $YEAR }, |
| 683 |
|
| { spec => '500 year', secs => 500 * $YEAR }, |
| 684 |
|
| { spec => '1000 year', secs => 1000 * $YEAR }, |
| 685 |
|
| ]; |
| 686 |
6 |
| for my $i (1 .. $#$steps) { |
| 687 |
192 |
▶ | $steps->[$i]{format} //= $steps->[$i-1]{format}; |
Condition66%2/3
$steps->[$i]{"format"} //= $$steps[$i - 1]{"format"}
MC/DC0%0/2
$steps->[$i]{"format"} //= $$steps[$i - 1]{"format"}
$steps->[$i]{"format"}
$$steps[$i - 1]{"format"}
Truth table66%2/3
A //= B
A= $steps->[$i]{"format"}B= $$steps[$i - 1]{"format"}
|
| 688 |
192 |
▶ | $steps->[$i]{start} //= $steps->[$i-1]{start}; |
Condition66%2/3
$steps->[$i]{"start"} //= $$steps[$i - 1]{"start"}
MC/DC0%0/2
$steps->[$i]{"start"} //= $$steps[$i - 1]{"start"}
$steps->[$i]{"start"}
$$steps[$i - 1]{"start"}
Truth table66%2/3
A //= B
A= $steps->[$i]{"start"}B= $$steps[$i - 1]{"start"}
|
| 689 |
|
| } |
| 690 |
|
| |
| 691 |
|
| # crudely work out number of steps in the given interval |
| 692 |
6 |
▶ | my $nsteps = $xspan / pdl($steps->map(sub { $_->{secs} })); |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
|
| 693 |
6 |
| my $init_i = my $init_i0 = ($nsteps-$n)->abs->minimum_ind; |
| 694 |
|
| |
| 695 |
|
| # calculate actual number of ticks in the given interval |
| 696 |
|
| |
| 697 |
11 |
▶ | my $calc_steps = sub { |
|
Subroutine
__ANON__: called CC=4 SCAR=14.2
|
| 698 |
11 |
| my ( $s, $lim ) = @_; |
| 699 |
11 |
▶ | $lim //= range_($zz); |
MC/DC0%0/2
$lim //= range_($zz)
$lim
range_($zz)
Truth table33%1/3
A //= B
A= $limB= range_($zz)
|
| 700 |
|
| |
| 701 |
11 |
| my $spec = $s->{spec}; |
| 702 |
|
| |
| 703 |
11 |
| my $start = dt_align( PDL::DateTime->new($lim->at(0)), $s->{start} ); |
| 704 |
11 |
| my $at = seq_dt( |
| 705 |
|
| beg => $start, |
| 706 |
|
| end => PDL::DateTime->new( $lim->at(1) ), |
| 707 |
|
| by => $spec |
| 708 |
|
| ); |
| 709 |
11 |
| my $r1 = List::AllUtils::max( $at->where( $at <= $lim->at(0) )->length - 1, 0 ); |
| 710 |
11 |
| my $r2 = $at->length - $at->where( $at >= $lim->at(1) )->length; |
| 711 |
11 |
▶ | if ( $r2 == $at->length ) |
Branch: 1 branch
| Branch | True | False | Total |
| if ($r2 == $at->length) |
7 |
4 |
11 |
|
| 712 |
|
| { # not covering at right -- add point at right |
| 713 |
7 |
| my $nat = seq_dt( |
| 714 |
|
| beg => PDL::DateTime->new( $at->at(-1) ), |
| 715 |
|
| by => $spec, |
| 716 |
|
| length => 2 |
| 717 |
|
| )->slice( pdl( [1] ) ); |
| 718 |
7 |
▶ | unless ( $nat->where( $nat > $at->at(-1) )->length == $nat->length ) { # failed |
Branch: 1 branch
| Branch | True | False | Total |
| unless ($nat->where($nat > $at->at(-1))->length == $nat->length) |
0 |
7 |
7 |
|
| 719 |
0 |
| $r2 = $at->length - 1; |
| 720 |
|
| } |
| 721 |
7 |
| $at = PDL::DateTime->new( $at->glue( 0, $nat ) ); |
| 722 |
|
| } |
| 723 |
11 |
| return $at->slice( pdl( [ $r1 .. $r2 ] ) ); |
| 724 |
6 |
| }; |
| 725 |
|
| |
| 726 |
6 |
| my $init_at = $calc_steps->(my $st_i = $steps->[$init_i]); |
| 727 |
|
| |
| 728 |
|
| # bump it up if below acceptable threshold |
| 729 |
6 |
| my $R = true; |
| 730 |
6 |
| my $L_fail = my $R_fail = false; |
| 731 |
6 |
| my $init_n = $init_at->length - 2; |
| 732 |
6 |
▶ | while ($init_n < $min_n) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ($init_n < $min_n) |
0 |
6 |
6 |
|
| 733 |
0 |
▶ | if ($init_i == 0) { # keep steps->[0] |
Branch: 1 branch
| Branch | True | False | Total |
| if ($init_i == 0) { } |
0 |
0 |
0 |
|
| 734 |
|
| # add new interval right or left |
| 735 |
0 |
▶ | if ($R) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ($R) { } |
0 |
0 |
0 |
|
| 736 |
0 |
| my $nat = seq_dt(beg => $init_at->at(-1), by => $st_i->{spec}, length => 2)->slice(pdl([1])); |
| 737 |
0 |
▶ | $R_fail = ($nat->isbad->at(0) or $nat->at(0) > $init_at->at(-1)); |
Condition0%0/3
$nat->isbad->at(0) || $nat->at(0) > $init_at->at(-1)
MC/DC0%0/2
$nat->isbad->at(0) || $nat->at(0) > $init_at->at(-1)
$nat->isbad->at(0)
$nat->at(0) > $init_at->at(-1)
Truth table0%0/3
A || B
A= $nat->isbad->at(0)B= $nat->at(0) > $init_at->at(-1)
|
| 738 |
0 |
▶ | unless ($R_fail) { |
Branch: 1 branch
| Branch | True | False | Total |
| unless ($R_fail) |
0 |
0 |
0 |
|
| 739 |
0 |
| $init_at->dt_set(-1, $nat->dt_at(0)); |
| 740 |
|
| } |
| 741 |
|
| } else { # left |
| 742 |
0 |
| my $nat = seq_dt(beg => $init_at->at(-1), by => "-$st_i->{spec}", length => 2)->slice(pdl([1])); |
| 743 |
0 |
▶ | $L_fail = ($nat->isbad->at(0) or $nat->at(0) < $init_at->at(0)); |
Condition0%0/3
$nat->isbad->at(0) || $nat->at(0) < $init_at->at(0)
MC/DC0%0/2
$nat->isbad->at(0) || $nat->at(0) < $init_at->at(0)
$nat->isbad->at(0)
$nat->at(0) < $init_at->at(0)
Truth table0%0/3
A || B
A= $nat->isbad->at(0)B= $nat->at(0) < $init_at->at(0)
|
| 744 |
0 |
▶ | unless ($L_fail) { |
Branch: 1 branch
| Branch | True | False | Total |
| unless ($L_fail) |
0 |
0 |
0 |
|
| 745 |
0 |
| $init_at->dt_set(0, $nat->dt_at(0)); |
| 746 |
|
| } |
| 747 |
|
| } |
| 748 |
0 |
▶ | if ($R_fail and $L_fail) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ($R_fail and $L_fail) |
0 |
0 |
0 |
MC/DC0%0/2
$R_fail and $L_fail
$R_fail
$L_fail
Truth table0%0/3
A and B
A= $R_failB= $L_fail
|
| 749 |
0 |
| die q{failed to add more ticks; $min_n too large?}; |
| 750 |
|
| } |
| 751 |
0 |
| $R = !$R; # alternating right <-> left |
| 752 |
|
| } else { # smaller step sizes |
| 753 |
0 |
| $init_i = $init_i - 1; |
| 754 |
0 |
| $st_i = $steps->[$init_i]; |
| 755 |
0 |
| $init_at = $calc_steps->($st_i); |
| 756 |
|
| } |
| 757 |
|
| } |
| 758 |
|
| |
| 759 |
6 |
▶ | if ($init_n == $n - 1 ) { # perfect |
Branch: 1 branch
| Branch | True | False | Total |
| if ($init_n == $n - 1) |
1 |
5 |
6 |
|
| 760 |
1 |
| return $make_output->($init_at, $st_i); |
| 761 |
|
| } |
| 762 |
|
| # else: have a different dn |
| 763 |
5 |
| my $dn = $init_n - ($n - 1); |
| 764 |
5 |
▶ | if ($dn > 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ($dn > 0) |
3 |
2 |
5 |
|
| 765 |
|
| # ticks "outside", on left and right, keep at least one on each side |
| 766 |
3 |
| my $nl = $init_at->where( $init_at <= $rx->at(0) )->length - 1; |
| 767 |
3 |
| my $nr = $init_at->where( $init_at >= $rx->at(1) )->length - 1; |
| 768 |
3 |
▶ | if ($nl > 0 or $nr > 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ($nl > 0 or $nr > 0) |
0 |
3 |
3 |
MC/DC0%0/2
$nl > 0 or $nr > 0
$nl > 0
$nr > 0
Truth table33%1/3
A or B
A= $nl > 0B= $nr > 0
|
| 769 |
0 |
| my $n_c = $nl + $nr; |
| 770 |
0 |
▶ | if ($dn < $n_c) { # remove $dn, not all |
Branch: 1 branch
| Branch | True | False | Total |
| if ($dn < $n_c) |
0 |
0 |
0 |
|
| 771 |
0 |
| $nl = round($dn * $nl / $n_c); |
| 772 |
0 |
| $nr = $dn - $nl; |
| 773 |
|
| } |
| 774 |
|
| # remove nl on left, nr on right |
| 775 |
0 |
| $init_at = $init_at->slice(pdl([$nl .. $init_at->length-$nr - 1])); |
| 776 |
|
| } |
| 777 |
|
| } |
| 778 |
|
| |
| 779 |
5 |
| $dn = $init_at->length - 1 - $n; |
| 780 |
5 |
▶ | if ( $dn == 0 # perfect |
Branch: 1 branch
| Branch | True | False | Total |
| if ($dn == 0 or $dn > 0 and $init_i < $init_i0 or $dn < 0 and $init_i == 0) |
0 |
5 |
5 |
Condition50%6/12
$dn == 0 or $dn > 0 and $init_i < $init_i0 or $dn < 0 and $init_i == 0
$dn == 0 or $dn > 0 and $init_i < $init_i0
$dn > 0 and $init_i < $init_i0
MC/DC0%0/5
$dn == 0 or $dn > 0 and $init_i < $init_i0 or $dn < 0 and $init_i == 0
$dn == 0
$dn > 0
$init_i < $init_i0
$dn < 0
$init_i == 0
Truth table0%0/8
A or B and C or D and E
A= $dn == 0B= $dn > 0C= $init_i < $init_i0D= $dn < 0E= $init_i == 0
| A | B | C | D | E | result |
| 1 | X | X | X | X | 1 |
| 0 | 1 | 1 | X | X | 1 |
| 0 | 0 | X | 1 | 1 | 1 |
| 0 | 1 | 0 | 1 | 1 | 1 |
| 0 | 0 | X | 0 | X | 0 |
| 0 | 0 | X | 1 | 0 | 0 |
| 0 | 1 | 0 | 0 | X | 0 |
| 0 | 1 | 0 | 1 | 0 | 0 |
|
| 781 |
|
| or ($dn > 0 and $init_i < $init_i0) # too many, but we tried $init_i + 1 already |
| 782 |
|
| or ($dn < 0 and $init_i == 0)) # too few but $init_i == 0 |
| 783 |
|
| { |
| 784 |
0 |
| return $make_output->($init_at, $st_i); |
| 785 |
|
| } |
| 786 |
|
| |
| 787 |
5 |
▶ | my $new_i = |
Branch: 1 branch
| Branch | True | False | Total |
| $dn > 0 ? : |
3 |
2 |
5 |
|
| 788 |
|
| ( $dn > 0 |
| 789 |
|
| ? List::AllUtils::min( $init_i + 1, $steps->length - 1 ) |
| 790 |
|
| : $init_i - 1 ); |
| 791 |
5 |
| my $new_at = $calc_steps->($steps->[$new_i]); |
| 792 |
5 |
| my $new_n = $new_at->length - 1; |
| 793 |
|
| |
| 794 |
|
| # work out whether new.at or init.at is better |
| 795 |
5 |
▶ | if ($new_n < $min_n) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ($new_n < $min_n) |
0 |
5 |
5 |
|
| 796 |
0 |
| $new_n = "-Inf"; |
| 797 |
|
| } |
| 798 |
|
| return |
| 799 |
5 |
▶ | abs( $new_n - $n ) < abs($dn) |
Branch: 1 branch
| Branch | True | False | Total |
| abs $new_n - $n < abs $dn ? : |
0 |
5 |
5 |
|
| 800 |
|
| ? $make_output->( $new_at, $steps->[$new_i] ) |
| 801 |
|
| : $make_output->( $init_at, $st_i ); |
| 802 |
24 |
| } |
| 803 |
|
| |
| 804 |
|
| |
| 805 |
9 |
▶ | fun pretty_breaks($n=5, %rest) { |
|
Subroutine
pretty_breaks: called CC=4 SCAR=14.2
Pod
documented
Branch: 2 branches
| Branch | True | False | Total |
| @_ > 1 and (@_ - 1) % 2 and Function::Parameters::_croak("Odd number of paired arguments for fun pretty_breaks") |
0 |
9 |
9 |
| @_ < 1 and $n = 5 |
9 |
0 |
9 |
MC/DC0%0/2
@_ > 1 and (@_ - 1) % 2
@_ > 1
(@_ - 1) % 2
Truth table33%1/3
A and B
A= @_ > 1B= (@_ - 1) % 2
|
| 806 |
7 |
▶ | return sub { |
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
|
| 807 |
7 |
| my ($x) = @_; |
| 808 |
|
| |
| 809 |
7 |
▶ | my $f = $x->$_DOES('PDL::DateTime') ? 'pretty_dt' : 'pretty'; |
Branch: 1 branch
| Branch | True | False | Total |
| $x->$Chart::GGPlot::Util::Scales::_DOES('PDL::DateTime') ? : |
5 |
2 |
7 |
|
| 810 |
24 |
▶ | no strict 'refs'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
|
| 811 |
7 |
| return $f->($x, n=>$n, %rest); |
| 812 |
9 |
| }; |
| 813 |
24 |
| } |
| 814 |
|
| |
| 815 |
3 |
▶ | fun dollar ($p, :$accuracy=undef, :$scale=1, |
|
Subroutine
dollar: called CC=17 SCAR=29.9
Pod
undocumented
|
| 816 |
|
| :$prefix='$', :$suffix='', |
| 817 |
|
| :$big_mark=',', :$decimal_mark='.', |
| 818 |
3 |
▶ | :$largest_with_cents=1e5, :$negative_parens=false) { |
Branch: 10 branches
| Branch | True | False | Total |
| @_ < 1 and Function::Parameters::_croak('Too few arguments for fun dollar (expected 1, got ' . @_ . ')') |
0 |
3 |
3 |
| @_ > 1 and (@_ - 1) % 2 and Function::Parameters::_croak("Odd number of paired arguments for fun dollar") |
0 |
3 |
3 |
| exists ${__rest}{'scale'} ? : |
0 |
3 |
3 |
| exists ${__rest}{'prefix'} ? : |
0 |
3 |
3 |
| exists ${__rest}{'suffix'} ? : |
0 |
3 |
3 |
| exists ${__rest}{'big_mark'} ? : |
0 |
3 |
3 |
| exists ${__rest}{'decimal_mark'} ? : |
0 |
3 |
3 |
| exists ${__rest}{'largest_with_cents'} ? : |
0 |
3 |
3 |
| exists ${__rest}{'negative_parens'} ? : |
1 |
2 |
3 |
| keys %{__rest} and Function::Parameters::_croak('In fun dollar: no such named parameter: ' . join(", ", sort(keys %{__rest}))) |
0 |
3 |
3 |
MC/DC0%0/2
@_ > 1 and (@_ - 1) % 2
@_ > 1
(@_ - 1) % 2
Truth table66%2/3
A and B
A= @_ > 1B= (@_ - 1) % 2
|
| 819 |
3 |
▶ | return PDL::SV->new( [] ) if ( $p->length == 0 ); |
Branch: 1 branch
| Branch | True | False | Total |
| if $p->length == 0 |
0 |
3 |
3 |
|
| 820 |
|
| |
| 821 |
3 |
▶ | $accuracy //= _need_cents( $p * $scale, $largest_with_cents ) ? 0.01 : 1; |
Branch: 1 branch
| Branch | True | False | Total |
| _need_cents($p * $scale, $largest_with_cents) ? : |
1 |
2 |
3 |
Condition50%1/2
$accuracy //= _need_cents($p * $scale, $largest_with_cents) ? "0.01" : 1
MC/DC0%0/1
$accuracy //= _need_cents($p * $scale, $largest_with_cents) ? "0.01" : 1
$accuracy
|
| 822 |
3 |
| my $precision = List::AllUtils::max( -floor( log10($accuracy) ), 0 ); |
| 823 |
3 |
| my $negative = ( $p->isgood & ( $p < 0 ) ); |
| 824 |
|
| |
| 825 |
3 |
▶ | my $fmt = Number::Format->new( |
Branch: 1 branch
| Branch | True | False | Total |
| $negative_parens ? : |
1 |
2 |
3 |
|
| 826 |
|
| -thousands_sep => $big_mark, |
| 827 |
|
| -mon_thousands_sep => $big_mark, |
| 828 |
|
| -decimal_point => $decimal_mark, |
| 829 |
|
| -mon_decimal_point => $decimal_mark, |
| 830 |
|
| -int_curr_symbol => $prefix, |
| 831 |
|
| ( $negative_parens ? ( -n_sign_posn => 0 ) : () ), |
| 832 |
|
| |
| 833 |
|
| # Number::Format would use locale's settings like P/N_SEP_BY_SPACE. |
| 834 |
|
| # Here we force these values to align with R's scale::dollar to make |
| 835 |
|
| # the behavior simple. |
| 836 |
|
| -p_sep_by_space => 0, |
| 837 |
|
| -n_sep_by_space => 0, |
| 838 |
|
| -p_cs_precedes => 1, |
| 839 |
|
| -n_cs_precedes => 1, |
| 840 |
|
| ); |
| 841 |
|
| |
| 842 |
24 |
▶ | no warnings 'numeric'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
|
| 843 |
3 |
| my @amount = map { $fmt->format_price( $_, $precision ); } @{ $p->unpdl }; |
| 844 |
|
| |
| 845 |
3 |
| my $rslt = PDL::SV->new( \@amount ); |
| 846 |
3 |
▶ | $rslt = $rslt->setbadif( $p->isbad ) if $p->badflag; |
Branch: 1 branch
| Branch | True | False | Total |
| if $p->badflag |
0 |
3 |
3 |
|
| 847 |
3 |
| return $rslt; |
| 848 |
24 |
| } |
| 849 |
|
| |
| 850 |
3 |
▶ | fun _need_cents ($p, $threshold) { |
|
Subroutine
_need_cents: called CC=7 SCAR=22.1
Branch: 2 branches
| Branch | True | False | Total |
| @_ < 2 and Function::Parameters::_croak('Too few arguments for fun _need_cents (expected 2, got ' . @_ . ')') |
0 |
3 |
3 |
| @_ > 2 and Function::Parameters::_croak('Too many arguments for fun _need_cents (expected 2, got ' . @_ . ')') |
0 |
3 |
3 |
|
| 851 |
3 |
▶ | return false if ($p->badflag and $p->isbad->all); |
Branch: 1 branch
| Branch | True | False | Total |
| if $p->badflag and $p->isbad->all |
0 |
3 |
3 |
Condition33%1/3
$p->badflag and $p->isbad->all
MC/DC0%0/2
$p->badflag and $p->isbad->all
$p->badflag
$p->isbad->all
Truth table33%1/3
A and B
A= $p->badflagB= $p->isbad->all
|
| 852 |
3 |
▶ | return false if ($p->abs->max > $threshold); |
Branch: 1 branch
| Branch | True | False | Total |
| if $p->abs->max > $threshold |
0 |
3 |
3 |
|
| 853 |
|
| return !( |
| 854 |
|
| ( |
| 855 |
3 |
▶ | $p->badflag |
Branch: 1 branch
| Branch | True | False | Total |
| $p->badflag ? : |
0 |
3 |
3 |
|
| 856 |
|
| ? ( ( $p->floor == $p ) | $p->isbad ) |
| 857 |
|
| : ( $p->floor == $p ) |
| 858 |
|
| )->all |
| 859 |
|
| ); |
| 860 |
24 |
| } |
| 861 |
|
| |
| 862 |
1 |
▶ | fun percent ($p, :$accuracy=undef, :$scale=100, |
|
Subroutine
percent: called CC=10 SCAR=25.9
Pod
undocumented
|
| 863 |
|
| :$prefix='', :$suffix="%", |
| 864 |
|
| :$big_mark=',', :$decimal_mark='.' |
| 865 |
1 |
▶ | ) { |
Branch: 8 branches
| Branch | True | False | Total |
| @_ < 1 and Function::Parameters::_croak('Too few arguments for fun percent (expected 1, got ' . @_ . ')') |
0 |
1 |
1 |
| @_ > 1 and (@_ - 1) % 2 and Function::Parameters::_croak("Odd number of paired arguments for fun percent") |
0 |
1 |
1 |
| exists ${__rest}{'scale'} ? : |
0 |
1 |
1 |
| exists ${__rest}{'prefix'} ? : |
0 |
1 |
1 |
| exists ${__rest}{'suffix'} ? : |
0 |
1 |
1 |
| exists ${__rest}{'big_mark'} ? : |
0 |
1 |
1 |
| exists ${__rest}{'decimal_mark'} ? : |
0 |
1 |
1 |
| keys %{__rest} and Function::Parameters::_croak('In fun percent: no such named parameter: ' . join(", ", sort(keys %{__rest}))) |
0 |
1 |
1 |
MC/DC0%0/2
@_ > 1 and (@_ - 1) % 2
@_ > 1
(@_ - 1) % 2
Truth table33%1/3
A and B
A= @_ > 1B= (@_ - 1) % 2
|
| 866 |
1 |
| return number( |
| 867 |
|
| $p, |
| 868 |
|
| accuracy => $accuracy, |
| 869 |
|
| scale => $scale, |
| 870 |
|
| prefix => $prefix, |
| 871 |
|
| suffix => $suffix |
| 872 |
|
| ); |
| 873 |
24 |
| } |
| 874 |
|
| |
| 875 |
1 |
▶ | fun comma ($p, :$big_mark=',', %rest) { |
|
Subroutine
comma: called CC=5 SCAR=17.8
Pod
undocumented
Branch: 3 branches
| Branch | True | False | Total |
| @_ < 1 and Function::Parameters::_croak('Too few arguments for fun comma (expected 1, got ' . @_ . ')') |
0 |
1 |
1 |
| @_ > 1 and (@_ - 1) % 2 and Function::Parameters::_croak("Odd number of paired arguments for fun comma") |
0 |
1 |
1 |
| exists $rest{'big_mark'} ? : |
0 |
1 |
1 |
MC/DC0%0/2
@_ > 1 and (@_ - 1) % 2
@_ > 1
(@_ - 1) % 2
Truth table33%1/3
A and B
A= @_ > 1B= (@_ - 1) % 2
|
| 876 |
1 |
| return number($p, big_mark => $big_mark, %rest); |
| 877 |
24 |
| } |
| 878 |
|
| |
| 879 |
3 |
▶ | fun number ($p, :$accuracy=1, :$scale=1, |
|
Subroutine
number: called CC=15 SCAR=27.7
Pod
undocumented
|
| 880 |
|
| :$big_mark=' ', :$decimal_mark='.', |
| 881 |
|
| :$prefix='', :$suffix='' |
| 882 |
3 |
▶ | ) { |
Branch: 9 branches
| Branch | True | False | Total |
| @_ < 1 and Function::Parameters::_croak('Too few arguments for fun number (expected 1, got ' . @_ . ')') |
0 |
3 |
3 |
| @_ > 1 and (@_ - 1) % 2 and Function::Parameters::_croak("Odd number of paired arguments for fun number") |
0 |
3 |
3 |
| exists ${__rest}{'accuracy'} ? : |
1 |
2 |
3 |
| exists ${__rest}{'scale'} ? : |
1 |
2 |
3 |
| exists ${__rest}{'big_mark'} ? : |
1 |
2 |
3 |
| exists ${__rest}{'decimal_mark'} ? : |
0 |
3 |
3 |
| exists ${__rest}{'prefix'} ? : |
1 |
2 |
3 |
| exists ${__rest}{'suffix'} ? : |
1 |
2 |
3 |
| keys %{__rest} and Function::Parameters::_croak('In fun number: no such named parameter: ' . join(", ", sort(keys %{__rest}))) |
0 |
3 |
3 |
MC/DC0%0/2
@_ > 1 and (@_ - 1) % 2
@_ > 1
(@_ - 1) % 2
Truth table66%2/3
A and B
A= @_ > 1B= (@_ - 1) % 2
|
| 883 |
3 |
▶ | return PDL::SV->new( [] ) if $p->length == 0; |
Branch: 1 branch
| Branch | True | False | Total |
| if $p->length == 0 |
0 |
3 |
3 |
|
| 884 |
|
| |
| 885 |
3 |
▶ | $accuracy //= _accuracy($p); |
Condition66%2/3
$accuracy //= _accuracy($p)
MC/DC0%0/2
$accuracy //= _accuracy($p)
$accuracy
_accuracy($p)
Truth table66%2/3
A //= B
A= $accuracyB= _accuracy($p)
|
| 886 |
3 |
| my $precision = |
| 887 |
|
| List::AllUtils::max( -floor( log10( $accuracy / $scale ) ), 0 ); |
| 888 |
3 |
| my $fmt = Number::Format->new( |
| 889 |
|
| -thousands_sep => $big_mark, |
| 890 |
|
| -decimal_point => $decimal_mark |
| 891 |
|
| ); |
| 892 |
|
| |
| 893 |
3 |
| my @s = ( $p * $scale )->list; |
| 894 |
24 |
▶ | no warnings 'numeric'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
|
| 895 |
10 |
| @s = map { "${prefix}${_}${suffix}" } |
| 896 |
3 |
▶ | map { $_ eq 'BAD' ? $_ : $fmt->format_number( $_, $precision ); } @s; |
Branch: 1 branch
| Branch | True | False | Total |
| $_ eq 'BAD' ? : |
0 |
10 |
10 |
|
| 897 |
|
| |
| 898 |
3 |
| my $rslt = PDL::SV->new( \@s ); |
| 899 |
3 |
▶ | $rslt->setbadif( $p->isbad ) if $p->badflag; |
Branch: 1 branch
| Branch | True | False | Total |
| if $p->badflag |
0 |
3 |
3 |
|
| 900 |
3 |
| return $rslt; |
| 901 |
24 |
| } |
| 902 |
|
| |
| 903 |
1 |
▶ | fun _accuracy ($p) { |
|
Subroutine
_accuracy: called CC=6 SCAR=19.0
Branch: 2 branches
| Branch | True | False | Total |
| @_ < 1 and Function::Parameters::_croak('Too few arguments for fun _accuracy (expected 1, got ' . @_ . ')') |
0 |
1 |
1 |
| @_ > 1 and Function::Parameters::_croak('Too many arguments for fun _accuracy (expected 1, got ' . @_ . ')') |
0 |
1 |
1 |
|
| 904 |
1 |
▶ | return 1 if ((!$p->isfinite)->all); |
Branch: 1 branch
| Branch | True | False | Total |
| if (!$p->isfinite)->all |
0 |
1 |
1 |
|
| 905 |
|
| |
| 906 |
1 |
| my $rng = range_($p, true, true); |
| 907 |
1 |
▶ | my $span = zero_range($rng) ? $rng->at(0)->abs : $rng->at(1) - $rng->at(0); |
Branch: 1 branch
| Branch | True | False | Total |
| zero_range($rng) ? : |
0 |
1 |
1 |
|
| 908 |
1 |
▶ | return 1 if ($span == 0); |
Branch: 1 branch
| Branch | True | False | Total |
| if $span == 0 |
0 |
1 |
1 |
|
| 909 |
1 |
| return 10 ** (pdl($span)->log10->floor); |
| 910 |
24 |
| } |
| 911 |
|
| |
| 912 |
|
| |
| 913 |
79 |
▶ | sub rgb255_to_csshex { sprintf("#%02x%02x%02x", @_); } |
|
Subroutine
rgb255_to_csshex: called CC=1 SCAR=0.0
Pod
documented
|
| 914 |
|
| |
| 915 |
66 |
▶ | sub rgb_to_csshex { |
|
Subroutine
rgb_to_csshex: called CC=1 SCAR=0.0
Pod
documented
|
| 916 |
|
| rgb255_to_csshex( |
| 917 |
66 |
| map { List::Util::max( 0, List::Util::min( 255, int( $_ * 256.0 ) ) ) } |
| 918 |
|
| @_ ); |
| 919 |
|
| } |
| 920 |
|
| |
| 921 |
7 |
▶ | sub csshex_to_rgb255 { |
|
Subroutine
csshex_to_rgb255: called CC=1 SCAR=0.0
Pod
documented
|
| 922 |
7 |
| my ($csshex) = @_; |
| 923 |
7 |
| return map { hex($_) } ( $csshex =~ /^#(..)(..)(..)/); |
| 924 |
|
| } |
| 925 |
|
| |
| 926 |
9 |
▶ | sub colorname_to_rgb255 { |
|
Subroutine
colorname_to_rgb255: called CC=2 SCAR=7.0
Pod
undocumented
|
| 927 |
9 |
| my ($color_name) = @_; |
| 928 |
9 |
| my $color = Color::Library->color($color_name); |
| 929 |
9 |
▶ | die "unknown color id '$color_name'" unless defined $color; |
Branch: 1 branch
| Branch | True | False | Total |
| unless defined $color |
0 |
9 |
9 |
|
| 930 |
9 |
| return $color->rgb; |
| 931 |
|
| } |
| 932 |
|
| |
| 933 |
4 |
▶ | sub colorname_to_csshex { |
|
Subroutine
colorname_to_csshex: called CC=1 SCAR=0.0
|
| 934 |
4 |
| my ($color_name) = @_; |
| 935 |
4 |
| return rgb255_to_csshex( colorname_to_rgb255($color_name) ); |
| 936 |
|
| } |
| 937 |
24 |
| memoize('colorname_to_csshex'); |
| 938 |
|
| |
| 939 |
24 |
| 1; |
| 940 |
|
| |
| 941 |
|
| __END__ |