From d98449cc68c3cb890ddabf6c90d348487b4b04b8 Mon Sep 17 00:00:00 2001 From: "Zak B. Elep" Date: Wed, 31 Oct 2018 11:51:12 +0800 Subject: [PATCH 1/5] Quadratic.pm: Fix tiny perlcritic issue Do not use the `$a` and `$b` variables which are used for `sort()`. --- lib/Math/Function/Interpolator/Quadratic.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Math/Function/Interpolator/Quadratic.pm b/lib/Math/Function/Interpolator/Quadratic.pm index 40b3a19..052a696 100644 --- a/lib/Math/Function/Interpolator/Quadratic.pm +++ b/lib/Math/Function/Interpolator/Quadratic.pm @@ -67,9 +67,9 @@ sub quadratic { my $solution; eval { $solution = $abc->simq($y) ; 1 } or confess 'Insoluble matrix: ' . $_; - my ( $a, $b, $c ) = @$solution; + my ( $A, $B, $C ) = @$solution; - return ( $a * ( $x**2 ) + $b * $x + $c ); + return ( $A * ( $x**2 ) + $B * $x + $C ); } =head1 AUTHOR From e1b2222714ad6ee3391a097732b8838ecf1d8322 Mon Sep 17 00:00:00 2001 From: "Zak B. Elep" Date: Wed, 31 Oct 2018 11:58:25 +0800 Subject: [PATCH 2/5] Cubic.pm: Simplify pairwise() in _spline_points() We just need to map() points between `$Xs` and `@y2_derivative` (which already have a 1:1 correspondence), so no need for the List::MoreUtils function. --- lib/Math/Function/Interpolator/Cubic.pm | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/Math/Function/Interpolator/Cubic.pm b/lib/Math/Function/Interpolator/Cubic.pm index c778ae4..a49ddfc 100644 --- a/lib/Math/Function/Interpolator/Cubic.pm +++ b/lib/Math/Function/Interpolator/Cubic.pm @@ -9,7 +9,6 @@ use warnings; our @ISA = qw(Math::Function::Interpolator); use Carp qw(confess); -use List::MoreUtils qw(pairwise indexes); use Number::Closest::XS qw(find_closest_numbers_around); use Scalar::Util qw(looks_like_number); @@ -83,7 +82,7 @@ sub _spline_points { $y_2derivative[$i] = $y_2derivative[$i] * $y_2derivative[ $i + 1 ] + $u[$i]; } - my %y_2derivative_combined = pairwise { $a => $b } @$Xs, @y_2derivative; + my %y_2derivative_combined = map { $Xs->[$_] => $y_2derivative[$_] } 0 .. $#y_2derivative; $self->{'_spline_points'} = \%y_2derivative_combined; From e74b87aed51c9b4099d89a4c0f58f85653f2b00c Mon Sep 17 00:00:00 2001 From: "Zak B. Elep" Date: Wed, 31 Oct 2018 12:29:50 +0800 Subject: [PATCH 3/5] Interpolator.pm: Simplify finding indexes for closest_three_points() List::MoreUtils::indexes() isn't really needed here. --- lib/Math/Function/Interpolator.pm | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/Math/Function/Interpolator.pm b/lib/Math/Function/Interpolator.pm index 0bb026b..6ebd4c7 100644 --- a/lib/Math/Function/Interpolator.pm +++ b/lib/Math/Function/Interpolator.pm @@ -8,7 +8,6 @@ use Carp qw(confess); use Scalar::Util qw(looks_like_number); use Number::Closest::XS qw(find_closest_numbers_around); -use List::MoreUtils qw(pairwise indexes); use List::Util qw(min max); use Math::Function::Interpolator::Linear; @@ -162,7 +161,7 @@ sub closest_three_points { my ($first, $second) = @{find_closest_numbers_around($sought, $all_points, 2)}; - my @indexes = indexes { $first == $_ or $second == $_ } @ap; + my @indexes = grep { $first == $ap[$_] or $second == $ap[$_] } 0 .. $#ap; my $third_index = (max(@indexes) < $length - 2) ? max(@indexes) + 1 : min(@indexes) - 1; my @sorted = sort { $a <=> $b } ($first, $second, $ap[$third_index]); From 26210c9c336edd102c41282282648ebf93c70054 Mon Sep 17 00:00:00 2001 From: "Zak B. Elep" Date: Wed, 31 Oct 2018 12:57:48 +0800 Subject: [PATCH 4/5] cpanfile: Remove List::MoreUtils No need for this dist anymore. --- cpanfile | 1 - 1 file changed, 1 deletion(-) diff --git a/cpanfile b/cpanfile index 9d3bc33..eef89ca 100644 --- a/cpanfile +++ b/cpanfile @@ -1,5 +1,4 @@ requires 'Carp'; -requires 'List::MoreUtils'; requires 'List::Util'; requires 'Math::Cephes::Matrix'; requires 'Number::Closest::XS'; From 242d27bfe6de2be90541b9834233fafeeb73cd92 Mon Sep 17 00:00:00 2001 From: "Zak B. Elep" Date: Wed, 31 Oct 2018 13:37:56 +0800 Subject: [PATCH 5/5] v1.03 - Remove List::MoreUtils and replace with simpler equivalents (pairwise, indexes) - Do not use `$a` and `$b` outside `sort()` --- Changes | 4 ++++ Makefile.PL | 4 +--- lib/Math/Function/Interpolator.pm | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Changes b/Changes index 8c3dce0..5494e33 100644 --- a/Changes +++ b/Changes @@ -2,6 +2,10 @@ Revision history for Math-Function-Interpolator {{$NEXT}} +1.03 2018-10-31 13:37:21+08:00 Asia/Manila + - Remove List::MoreUtils and replace with simpler equivalents (pairwise, indexes) + - Do not use `$a` and `$b` outside `sort()` + 1.02 2018-10-25 12:07:53+08:00 Asia/Manila Remove fatalized warnings diff --git a/Makefile.PL b/Makefile.PL index 30e0bca..8691726 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -18,7 +18,6 @@ my %WriteMakefileArgs = ( "NAME" => "Math::Function::Interpolator", "PREREQ_PM" => { "Carp" => 0, - "List::MoreUtils" => 0, "List::Util" => 0, "Math::Cephes::Matrix" => 0, "Number::Closest::XS" => 0, @@ -35,7 +34,7 @@ my %WriteMakefileArgs = ( "Test::FailWarnings" => 0, "Test::More" => "0.94" }, - "VERSION" => "1.02", + "VERSION" => "1.03", "test" => { "TESTS" => "t/*.t" } @@ -48,7 +47,6 @@ my %FallbackPrereqs = ( "File::Spec" => 0, "IO::Handle" => 0, "IPC::Open3" => 0, - "List::MoreUtils" => 0, "List::Util" => 0, "Math::Cephes::Matrix" => 0, "Number::Closest::XS" => 0, diff --git a/lib/Math/Function/Interpolator.pm b/lib/Math/Function/Interpolator.pm index 6ebd4c7..ab8990c 100644 --- a/lib/Math/Function/Interpolator.pm +++ b/lib/Math/Function/Interpolator.pm @@ -48,7 +48,7 @@ HashRef of points for interpolations =cut -our $VERSION = '1.02'; +our $VERSION = '1.03'; =head1 METHODS