diff --git a/Libtmp/Simplex/t/simplex.t b/Libtmp/Simplex/t/simplex.t index 16dd4a9a1..5e6da56c0 100644 --- a/Libtmp/Simplex/t/simplex.t +++ b/Libtmp/Simplex/t/simplex.t @@ -3,6 +3,7 @@ use warnings; use Test::More; use PDL::LiteF; use PDL::Opt::Simplex; +use Test::PDL -atol => 1e-3; sub test_simplex { local $Test::Builder::Level = $Test::Builder::Level + 1; @@ -15,24 +16,23 @@ sub test_simplex { sumover( ( $_[0] - $dis )**2 ) + 1; }, $nolog ? () : $logsub, ); - ok all PDL::Core::approx($opt, $dis, 1e-3), 'optimum' or diag "got=$opt"; - ok PDL::Core::approx($ssize, 0, 1e-3), 'ssize' or diag "got=$ssize"; - ok PDL::Core::approx($optval, 1, 1e-3), 'optval' or diag "got=$optval"; + is_pdl $opt, $dis, 'optimum' or diag "got=$opt"; + is_pdl $ssize, pdl(0), 'ssize' or diag "got=$ssize"; + is_pdl $optval, pdl(1), 'optval' or diag "got=$optval"; ok $log_called, 'log called' if !$nolog; my @init_dims = $init->dims; my @exp_dims = ($init_dims[0], 1, @init_dims[2..$#init_dims]); is_deeply [$opt->dims], \@exp_dims, 'dims optimum right'; } -test_simplex(pdl(2,2), 0.01, pdl(0,1)); -test_simplex(pdl(2,2), pdl(0.01,0.01), pdl(0,1)); -test_simplex(pdl(2,2), pdl(0.01,0.01), pdl(0,1), 1); -test_simplex(pdl(2,2,2), pdl(0.01,0.01,0.01), pdl(0,1,2)); -test_simplex(my $p = pdl(q[-1 -1; -1.1 -1; -1.1 -0.9]), pdl(0.01,0.01), pdl(0,1)); -test_simplex($p, undef, pdl(-1,1)); +test_simplex(pdl(2,2), 0.01, pdl([[0,1]])); +test_simplex(pdl(2,2), pdl(0.01,0.01), pdl([[0,1]])); +test_simplex(pdl(2,2), pdl(0.01,0.01), pdl([[0,1]]), 1); +test_simplex(pdl(2,2,2), pdl(0.01,0.01,0.01), pdl([[0,1,2]])); +test_simplex(my $p = pdl(q[-1 -1; -1.1 -1; -1.1 -0.9]), pdl(0.01,0.01), pdl([[0,1]])); +test_simplex($p, undef, pdl([[-1,1]])); my $s = make_simplex(pdl(0,0,0), pdl(0.12,0.12,0.12)); -ok all approx $s, pdl '0 -0.06 -0.08; 0.12 -0.06 -0.08; 0 0.06 -0.08; 0 0 0.04' - or diag "got=$s"; +is_pdl $s, pdl '0 -0.06 -0.08; 0.12 -0.06 -0.08; 0 0.06 -0.08; 0 0 0.04'; done_testing; diff --git a/Libtmp/Slatec/t/linfit.t b/Libtmp/Slatec/t/linfit.t index 356ea48e1..4b785577e 100644 --- a/Libtmp/Slatec/t/linfit.t +++ b/Libtmp/Slatec/t/linfit.t @@ -3,6 +3,7 @@ use warnings; use Test::More; use PDL::Fit::Linfit; use PDL::LiteF; +use Test::PDL; { # Simple Test Case: @@ -20,7 +21,7 @@ my ($yfit, $coeffs) = PDL::linfit1d($data, $fitFuncs); my @coefs = $coeffs->list; -ok all approx( $coeffs, pdl([3,2,3]) ); +is_pdl $coeffs, pdl([3,2,3]); } { @@ -92,7 +93,7 @@ my ($yfit, $coeffs) = linfit1d($data, $fitFuncs); my @coefs = $coeffs->list; -ok all approx( $coeffs, pdl( \@expectedCoefs ) ); +is_pdl $coeffs, pdl( \@expectedCoefs ); } done_testing; diff --git a/Libtmp/Slatec/t/slatec-polyfit-weight.t b/Libtmp/Slatec/t/slatec-polyfit-weight.t index cf8d792f5..0f22b0bab 100644 --- a/Libtmp/Slatec/t/slatec-polyfit-weight.t +++ b/Libtmp/Slatec/t/slatec-polyfit-weight.t @@ -3,6 +3,7 @@ use warnings; use Test::More; use Test::Exception; use PDL::LiteF; +use Test::PDL; use PDL::Slatec; ## Issue information @@ -25,13 +26,13 @@ lives_ok { $polyfit_orig = polyfit( $x, $y, $x->ones, 4, .0001 ); } 'polyfit() w subtest 'Passing the weight in a PDL of length 1' => sub { my $polyfit_pdl_len_one; lives_ok { $polyfit_pdl_len_one = polyfit( $x, $y, pdl(1), 4, .0001 ); }; - ok( approx($polyfit_orig, $polyfit_pdl_len_one)->all, 'passing a PDL of length 1 expands to the correct length' ); + is_pdl $polyfit_orig, $polyfit_pdl_len_one, 'passing a PDL of length 1 expands to the correct length'; }; subtest 'Passing the weight in a Perl scalar' => sub { my $polyfit_perl_scalar; lives_ok { $polyfit_perl_scalar = polyfit( $x, $y, 1, 4, .0001 ) }; - ok( approx($polyfit_orig, $polyfit_perl_scalar)->all, 'passing a Perl scalar expands to the correct length' ); + is_pdl $polyfit_orig, $polyfit_perl_scalar, 'passing a Perl scalar expands to the correct length'; }; done_testing;