[DRE-commits] [ruby-fftw3] 01/02: RefactTestCases

Youhei SASAKI uwabami-guest at moszumanska.debian.org
Fri Sep 4 08:02:01 UTC 2015


This is an automated email from the git hooks/post-receive script.

uwabami-guest pushed a commit to branch patch-queue/master
in repository ruby-fftw3.

commit a37c04724e4ca64a27bf7024b7668f4a287e148b
Author: Youhei SASAKI <uwabami at gfd-dennou.org>
Date:   Tue Oct 15 17:00:05 2013 +0900

    RefactTestCases
    
    
    Gbp-Pq: Name 0001-RefactTestCases.patch
---
 test/complexFFT.rb | 69 +++++++++++++++++++++++++++---------------------------
 1 file changed, 35 insertions(+), 34 deletions(-)

diff --git a/test/complexFFT.rb b/test/complexFFT.rb
index e8dde6d..b7e28d5 100644
--- a/test/complexFFT.rb
+++ b/test/complexFFT.rb
@@ -3,41 +3,42 @@ require "rubygems"
 rescue LoadError
 end
 require "narray"  # This line is needed for rake test when making a gem package.
+require "test/unit"
+require "narray"
 require "numru/fftw3"
 include NumRu
 
-print "\n**TEST** all dimensions\n\n"
-
-na = NArray.float(8,4).fill(1)  # will be corced to complex
-na[1,1]=5
-p na
-fc = FFTW3.fft(na, -1)/na.length 
-p fc
-p fc.real
-
-p FFTW3.fft(fc, 1).real
-
-print "\n**TEST** single float (treated as single if lib fftw3f exits)\n"
-print " --- see http://www.fftw.org/fftw3_doc/Precision.html for more info\n\n"
-na = NArray.sfloat(8,4).indgen!
-fc = FFTW3.fft(na, -1)/na.length 
-p fc
-p FFTW3.fft(fc, 1).real
-
-print "\n**TEST** dimension selection\n\n"
-
-fc = FFTW3.fft(na, -1, 0)/na.shape[0]
-p fc
-p FFTW3.fft(fc, 1, 0).real
-fc = FFTW3.fft(na, -1, 1)/na.shape[1]
-p fc
-p FFTW3.fft(fc, 1, 1).real
-
-na = NArray.float(4,3,8,3)
-na[1,1,1,0]= 1
-p( fc=FFTW3.fft(na, -1, 0,2) / (na.shape[0]*na.shape[2]) )
-p( fc=FFTW3.fft(na, -1, 1) / na.shape[1] )
-p( fc=FFTW3.fft(na, -1, 0,1,2)  / (na.shape[0]*na.shape[1]*na.shape[2]) )
-p FFTW3.fft(fc, 1, 0,1,2).real
-
+class ComplexTest < Test::Unit::TestCase
+
+  def setup
+    @na_double = NArray.float(8,4).fill(1.0)
+    @na_single = NArray.sfloat(8,4).indgen!
+    @na_complex = NArray.float(4,3,8,3)
+    @na_complex[1,1,1,0] = 1.0
+    @sfloat_delta = 5.0e-5
+    @float_delta = 1.0e-13
+  end
+
+  define_method("test_double_float") do
+    fc_double = FFTW3.fft(@na_double, -1)/@na_double.length
+    assert_in_delta @na_double, FFTW3.fft(fc_double, 1).real, @float_delta
+  end
+
+  define_method("test_single_float") do
+    fc_single = FFTW3.fft(@na_single, -1)/@na_single.length
+    assert_in_delta @na_single, FFTW3.fft(fc_single, 1).real, @sfloat_delta
+  end
+
+  define_method("test_dimenssion_selection") do
+    fc_double = FFTW3.fft(@na_double, -1, 0)/@na_double.shape[0]
+    assert_in_delta @na_double, FFTW3.fft(fc_double, 1, 0).real, @float_delta
+    fc_single = FFTW3.fft(@na_single, -1, 0)/@na_single.shape[0]
+    assert_in_delta @na_single, FFTW3.fft(fc_single, 1, 0).real, @sfloat_delta
+  end
+
+  define_method("test_complex") do
+    fc_complex = FFTW3.fft(@na_complex, -1, 0, 1, 2)/(@na_complex.shape[0]*@na_complex.shape[1]*@na_complex.shape[2])
+    assert_in_delta @na_complex, FFTW3.fft(fc_complex, 1, 0, 1, 2).real, @float_delta
+  end
 
+end

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/ruby-fftw3.git



More information about the Pkg-ruby-extras-commits mailing list