Skip to content
This repository has been archived by the owner on Jan 23, 2022. It is now read-only.

Test cleanup 3 #7

Merged
merged 1 commit into from
Aug 29, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
52 changes: 0 additions & 52 deletions TODO
Original file line number Diff line number Diff line change
Expand Up @@ -37,58 +37,6 @@ the work planned for the future PDLA-2.x releases.
| TESTING |
+-------------------------------------------------------+


Refactor to use Test::More
* imagergb.t
* interp.t
* interp_slatec.t
* interpol.t
* limits_normalize_dsets.t
* linfit.t
* magic.t
* matmult.t
* ones.t
* pdlchar.t
* physical.t
* picnorgb.t
* picrgb.t
* pnm.t
* poly.t
* polyroots.t
* pthread.t
* pthread_auto.t
* reduce.t
* refs.t
* scope.t
* segfault.t
* thread.t
* thread_def.t
* vaffine.t

Convert from Test to Test::More
* bess.t
* conv.t
* diskcache.t
* erf.t
* erfi.t
* fft.t
* func.t
* hist.t
* image2d.t
* lut.t
* lvalue.t
* matrix.t
* matrixops.t
* niceslice.t
* nsdatahandle.t
* requiredmods.t
* round.t
* simplex.t
* transform.t
* trig.t
* xvals.t


Need to test PDLA build from scratch both WITH_BADVAL and without
* Find a way to automate this process for release testing
* Unix/Linux/BSD
Expand Down
31 changes: 18 additions & 13 deletions t/bess.t
Original file line number Diff line number Diff line change
@@ -1,32 +1,37 @@
# -*-perl-*-

use Test;
use Test::More tests => 6;

BEGIN { plan tests => 6; }
use strict;
use warnings;

use PDLA::LiteF;
use PDLA::Math;

kill INT,$$ if $ENV{UNDER_DEBUGGER}; # Useful for debugging.
kill 'INT',$$ if $ENV{UNDER_DEBUGGER}; # Useful for debugging.

sub tapprox {
my($a,$b) = @_;
$c = abs($a-$b);
$d = max($c);
$d < 0.01;
my($pa,$pb) = @_;
all approx $pa, $pb, 0.01;
}

ok( tapprox(bessj0(0.5),0.9384) && tapprox(bessj0(0),1) );
ok( tapprox(bessj1(0.1),0.0499) && tapprox(bessj1(0),0) );
ok( tapprox(bessjn(0.8,3),0.010) && tapprox(bessyn(0.2,2),-32.15714) );

{
# test inplace
$a = pdl(0.5,0.0);
$a->inplace->bessj0;
ok( tapprox($a,pdl(0.9384,1)) );
my $pa = pdl(0.5,0.0);
$pa->inplace->bessj0;
ok( tapprox($pa,pdl(0.9384,1)) );
}

$a = pdl(0.2);
$a->inplace->bessyn(2);
ok( tapprox( $a, -32.15714 ) ); # 5
{
my $pa = pdl(0.2);
$pa->inplace->bessyn(2);
ok( tapprox( $pa, -32.15714 ) ); # 5
}

{
ok( tapprox( pow(2,3),8)); # test for the pow bug
}
23 changes: 11 additions & 12 deletions t/bool.t
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use Test::More tests => 6;
use Test::More tests => 5;
use Test::Exception;
use PDLA::LiteF;
use strict;
Expand All @@ -15,17 +15,16 @@ kill 'INT',$$ if $ENV{UNDER_DEBUGGER}; # Useful for debugging.
{
my $pa = ones 3;
throws_ok { print "oops\n" if $pa } qr/multielement/;
ok all $pa;
}

$a = ones 3;
eval {print "oops\n" if $a};
like $@, qr/multielement/;

ok all $a;

$a = pdl byte, [ 0, 0, 1 ];
ok any $a > 0;
{
my $pa = pdl byte, [ 0, 0, 1 ];
ok any $pa > 0;
}

$a = ones 3;
$b = $a + 1e-4;
ok all PDLA::approx $a, $b, 1e-3;
{
my $pa = ones 3;
my $pb = $pa + 1e-4;
ok all PDLA::approx $pa, $pb, 1e-3;
}
38 changes: 18 additions & 20 deletions t/callext.t
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@ use File::Spec;
kill 'INT',$$ if $ENV{UNDER_DEBUGGER}; # Useful for debugging.

sub tapprox {
my($a,$b) = @_;
my $c = abs($a-$b);
my $d = max($c);
$d < 0.01;
my($pa,$pb) = @_;
all approx($pa, $pb, 0.01);
}

# Create the filenames
Expand Down Expand Up @@ -56,26 +54,26 @@ done_testing;

sub loglog {

die 'Usage: loglog($x,$y)' if scalar(@_)!=2;
die 'Usage: loglog($x,$y)' if scalar(@_)!=2;

# Tips:
#
# (i) topdl() forces arguments to be pdl vars even
# if ordinary numbers are passed
#
# (ii) float() forces the pdl vars to be float precision
# thus matching the C routine.
# Tips:
#
# (i) topdl() forces arguments to be pdl vars even
# if ordinary numbers are passed
#
# (ii) float() forces the pdl vars to be float precision
# thus matching the C routine.

my $x = float(topdl(shift));
my $y = float(topdl(shift));
my $x = float(topdl(shift));
my $y = float(topdl(shift));

my $ret = $x->copy; # Make copy of $x to return
my $ret = $x->copy; # Make copy of $x to return

print "X = $x\n";
print "Y = $y\n";
note "X = $x\n";
note "Y = $y\n";

my $ldfile =
callext($out, "loglog_ext", $ret, $y);
my $ldfile =
callext($out, "loglog_ext", $ret, $y);

return $ret;
return $ret;
}
14 changes: 7 additions & 7 deletions t/clump.t
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ $|=1;
# PDLA::Core::set_debugging(1);
kill 'INT',$$ if $ENV{UNDER_DEBUGGER}; # Useful for debugging.

#$a = zeroes(4,4) * zeroes(4,4);
# $a = zeroes(4,4) ;
#$pa = zeroes(4,4) * zeroes(4,4);
# $pa = zeroes(4,4) ;

#print $a;
#print $pa;
#
#print $a->at(3,3);
#print $pa->at(3,3);
#
#exit 4;

Expand Down Expand Up @@ -60,9 +60,9 @@ if(0) {
my $pa = xvals(zeroes(3,3)) + 10*yvals(zeroes(3,3));
note $pa;
my $pb = $pa->clump(-1);
# $b->make_physical();
# $a->jdump();
# $b->jdump();
# $pb->make_physical();
# $pa->jdump();
# $pb->jdump();

note $pb;

Expand Down
46 changes: 24 additions & 22 deletions t/conv.t
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,40 @@

# 1.9901 - converted to new type semantics + extra test

use Test;
BEGIN { plan tests => 7 }
use Test::More tests => 7;

use strict;
use warnings;

use PDLA::LiteF;
use PDLA::Types;

$a = pdl 42.4;
print "A is $a\n";
my $pa = pdl 42.4;
note "A is $pa";

ok($a->get_datatype,$PDLA_D);
is($pa->get_datatype,$PDLA_D);

$b = byte $a;
print "B (byte $a) is $b\n";
my $pb = byte $pa;
note "B (byte $pa) is $pb";

ok($b->get_datatype,$PDLA_B);
ok($b->at(),42);
is($pb->get_datatype,$PDLA_B);
is($pb->at(),42);

$c = $b * 3;
ok($c->get_datatype, $PDLA_B); # $c is the same
print "C ($b * 3) is $c\n";
my $pc = $pb * 3;
is($pc->get_datatype, $PDLA_B); # $pc is the same
note "C ($pb * 3) is $pc";

$d = $b * 600.0;
ok($d->get_datatype, $PDLA_F); # $d is promoted to float
print "D ($b * 600) is $d\n";
my $pd = $pb * 600.0;
is($pd->get_datatype, $PDLA_F); # $pd is promoted to float
note "D ($pb * 600) is $pd";

$pi = 4*atan2(1,1);
my $pi = 4*atan2(1,1);

$e = $b * $pi;
ok($e->get_datatype, $PDLA_D); # $e needs to be double to represent result
print "E ($b * $pi) is $e\n";
my $pe = $pb * $pi;
is($pe->get_datatype, $PDLA_D); # $pe needs to be double to represent result
note "E ($pb * $pi) is $pe";

$f = $b * "-2.2";
ok($f->get_datatype, $PDLA_D); # $e check strings are handled ok
print "F ($b * string(-2.2)) is $f\n";
my $pf = $pb * "-2.2";
is($pf->get_datatype, $PDLA_D); # $pe check strings are handled ok
note "F ($pb * string(-2.2)) is $pf";

40 changes: 17 additions & 23 deletions t/diskcache.t
Original file line number Diff line number Diff line change
@@ -1,47 +1,41 @@

use strict;
use warnings;

use PDLA;
use PDLA::Config;
use File::Temp 'tempdir';
use File::Spec;

use Test::More tests => 4;
use Test::Exception;

# Temp directory name. The catfile() call adds a trailing dir
# separator (e.g. "/" on POSIX).
my $d = File::Spec->catfile(tempdir(CLEANUP=>1),"");

use Test;
BEGIN { plan tests => 4; }

##1 Make sure the library loads

eval 'use PDLA::DiskCache;';
if($@) {print $@,"\n";}
ok( !$@ );
use PDLA::DiskCache;

##2 Make a DiskCache object
##exercises STORE, sync, and DESTROY

eval <<'BAR'
do {
my($a) = diskcache(["${d}1","${d}2","${d}3"],{verbose=>1});
$a->[0] = zeroes(10,10);
$a->[1] = xvals(10,10);
$a->[2] = yvals(10,10);
} while(0);
BAR
;
ok( !$@ );
lives_ok {
my($pa) = diskcache(["${d}1","${d}2","${d}3"],{verbose=>1});
$pa->[0] = zeroes(10,10);
$pa->[1] = xvals(10,10);
$pa->[2] = yvals(10,10);
1;
};

ok( (-e "${d}1") && (-e "${d}2") && (-e "${d}3") );

eval <<'BAZ'
do {
my($b) = diskcache(["${d}1","${d}2","${d}3"],{ro=>1});
ok( ($b->[0]->sum == 0) && ($b->[1]->sum == xvals(10,10)->sum) );
}
BAZ
;
my $pb;
lives_ok {
($pb) = diskcache(["${d}1","${d}2","${d}3"],{ro=>1});
};
ok( ($pb->[0]->sum == 0) && ($pb->[1]->sum == xvals(10,10)->sum) );


# end
Expand Down