Skip to content

Commit 61e55ba

Browse files
committed
GSL::CDF tests replace tapprox with is_pdl - #34 #393
1 parent 93b86bb commit 61e55ba

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

Libtmp/GSL/CDF/t/cdf.t

+6-13
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,15 @@ use warnings;
33
use Test::More;
44
use PDL::LiteF;
55
use PDL::GSL::CDF;
6+
use Test::PDL;
67

7-
sub tapprox {
8-
my($a,$b) = @_;
9-
my $diff = abs($a-$b);
10-
# use max to make it perl scalar
11-
ref $diff eq 'PDL' and $diff = $diff->max;
12-
return $diff < 1.0e-6;
13-
}
148
{
159
my $a = sequence 5;
16-
my $a_bad = sequence 6;
17-
$a_bad->setbadat(-1);
18-
is( tapprox( $a->gsl_cdf_tdist_P(1999)->sum, 4.31706715604714 ), 1 );
19-
is( tapprox( $a_bad->gsl_cdf_tdist_P(1999)->sum, 4.31706715604714 ), 1 );
20-
is( tapprox( $a->gsl_cdf_fdist_P(1,1999)->sum, 3.39605941459337 ), 1 );
21-
is( tapprox( $a_bad->gsl_cdf_fdist_P(1,1999)->sum, 3.39605941459337 ), 1 );
10+
my $a_bad = $a->append(pdl 'BAD');
11+
is_pdl $a->gsl_cdf_tdist_P(1999), my $texp = pdl('0.5 0.841284230695725 0.977182329566921 0.998633419750658 0.999967176033837');
12+
is_pdl $a_bad->gsl_cdf_tdist_P(1999), $texp->append(pdl 'BAD');
13+
is_pdl $a->gsl_cdf_fdist_P(1,1999), my $fexp = pdl('0 0.682568461391451 0.842545068166059 0.916581225902023 0.95436465913384');
14+
is_pdl $a_bad->gsl_cdf_fdist_P(1,1999), $fexp->append(pdl 'BAD');
2215
}
2316
{
2417
my $x = pdl('[0.185 0.242 0.385 0.528 0.671 0.814]');

0 commit comments

Comments
 (0)