"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "t/primitive.t" between
PDL-2.078.tar.gz and PDL-2.079.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.078):primitive.t  (PDL-2.079)
skipping to change at line 18 skipping to change at line 18
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) {
diag "APPROX: $x $y\n"; diag "got=$x expected=$y\n";
} }
$d < 0.01; $d < 0.01;
} }
ok tapprox(pdl(1,2,3)->cmpvec(pdl(3,2,1)), -1), 'cmpvec less';
ok tapprox(pdl(3,2,1)->cmpvec(pdl(1,2,3)), 1), 'cmpvec more';
ok tapprox(pdl(3,2,1)->cmpvec(pdl(3,2,1)), 0), 'cmpvec same';
is pdl('[1 BAD]')->cmpvec(pdl(3,2)).'', '-1', 'cmpvec bad before';
is pdl('[BAD 1]')->cmpvec(pdl(3,2)).'', 'BAD', 'cmpvec bad';
ok tapprox(pdl(3,2,1)->eqvec(pdl(1,2,3)), 0), 'eqvec diff';
ok tapprox(pdl(3,2,1)->eqvec(pdl(3,2,1)), 1), 'eqvec same';
is pdl('[2 1 BAD]')->eqvec(pdl(1,3,2)).'', 'BAD', 'eqvec bad before';
is pdl('[2 BAD 1]')->eqvec(pdl(2,3,2)).'', 'BAD', 'eqvec bad';
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");
my $y = PDL->pdl(4,3,1,0,0,0,0,5,2,0,3,6); my $y = PDL->pdl(4,3,1,0,0,0,0,5,2,0,3,6);
my $c = ($y->xvals) + 10; my $c = ($y->xvals) + 10;
ok(tapprox($y->where($y>4), PDL->pdl(5,6)), "where with >"); ok(tapprox($y->where($y>4), PDL->pdl(5,6)), "where with >");
ok(tapprox($y->which, PDL->pdl(0,1,2,7,8,10,11)), "which"); ok(tapprox($y->which, PDL->pdl(0,1,2,7,8,10,11)), "which");
ok(tapprox($c->where($y), PDL->pdl(10,11,12,17,18,20,21)), "where with mask"); ok(tapprox($c->where($y), PDL->pdl(10,11,12,17,18,20,21)), "where with mask");
ok zeroes(3)->which->isempty, 'which on all-zero returns empty';
$y = sequence(10) + 2; $y = sequence(10) + 2;
my ($big, $small) = where_both($y, $y > 5); my ($big, $small) = where_both($y, $y > 5);
$big += 2, $small -= 1; $big += 2, $small -= 1;
ok tapprox($big, pdl('[8 9 10 11 12 13]')), 'where_both big + 2 is right'; ok tapprox($big, pdl('[8 9 10 11 12 13]')), 'where_both big + 2 is right';
ok tapprox($small, pdl('[1 2 3 4]')), 'where_both small - 2 is right'; ok tapprox($small, pdl('[1 2 3 4]')), 'where_both small - 2 is right';
ok tapprox($y, pdl('[1 2 3 4 8 9 10 11 12 13]')), 'where_both dataflow affected orig'; ok tapprox($y, pdl('[1 2 3 4 8 9 10 11 12 13]')), 'where_both dataflow affected orig';
{ {
my $orig = ones(byte, 300); my $orig = ones(byte, 300);
 End of changes. 3 change blocks. 
1 lines changed or deleted 13 lines changed or added

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