Skip to content

Commit

Permalink
allow reshaping of PDLs with dataflow; the dataflow connection gets s…
Browse files Browse the repository at this point in the history
…evered.
  • Loading branch information
Craig DeForest authored and Craig DeForest committed Dec 8, 2015
1 parent 35e3e61 commit 903750d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions Basic/Core/Core.pm
Expand Up @@ -2618,9 +2618,10 @@ preserves dataflow:
]
]
Note: an explicit copy of slices is generally forced - this is the
only way (for now) of stopping a crash if C<$x> is a slice.
Important: Physical piddles are changed inplace!
Important: Piddles are changed inplace!
Note: If C<$x> is connected to any other PDL (e.g. if it is a slice)
then the connection is first severed.
=for example
Expand All @@ -2643,6 +2644,7 @@ sub PDL::reshape{
return $_[0]->slice( map { $_==1 ? [0,0,0] : [] } $_[0]->dims);
}
my $pdl = topdl($_[0]);
$pdl->sever;
my $nelem = $pdl->nelem;
my @dims = grep defined, @_[1..$#_];
for my $dim(@dims) { barf "reshape: invalid dim size '$dim'" if $dim < 0 }
Expand Down
2 changes: 1 addition & 1 deletion t/core.t
Expand Up @@ -243,5 +243,5 @@ ok(all($a == short pdl([[3,4],[5,6]])), "reshape moved the elements to the right

$b = $a->slice(":,:");
eval { $b->reshape(4); };
ok( $@ =~ m/Can\'t/, "reshape fails on a PDL with a parent" );
ok( $@ !~ m/Can\'t/, "reshape doesn't fail on a PDL with a parent" );

0 comments on commit 903750d

Please sign in to comment.