summaryrefslogtreecommitdiff
path: root/lazar.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lazar.rb')
-rw-r--r--lazar.rb12
1 files changed, 9 insertions, 3 deletions
diff --git a/lazar.rb b/lazar.rb
index 6324f3c..0ee7a43 100644
--- a/lazar.rb
+++ b/lazar.rb
@@ -2,6 +2,12 @@ require 'rubygems'
require 'opentox-ruby'
require 'test/unit'
+class Float
+ def round_to(x)
+ (self * 10**x).round.to_f / 10**x
+ end
+end
+
class LazarTest < Test::Unit::TestCase
=begin
@@ -13,8 +19,8 @@ class LazarTest < Test::Unit::TestCase
compound = OpenTox::Compound.from_smiles("c1ccccc1NN")
prediction_uri = lazar.run(:compound_uri => compound.uri, :subjectid => @@subjectid)
prediction = OpenTox::LazarPrediction.find(prediction_uri)
- assert_equal prediction.value(compound), 0.149480050002539
- assert_equal prediction.confidence(compound), 0.615246530364447
+ assert_equal prediction.value(compound).round_to(4), 0.149518871336721.round_to(4)
+ assert_equal prediction.confidence(compound).round_to(4), 0.615246530364447.round_to(4)
assert_equal prediction.neighbors(compound).size, 81
prediction.delete(@@subjectid)
lazar.delete(@@subjectid)
@@ -30,7 +36,7 @@ class LazarTest < Test::Unit::TestCase
prediction_uri = lazar.run(:compound_uri => compound.uri, :subjectid => @@subjectid)
prediction = OpenTox::LazarPrediction.find(prediction_uri)
assert_equal prediction.value(compound), false
- assert_equal prediction.confidence(compound), 0.25857114104619
+ assert_equal prediction.confidence(compound).round_to(4), 0.25857114104619.round_to(4)
assert_equal prediction.neighbors(compound).size, 15
prediction.delete(@@subjectid)
# dataset activity