Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_rangetest(self):
range_2_3_test = RangeTest(observation=[2, 3])
one_model = ConstModel(2.5)
self.assertTrue(range_2_3_test.check_capabilities(one_model))
score = range_2_3_test.judge(one_model)
self.assertTrue(isinstance(score, BooleanScore))
self.assertEqual(score.score,True)
self.assertTrue(score.test is range_2_3_test)
self.assertTrue(score.model is one_model)
def test_rangetest(self):
from sciunit.tests import RangeTest
range_2_3_test = RangeTest(observation=[2,3])
one_model = sciunit.models.ConstModel(2.5)
self.assertTrue(range_2_3_test.check_capabilities(one_model))
score = range_2_3_test.judge(one_model)
self.assertTrue(isinstance(score, sciunit.scores.BooleanScore))
self.assertEqual(score.score,True)
self.assertTrue(score.test is range_2_3_test)
self.assertTrue(score.model is one_model)
def test_regular_score_types(self):
from sciunit.scores import BooleanScore,FloatScore,RatioScore,\
ZScore,CohenDScore,PercentScore
from sciunit.tests import RangeTest
BooleanScore(True)
BooleanScore(False)
score = BooleanScore.compute(5,5)
self.assertEqual(score.sort_key,1)
score = BooleanScore.compute(4,5)
self.assertEqual(score.sort_key,0)
t = RangeTest([2,3])
score.test = t
score.describe()
score.description = "Lorem Ipsum"
score.describe()
score = FloatScore(3.14)
obs = np.array([1.0,2.0,3.0])
pred = np.array([1.0,2.0,4.0])
score = FloatScore.compute_ssd(obs,pred)
self.assertEqual(score.score,1.0)
RatioScore(1.2)
score = RatioScore.compute({'mean':4.,'std':1.},{'value':2.})
self.assertEqual(score.score,0.5)
score = PercentScore(42)
def test_check_model_capabilities(self):
from sciunit.tests import RangeTest
t = RangeTest([2,3])
m = self.M(2,3)
t.check(m)
def setUp(self):
from sciunit.models.examples import UniformModel
from sciunit.tests import RangeTest
self.M = UniformModel
self.T = RangeTest
def test_regular_score_types_2(self):
BooleanScore(True)
BooleanScore(False)
score = BooleanScore.compute(5, 5)
self.assertEqual(score.norm_score, 1)
score = BooleanScore.compute(4, 5)
self.assertEqual(score.norm_score, 0)
t = RangeTest([2, 3])
score.test = t
score.describe()
score.description = "Lorem Ipsum"
score.describe()
score = FloatScore(3.14)
obs = np.array([1.0, 2.0, 3.0])
pred = np.array([1.0, 2.0, 4.0])
score = FloatScore.compute_ssd(obs, pred)
self.assertEqual(score.score, 1.0)
RatioScore(1.2)
score = RatioScore.compute({'mean': 4., 'std': 1.}, {'value': 2.})
self.assertEqual(score.score, 0.5)
def __init__(self, observation, name=None):
super(RangeTest, self).__init__(observation, name=name)
def setUp(self):
from sciunit.tests import RangeTest
from sciunit.models import UniformModel
self.M = UniformModel
self.T = RangeTest
def setUp(self):
self.M = UniformModel
self.T = RangeTest