93
93
$c = pdl( long, [ 2, 0, 3, 4 ] )->reshape(2,2);
94
94
ok all( $b == $c ), "undef converted to 0 (long)";
96
$PDL::undefval = -999;
97
$a = [ [ 2, undef ], [3, 4 ] ];
99
$c = pdl( [ 2, -999, 3, 4 ] )->reshape(2,2);
100
ok all( $b == $c ), "undef converted to -999 (dbl)";
102
$b = pdl( long, $a );
103
$c = pdl( long, [ 2, -999, 3, 4 ] )->reshape(2,2);
104
ok all( $b == $c ), "undef converted to -999 (long)";
97
local($PDL::undefval) = -999;
98
$a = [ [ 2, undef ], [3, 4 ] ];
100
$c = pdl( [ 2, -999, 3, 4 ] )->reshape(2,2);
101
ok all( $b == $c ), "undef converted to -999 (dbl)";
103
$b = pdl( long, $a );
104
$c = pdl( long, [ 2, -999, 3, 4 ] )->reshape(2,2);
105
ok all( $b == $c ), "undef converted to -999 (long)";
107
109
# Funky constructor cases
110
112
$a = pdl(pdl(5));
111
ok all( $a== pdl(5));
113
ok all( $a== pdl(5)), "pdl() can piddlify a piddle";
113
115
# pdl of mixed-dim pdls: pad within a dimension
114
116
$a = pdl( zeroes(5), ones(3) );
115
ok all($a == pdl([0,0,0,0,0],[1,1,1,0,0]));
118
ok all($a == pdl([0,0,0,0,0],[1,1,1,0,0])),"Piddlifing two piddles catenates them and pads to length";
117
120
# pdl of mixed-dim pdls: pad a whole dimension
118
121
$a = pdl( [[9,9],[8,8]], xvals(3)+1 );
119
ok all($a == pdl([[[9,9],[8,8],[0,0]] , [[1,0],[2,0],[3,0]] ]));
122
ok all($a == pdl([[[9,9],[8,8],[0,0]] , [[1,0],[2,0],[3,0]] ])),"can catenate mixed-dim piddles";
125
# pdl of mixed-dim pdls: a hairier case
126
$c = pdl [1], pdl[2,3,4], pdl[5];
127
ok all($c == pdl([[[1,0,0],[0,0,0]],[[2,3,4],[5,0,0]]])),"Can catenate mixed-dim piddles: hairy case";
129
# same thing, with undefval set differently
131
local($PDL::undefval) = 99;
132
$c = pdl [1], pdl[2,3,4], pdl[5];
133
ok all($c == pdl([[[1,99,99],[99,99,99]],[[2,3,4],[5,99,99]]])), "undefval works for padding";