diff options
| author | Jack Nagel | 2013-02-01 23:12:34 -0600 |
|---|---|---|
| committer | Jack Nagel | 2013-02-01 23:38:51 -0600 |
| commit | 0c4beb1d37424ed117fb5542493d59d389a25a2f (patch) | |
| tree | 7c4dd4b34f8abda0ffe28e8f10a755affed48cd8 /Library/Formula | |
| parent | c5fb7f6d2847aa81807efdd562c65e5acb5ea72c (diff) | |
| download | homebrew-0c4beb1d37424ed117fb5542493d59d389a25a2f.tar.bz2 | |
fann: use test DSL
Diffstat (limited to 'Library/Formula')
| -rw-r--r-- | Library/Formula/fann.rb | 78 |
1 files changed, 38 insertions, 40 deletions
diff --git a/Library/Formula/fann.rb b/Library/Formula/fann.rb index 5acc9ecf3..1140f3861 100644 --- a/Library/Formula/fann.rb +++ b/Library/Formula/fann.rb @@ -14,46 +14,44 @@ class Fann < Formula system "make install" end - def test - mktemp do - (Pathname.pwd/'xor.data').write <<-EOS.undent - 4 2 1 - -1 -1 - -1 - -1 1 - 1 - 1 -1 - 1 - 1 1 - -1 - EOS + test do + (testpath/'xor.data').write <<-EOS.undent + 4 2 1 + -1 -1 + -1 + -1 1 + 1 + 1 -1 + 1 + 1 1 + -1 + EOS - (Pathname.pwd/'test.c').write <<-EOS.undent - #include "fann.h" - int main() - { - const unsigned int num_input = 2; - const unsigned int num_output = 1; - const unsigned int num_layers = 3; - const unsigned int num_neurons_hidden = 3; - const float desired_error = (const float) 0.001; - const unsigned int max_epochs = 500000; - const unsigned int epochs_between_reports = 1000; - struct fann *ann = fann_create_standard(num_layers, num_input, - num_neurons_hidden, num_output); - fann_set_activation_function_hidden(ann, FANN_SIGMOID_SYMMETRIC); - fann_set_activation_function_output(ann, FANN_SIGMOID_SYMMETRIC); - fann_train_on_file(ann, "xor.data", max_epochs, - epochs_between_reports, desired_error); - fann_save(ann, "xor_float.net"); - fann_destroy(ann); - return 0; - } - EOS - system ENV.cc, "-o", "test", "test.c", "-lfann" - system "./test" - system "cat xor_float.net" - puts - end + (testpath/'test.c').write <<-EOS.undent + #include "fann.h" + int main() + { + const unsigned int num_input = 2; + const unsigned int num_output = 1; + const unsigned int num_layers = 3; + const unsigned int num_neurons_hidden = 3; + const float desired_error = (const float) 0.001; + const unsigned int max_epochs = 500000; + const unsigned int epochs_between_reports = 1000; + struct fann *ann = fann_create_standard(num_layers, num_input, + num_neurons_hidden, num_output); + fann_set_activation_function_hidden(ann, FANN_SIGMOID_SYMMETRIC); + fann_set_activation_function_output(ann, FANN_SIGMOID_SYMMETRIC); + fann_train_on_file(ann, "xor.data", max_epochs, + epochs_between_reports, desired_error); + fann_save(ann, "xor_float.net"); + fann_destroy(ann); + return 0; + } + EOS + system ENV.cc, "-o", "test", "test.c", "-lfann" + system "./test" + system "cat xor_float.net" + puts end end |
