slice.t (PDL-2.074) | : | slice.t (PDL-2.075) | ||
---|---|---|---|---|
skipping to change at line 326 | skipping to change at line 326 | |||
my ($source, $index, $dest, $z); | my ($source, $index, $dest, $z); | |||
# Basic indexND operation | # Basic indexND operation | |||
$source = 10*xvals(10,10) + yvals(10,10); | $source = 10*xvals(10,10) + yvals(10,10); | |||
$index = pdl([[2,3],[4,5]],[[6,7],[8,9]]); | $index = pdl([[2,3],[4,5]],[[6,7],[8,9]]); | |||
eval { $x = $source->indexND( $index ) }; | eval { $x = $source->indexND( $index ) }; | |||
is $@, ''; | is $@, ''; | |||
ok(eval { zcheck($x != pdl([23,45],[67,89])) }, "eval of zcheck 1"); | ok(eval { zcheck($x != pdl([23,45],[67,89])) }, "eval of zcheck 1"); | |||
# Threaded indexND operation | # Broadcast indexND operation | |||
$source = 100*xvals(10,10,2)+10*yvals(10,10,2)+zvals(10,10,2); | $source = 100*xvals(10,10,2)+10*yvals(10,10,2)+zvals(10,10,2); | |||
$index = pdl([[2,3],[4,5]],[[6,7],[8,9]]); | $index = pdl([[2,3],[4,5]],[[6,7],[8,9]]); | |||
eval { $x = $source->indexND($index) }; | eval { $x = $source->indexND($index) }; | |||
is $@, ''; | is $@, ''; | |||
ok(eval { zcheck($x != pdl([[230,450],[670,890]],[[231,451],[671,891]])) }, "eva l of zcheck 2"); | ok(eval { zcheck($x != pdl([[230,450],[670,890]],[[231,451],[671,891]])) }, "eva l of zcheck 2"); | |||
############################## | ############################## | |||
# Tests of range operator | # Tests of range operator | |||
# Basic range operation | # Basic range operation | |||
skipping to change at line 394 | skipping to change at line 394 | |||
ok("$z" eq 'Empty[0]', "ranging an empty array with an empty index gives Empty[0 ]"); | ok("$z" eq 'Empty[0]', "ranging an empty array with an empty index gives Empty[0 ]"); | |||
$x = pdl(5,5,5,5); | $x = pdl(5,5,5,5); | |||
$z = $x->range($mt); | $z = $x->range($mt); | |||
ok("$z" eq 'Empty[0]'); | ok("$z" eq 'Empty[0]'); | |||
$z .= 2; # should *not* segfault! | $z .= 2; # should *not* segfault! | |||
ok all($x==5), 'empty range .= no mutate'; # should *not* change $x! | ok all($x==5), 'empty range .= no mutate'; # should *not* change $x! | |||
### Check slicing of a null PDL | ### Check slicing of a null PDL | |||
$x = PDL->null; | $x = PDL->null; | |||
eval { $y = $x->slice("") }; | ||||
eval { $y = $x->slice("")->nelem }; | like $@, qr/is null/, 'null->slice exception'; | |||
is $@, '', 'null->slice no error'; | ||||
is $y, 0; | ||||
eval { $y = $x->slice(0)->nelem }; | ||||
like $@, qr/out of bounds/; | ||||
for my $start (0, 4, -4, 20, -20) { | for my $start (0, 4, -4, 20, -20) { | |||
for my $stop (0, 4, -4, 20, -20) { | for my $stop (0, 4, -4, 20, -20) { | |||
# Generate a simple data ndarray and a bad slice of that ndarray | # Generate a simple data ndarray and a bad slice of that ndarray | |||
my $data = sequence(10); | my $data = sequence(10); | |||
my $slice = $data->slice("$start:$stop"); | my $slice = $data->slice("$start:$stop"); | |||
pass('Slice operation for properly formed slice does not croak'); | pass('Slice operation for properly formed slice does not croak'); | |||
# Calculate the expected dimension size: | # Calculate the expected dimension size: | |||
End of changes. 3 change blocks. | ||||
9 lines changed or deleted | 3 lines changed or added |