Skip to content

Commit 72b7e71

Browse files
committed
Proj4 tests replace approx with is_pdl - #34
1 parent cfdd275 commit 72b7e71

File tree

1 file changed

+9
-17
lines changed

1 file changed

+9
-17
lines changed

Libtmp/Transform-Proj4/t/proj_transform.t

+9-17
Original file line numberDiff line numberDiff line change
@@ -2,59 +2,51 @@ use strict;
22
use warnings;
33
use PDL::LiteF;
44
use Test::More;
5+
use Test::PDL;
56
use PDL::Transform::Proj4;
67
use PDL::Transform::Cartography;
78

8-
sub pdl_cmp {
9-
my ($g, $e, $l, $eps) = @_;
10-
$_ = PDL->topdl($_) for $g, $e;
11-
local $Test::Builder::Level = $Test::Builder::Level + 1;
12-
my $res = all(approx($g, $e, $eps));
13-
fail("$l: result was BAD value"), return if $res->isbad;
14-
ok $res, $l or diag "got:\n$g\nexpected:\n$e";
15-
}
16-
179
my $fwd = pdl '-146.25 -81.5625; -137.8125 -81.5625; -146.25 -73.125; -137.8125 -73.125';
1810
my $inv = pdl '0 -7213503; 4809002 -7213503; 0 -4809002; 4809002 -4809002';
1911
my $t = t_proj( proj_params => "+proj=eqc +lon_0=0 +datum=WGS84" );
20-
pdl_cmp $fwd->apply($t), pdl(<<'EOF'), 'eqc fwd', 10;
12+
is_pdl $fwd->apply($t), pdl(<<'EOF'), {test_name=>'eqc fwd', atol=>10};
2113
-16280476 -9079496; -15341217 -9079496;
2214
-16280476 -8140237.8; -15341217 -8140237.8
2315
EOF
24-
pdl_cmp $inv->apply(!$t), pdl(<<'EOF'), 'eqc inv', 1e-2;
16+
is_pdl $inv->apply(!$t), pdl(<<'EOF'), {test_name=>'eqc inv', atol=>1e-2};
2517
0 -64.8; 43.2 -64.8; 0 -43.2; 43.2 -43.2
2618
EOF
2719

2820
$fwd = pdl '-146.25 81.5625; -137.8125 81.5625; -146.25 73.125; -137.8125 73.125';
2921
$inv = pdl '0 -4558236.1; 1530752.9 -4558236.1; 0 -3031095.5; 1530752.9 -3031095.5';
3022
$t = t_proj( proj_params => "+proj=ortho +ellps=WGS84 +lon_0=-90 +lat_0=40" );
31-
pdl_cmp $fwd->apply($t), pdl(<<'EOF'), 'ortho fwd', 10;
23+
is_pdl $fwd->apply($t), pdl(<<'EOF'), {test_name=>'ortho fwd', atol=>10};
3224
-780706.14 4502242.5; -695714.05 4432238.3;
3325
-1544186 4016381.2; -1376077.2 3877917.4
3426
EOF
35-
pdl_cmp $inv->apply(!$t), pdl(<<'EOF'), 'ortho inv', 1e-2;
27+
is_pdl $inv->apply(!$t), pdl(<<'EOF'), {test_name=>'ortho inv', atol=>1e-2};
3628
-90 -5.9283617; -75.991258 -7.5230948; -90 11.481088; -75.886486 10.220222
3729
EOF
3830

3931
$fwd = pdl '-146.25 81.5625; -137.8125 81.5625; -146.25 73.125; -137.8125 73.125';
4032
$inv = pdl '0 -4558236.1; 1530752.9 -4558236.1; 0 -3031095.5; 1530752.9 -3031095.5';
4133
$t = t_proj_ortho( ellps => 'WGS84', lon_0 => -90, lat_0 => 40 );
42-
pdl_cmp $fwd->apply($t), pdl(<<'EOF'), 'ortho2 fwd', 10;
34+
is_pdl $fwd->apply($t), pdl(<<'EOF'), {test_name=>'ortho2 fwd', atol=>10};
4335
-780706.14 4502242.5; -695714.05 4432238.3;
4436
-1544186 4016381.2; -1376077.2 3877917.4
4537
EOF
46-
pdl_cmp $inv->apply(!$t), pdl(<<'EOF'), 'ortho2 inv', 1e-2;
38+
is_pdl $inv->apply(!$t), pdl(<<'EOF'), {test_name=>'ortho2 inv', atol=>1e-2};
4739
-90 -5.9283617; -75.991258 -7.5230948; -90 11.481088; -75.886486 10.220222
4840
EOF
4941

5042
$fwd = pdl '-146.25 -81.5625; -137.8125 -81.5625; -146.25 -73.125; -137.8125 -73.125';
5143
$inv = pdl '0 -6210111.4; 4081400 -6210111.4; 0 -4140074.2; 4081400 -4140074.2';
5244
$t = t_proj_robin( ellps => 'WGS84', over => 1 );
53-
pdl_cmp $fwd->apply($t), pdl(<<'EOF'), 'robin fwd', 10;
45+
is_pdl $fwd->apply($t), pdl(<<'EOF'), {test_name=>'robin fwd', atol=>10};
5446
-8363042.7 -8211603.9; -7880559.4 -8211603.9;
5547
-9548357.3 -7548659.1; -8997490.5 -7548659.1
5648
EOF
57-
pdl_cmp $inv->apply(!$t), pdl(<<'EOF'), 'robin inv', 1e-2;
49+
is_pdl $inv->apply(!$t), pdl(<<'EOF'), {test_name=>'robin inv', atol=>1e-2};
5850
0 -58.719767; 53.453033 -58.719767; 0 -38.71881; 46.580505 -38.71881
5951
EOF
6052

0 commit comments

Comments
 (0)