"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "t/primitive.t" between
PDL-2.074.tar.gz and PDL-2.075.tar.gz

About: PDL (Perl Data Language) aims to turn perl into an efficient numerical language for scientific computing (similar to IDL and MatLab).

primitive.t  (PDL-2.074):primitive.t  (PDL-2.075)
skipping to change at line 17 skipping to change at line 17
sub tapprox { sub tapprox {
my($x,$y) = @_; my($x,$y) = @_;
$_ = pdl($_) for $x, $y; $_ = pdl($_) for $x, $y;
if(join(',',$x->dims) ne join(',',$y->dims)) { if(join(',',$x->dims) ne join(',',$y->dims)) {
diag "APPROX: $x $y\n"; diag "APPROX: $x $y\n";
diag "UNEQDIM\n"; diag "UNEQDIM\n";
return 0; return 0;
} }
my $d = max( abs($x-$y) ); my $d = max( abs($x-$y) );
if($d >= 0.01) { if($d >= 0.01) {
use Carp; confess "SHIT";
diag "APPROX: $x $y\n"; diag "APPROX: $x $y\n";
} }
$d < 0.01; $d < 0.01;
} }
my $x = PDL->pdl([[5,4,3],[2,3,1.5]]); my $x = PDL->pdl([[5,4,3],[2,3,1.5]]);
ok(tapprox($x->average(), PDL->pdl([4, 2.16666])), "average"); ok(tapprox($x->average(), PDL->pdl([4, 2.16666])), "average");
ok(tapprox($x->sumover(), PDL->pdl([12, 6.5])), "sumover"); ok(tapprox($x->sumover(), PDL->pdl([12, 6.5])), "sumover");
ok(tapprox($x->prodover(), PDL->pdl([60, 9])), "prodover"); ok(tapprox($x->prodover(), PDL->pdl([60, 9])), "prodover");
skipping to change at line 296 skipping to change at line 295
# complex matmult # complex matmult
my $cm1 = cdouble(1, czip(1, 1), 1); my $cm1 = cdouble(1, czip(1, 1), 1);
my $cm2 = cdouble(2, 3, i()); my $cm2 = cdouble(2, 3, i());
my $got = $cm1 x $cm2->dummy(0); my $got = $cm1 x $cm2->dummy(0);
ok all(approx $got, czip(5, 4)), 'complex matmult' or diag $got; ok all(approx $got, czip(5, 4)), 'complex matmult' or diag $got;
# which ND test # which ND test
my $a1 = PDL->sequence(10,10,3,4); my $a1 = PDL->sequence(10,10,3,4);
# $PDL::whichND_no_warning = 1; ($x, $y, $z, my $w) = whichND($a1 == 203)->mv(0,-1)->dog;
# ($x, $y, $z, $w)=whichND($a1 == 203);
($x, $y, $z, my $w) = whichND($a1 == 203)->mv(0,-1)->dog; # quiet deprecation w
arning
ok($a1->at($x->list,$y->list,$z->list,$w->list) == 203, "whichND" ); ok($a1->at($x->list,$y->list,$z->list,$w->list) == 203, "whichND" );
$a1 = pdl(1,2,3,4); $a1 = pdl(1,2,3,4);
my $b1 = append($a1,2); my $b1 = append($a1,2);
ok(int(sum($b1))==12, "append"); ok(int(sum($b1))==12, "append");
$b1 = append(null, null); $b1 = append(null, null);
ok !$b1->isnull, 'append(null, null) returns non-null'; ok !$b1->isnull, 'append(null, null) returns non-null';
ok $b1->isempty, 'append(null, null) returns an empty'; ok $b1->isempty, 'append(null, null) returns an empty';
append(null, null, $b1); append(null, null, $b1);
ok !$b1->isnull, 'append(null, null, b1) sets non-null'; ok !$b1->isnull, 'append(null, null, b1) sets non-null';
ok $b1->isempty, 'append(null, null, b1) sets an empty'; ok $b1->isempty, 'append(null, null, b1) sets an empty';
$b1 = indx(1,2);
is $b1->type, 'indx', '$indx_pdl is an indx pdl';
$b1 = $b1->append(-1);
is $b1->type, 'indx', 'append($indx_pdl, -1) returns an indx pdl';
is $b1.'', '[1 2 -1]', 'append($indx_pdl, -1) correct content';
# clip tests # clip tests
ok(tapprox($im->hclip(5)->sum,83), "hclip" ); ok(tapprox($im->hclip(5)->sum,83), "hclip" );
ok(tapprox($im->lclip(5)->sum,176), "lclip" ); ok(tapprox($im->lclip(5)->sum,176), "lclip" );
ok(tapprox($im->clip(5,7)->sum,140), "clip" ); ok(tapprox($im->clip(5,7)->sum,140), "clip" );
# with NaN badvalue # with NaN badvalue
$im = sequence(3); $im = sequence(3);
$im->badvalue(nan()); $im->badvalue(nan());
$im->badflag(1); $im->badflag(1);
$im->set(1, nan()); $im->set(1, nan());
 End of changes. 3 change blocks. 
5 lines changed or deleted 6 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)