It definitely is related to SF#398 fix but IMO it only revealed the problem.
1/ yes, changing "my $pdl = topdl($_[0]);" back to "my $pdl = pdl($_[0]);"
fixes this issue (but we have lost again hdr items)
2/ but why is pdl created from string different from pdl created from arrayref?
pdl('[ [ [0 1] [2 3] ] [ [4 5] [6 7] ] ]'); ... this has flag: C=changed
vs.
pdl([ [ [0,1],[2,3] ],[ [4,5],[6,7] ] ]); ... this has flag: P=physical
3/ another possible fix - sub PDL::Core::new_pdl_from_string
- $to_return = $to_return->mv(-1,1)->clump(2); # this is the line where
flag P becomes C
+ $to_return->mv(-1,1)->clump(2);
--
kmx
On 12.10.2015 22:27, Chris Marshall wrote:
My guess is that this fix broke things:
> fix for SF#398 "$pdl->hdr items are lost after $pdl->reshape"
Definitely something that needs to be fixed. I think the
previous correct reshape() that lost the hdr information
is at least the expected behavior. Of course a full fix
would be even better.
--Chris
On 10/12/2015 15:33, kmx wrote:
A strange observation with PDL-2.014:
*The code:*
use PDL;
my $P = pdl('[ [ [0 1] [2 3] ] [ [4 5] [6 7] ] ]'); # Double D [2,2,2]
print "P-BEFORE info=". $P->info . " data: " . $P . "\n";
$P->reshape(4, 2);
print "P-AFTER info=". $P->info . " data: " . $P . "\n";
my $Q = pdl([ [ [0,1],[2,3] ],[ [4,5],[6,7] ] ]); # Double D [2,2,2]
print "Q-BEFORE info=". $Q->info . " data: " . $Q . "\n";
$Q->reshape(4, 2);
print "Q-AFTER info=". $Q->info . " data: " . $Q . "\n";
*The output on PDL-2.013 (IMO correct):*
P-BEFORE info=PDL: Double D [2,2,2] data:
[
[
[0 1]
[2 3]
]
[
[4 5]
[6 7]
]
]
P-AFTER info=PDL: Double D [4,2] data:
[
[0 1 2 3]
[4 5 6 7]
]
Q-BEFORE info=PDL: Double D [2,2,2] data:
[
[
[0 1]
[2 3]
]
[
[4 5]
[6 7]
]
]
Q-AFTER info=PDL: Double D [4,2] data:
[
[0 1 2 3]
[4 5 6 7]
]
*The output on PDL-2.014:*
P-BEFORE info=PDL: Double D [2,2,2] data:
[
[
[0 1]
[2 3]
]
[
[4 5]
[6 7]
]
]
P-AFTER info=PDL: Double D [2,2,2] data:*##### **BUG?*
[
[
[0 1]
[2 3]
]
[
[4 5]
[6 7]
]
]
Q-BEFORE info=PDL: Double D [2,2,2] data:
[
[
[0 1]
[2 3]
]
[
[4 5]
[6 7]
]
]
Q-AFTER info=PDL: Double D [4,2] data:
[
[0 1 2 3]
[4 5 6 7]
]
--
kmx
------------------------------------------------------------------------------
_______________________________________________
pdl-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pdl-general
------------------------------------------------------------------------------
_______________________________________________
pdl-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pdl-general