~ubuntu-branches/ubuntu/trusty/pdl/trusty-proposed

« back to all changes in this revision

Viewing changes to t/core.t

  • Committer: Bazaar Package Importer
  • Author(s): Andres Rodriguez
  • Date: 2009-12-05 12:37:41 UTC
  • mfrom: (2.1.4 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091205123741-ilqkc9s4zlk71z13
Tags: 1:2.4.5+dfsg-2ubuntu1
* Merge from debian testing (LP: #492898), remaining changes:
  - debian/perldl.conf: Enabled NAN support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
#
5
5
 
6
6
use strict;
7
 
use Test::More tests => 26;
 
7
use Test::More tests => 28;
8
8
 
9
9
BEGIN {
10
10
    # if we've got this far in the tests then 
93
93
$c = pdl( long, [ 2, 0, 3, 4 ] )->reshape(2,2);
94
94
ok all( $b == $c ), "undef converted to 0 (long)";
95
95
 
96
 
$PDL::undefval = -999;
97
 
$a = [ [ 2, undef ], [3, 4 ] ];
98
 
$b = pdl( $a );
99
 
$c = pdl( [ 2, -999, 3, 4 ] )->reshape(2,2);
100
 
ok all( $b == $c ), "undef converted to -999 (dbl)";
101
 
 
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)";
 
96
do { 
 
97
    local($PDL::undefval) = -999;
 
98
    $a = [ [ 2, undef ], [3, 4 ] ];
 
99
    $b = pdl( $a );
 
100
    $c = pdl( [ 2, -999, 3, 4 ] )->reshape(2,2);
 
101
    ok all( $b == $c ), "undef converted to -999 (dbl)";
 
102
    
 
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)";
 
106
} while(0);
105
107
 
106
108
##############
107
109
# Funky constructor cases
108
110
 
109
111
# pdl of a pdl
110
112
$a = pdl(pdl(5));
111
 
ok all( $a== pdl(5));
 
113
ok all( $a== pdl(5)), "pdl() can piddlify a piddle";
112
114
 
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]));
 
117
print "a=$a\n";
 
118
ok all($a == pdl([0,0,0,0,0],[1,1,1,0,0])),"Piddlifing two piddles catenates them and pads to length";
116
119
 
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]] ]));
120
 
 
 
122
ok all($a == pdl([[[9,9],[8,8],[0,0]] , [[1,0],[2,0],[3,0]] ])),"can catenate mixed-dim piddles";
 
123
print "a=$a\n";
 
124
 
 
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";
 
128
 
 
129
# same thing, with undefval set differently
 
130
do {
 
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";
 
134
} while(0);
 
135
    
121
136
# end