"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "t/core.t" between
PDL-2.077.tar.gz and PDL-2.078.tar.gz

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

core.t  (PDL-2.077):core.t  (PDL-2.078)
skipping to change at line 19 skipping to change at line 19
sub tapprox ($$) { sub tapprox ($$) {
my ( $x, $y ) = @_; my ( $x, $y ) = @_;
my $d = abs( $x - $y ); my $d = abs( $x - $y );
return $d <= 0.0001; return $d <= 0.0001;
} }
for my $type (PDL::Types::types()) { for my $type (PDL::Types::types()) {
ok defined pdl($type, 0), "constructing PDL of type $type"; ok defined pdl($type, 0), "constructing PDL of type $type";
} }
{
my $p = sequence(100); # big enough to not fit in "value" field
my $ref = $p->get_dataref;
$p->reshape(3); # small enough now
$p->upd_data;
}
is sequence(3,2)->dup(0, 2).'', ' is sequence(3,2)->dup(0, 2).'', '
[ [
[0 1 2 0 1 2] [0 1 2 0 1 2]
[3 4 5 3 4 5] [3 4 5 3 4 5]
] ]
', 'dup'; ', 'dup';
is sequence(3,2)->dupN(2, 3).'', ' is sequence(3,2)->dupN(2, 3).'', '
[ [
[0 1 2 0 1 2] [0 1 2 0 1 2]
skipping to change at line 63 skipping to change at line 70
like $@, qr/multielement ndarray in 'sclr' call/, "sclr failed on multi-element ndarray (long)"; like $@, qr/multielement ndarray in 'sclr' call/, "sclr failed on multi-element ndarray (long)";
eval { $c_dbl->sclr }; eval { $c_dbl->sclr };
like $@, qr/multielement ndarray in 'sclr' call/, "sclr failed on multi-element ndarray (dbl)"; like $@, qr/multielement ndarray in 'sclr' call/, "sclr failed on multi-element ndarray (dbl)";
eval { zeroes(0)->max ? 1 : 0 }; eval { zeroes(0)->max ? 1 : 0 };
like $@, qr/bad.*conditional/, 'badvalue as boolean is error'; like $@, qr/bad.*conditional/, 'badvalue as boolean is error';
# test reshape barfing with negative args # test reshape barfing with negative args
# #
eval 'my $d_long = $a_long->reshape(0,-3);'; eval { my $d_long = $a_long->reshape(0,-3) };
like $@, qr/invalid dim size/, "reshape() failed with negative args (long)"; like $@, qr/invalid dim size/, "reshape() failed with negative args (long)";
eval 'my $d_dbl = $a_dbl->reshape(0,-3);'; eval { my $d_dbl = $a_dbl->reshape(0,-3) };
like $@, qr/invalid dim size/, "reshape() failed with negative args (dbl)"; like $@, qr/invalid dim size/, "reshape() failed with negative args (dbl)";
# test reshape with no args eval { my $y = zeroes(1,3); $y .= sequence(2,3); };
my ( $x, $y, $c ); isnt $@, '', 'scaling-up of output dim 1 throws error';
eval { my $y = zeroes(1); $y .= zeroes(0) + 1; };
isnt $@, '', 'scaling-down of output dim 1 throws error';
$x = ones 3,1,4; # test reshape with no args
$y = $x->reshape; my $x = ones 3,1,4;
my $y = $x->reshape;
ok eq_array( [ $y->dims ], [3,4] ), "reshape()"; ok eq_array( [ $y->dims ], [3,4] ), "reshape()";
# test reshape(-1) and squeeze # test reshape(-1) and squeeze
$x = ones 3,1,4; $x = ones 3,1,4;
$y = $x->reshape(-1); $y = $x->reshape(-1);
$c = $x->squeeze; my $c = $x->squeeze;
ok eq_array( [ $y->dims ], [3,4] ), "reshape(-1)"; ok eq_array( [ $y->dims ], [3,4] ), "reshape(-1)";
ok all( $y == $c ), "squeeze"; ok all( $y == $c ), "squeeze";
$c++; # check dataflow in reshaped PDL $c++; # check dataflow in reshaped PDL
ok all( $y == $c ), "dataflow"; # should flow back to y ok all( $y == $c ), "dataflow"; # should flow back to y
ok all( $x == 2 ), "dataflow"; ok all( $x == 2 ), "dataflow";
our $d = pdl(5); # zero dim ndarray and reshape/squeeze our $d = pdl(5); # zero dim ndarray and reshape/squeeze
ok $d->reshape(-1)->ndims==0, "reshape(-1) on 0-dim PDL gives 0-dim PDL"; ok $d->reshape(-1)->ndims==0, "reshape(-1) on 0-dim PDL gives 0-dim PDL";
ok $d->reshape(1)->ndims==1, "reshape(1) on 0-dim PDL gives 1-dim PDL"; ok $d->reshape(1)->ndims==1, "reshape(1) on 0-dim PDL gives 1-dim PDL";
 End of changes. 6 change blocks. 
7 lines changed or deleted 17 lines changed or added

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