Skip to content

Commit 6551403

Browse files
committed
FFT tests replace tapprox with is_pdl - #34
1 parent 4db9639 commit 6551403

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

Basic/Lib-FFT/t/fft.t

+10-14
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@ use PDL;
44
use PDL::FFT;
55
use Test::More;
66
use Test::Exception;
7-
8-
sub tapprox {
9-
my($pa,$pb) = @_;
10-
all approx $pa, $pb, 0.01;
11-
}
7+
use Test::PDL -atol => 0.01, -require_equal_types => 0;
128

139
foreach my $type(double,float,cdouble,cfloat){
1410
my $pa = pdl($type,1,-1,1,-1);
@@ -29,35 +25,35 @@ fft($pb,$pc);
2925
ifft($pb,$pc);
3026
fft($pd);
3127
ifft($pd);
32-
ok (tapprox($pc,0), "fft zeroes");
33-
ok (tapprox($pd->im,0), "fft zeroes using complex ndarrays");
34-
ok (tapprox($pa,$pb), "original image recovered");
28+
is_pdl $pc, $pb->zeroes, "fft zeroes";
29+
is_pdl $pd->im, $pb->zeroes, "fft zeroes using complex ndarrays";
30+
is_pdl $pa, $pb, "original image recovered";
3531
}
3632

3733
{
3834
my $pb = $pa->copy;
3935
my $pc = $pb->zeroes;
4036
my $pd=czip($pb, $pc);
4137
fftnd($pb,$pc); ifftnd($pb,$pc);
42-
ok ( tapprox($pc,0), "fftnd zeroes");
43-
ok ( tapprox($pa,$pb), "fftnd real image");
38+
is_pdl $pc, $pb->zeroes, "fftnd zeroes";
39+
is_pdl $pa, $pb, "fftnd real image";
4440
fftnd($pd); ifftnd($pd);
45-
ok ( tapprox($pd,$pb), "fftnd native complex image with imag zeroes");
41+
is_pdl $pd, $pb, "fftnd native complex image with imag zeroes";
4642
}
4743

4844
{
4945
my $pb = $pa->slice("1:35,1:69");
5046
my $pc = $pb->copy; fftnd($pb,$pc); ifftnd($pb,$pc);
51-
ok ( tapprox($pc,$pb), "fftnd real and imaginary");
52-
ok ( tapprox($pa->slice("1:35,1:69"),$pb), "fftnd original restored");
47+
is_pdl $pc, $pb, "fftnd real and imaginary";
48+
is_pdl $pa->slice("1:35,1:69"), $pb, "fftnd original restored";
5349
}
5450

5551
{
5652
my $pb = $pa->copy;
5753
# Test real ffts
5854
realfft($pb);
5955
realifft($pb);
60-
ok( tapprox($pa,$pb), "realfft");
56+
is_pdl $pa, $pb, "realfft";
6157
}
6258

6359
# Test that errors are properly caught

0 commit comments

Comments
 (0)