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_converters(self):
from sciunit.converters import NoConversion,LambdaConversion,\
AtMostToBoolean,AtLeastToBoolean,\
RangeToBoolean
from sciunit.scores import BooleanScore,ZScore
old_score = ZScore(1.3)
new_score = NoConversion().convert(old_score)
self.assertEqual(old_score,new_score)
new_score = LambdaConversion(lambda x:x.score**2).convert(old_score)
self.assertEqual(old_score.score**2,new_score.score)
new_score = AtMostToBoolean(3).convert(old_score)
self.assertEqual(new_score,BooleanScore(True))
new_score = AtMostToBoolean(1).convert(old_score)
self.assertEqual(new_score,BooleanScore(False))
new_score = AtLeastToBoolean(1).convert(old_score)
self.assertEqual(new_score,BooleanScore(True))
new_score = AtLeastToBoolean(3).convert(old_score)
self.assertEqual(new_score,BooleanScore(False))
new_score = RangeToBoolean(1,3).convert(old_score)
self.assertEqual(new_score,BooleanScore(True))
new_score = RangeToBoolean(3,5).convert(old_score)
self.assertEqual(new_score,BooleanScore(False))
def test_regular_score_types_1(self):
score = PercentScore(42)
self.assertEqual(score.norm_score, 0.42)
ZScore(0.7)
score = ZScore.compute({'mean': 3., 'std': 1.},
{'value': 2.})
self.assertEqual(score.score, -1.)
CohenDScore(-0.3)
score = CohenDScore.compute({'mean': 3., 'std': 1.},
{'mean': 2., 'std': 1.})
self.assertTrue(-0.708 < score.score < -0.707)
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)
self.assertEqual(score.sort_key,0.42)
ZScore(0.7)
score = ZScore.compute({'mean':3.,'std':1.},{'value':2.})
self.assertEqual(score.score,-1.)
CohenDScore(-0.3)
score = CohenDScore.compute({'mean':3.,'std':1.},{'mean':2.,'std':1.})
self.assertTrue(-0.708 < score.score < -0.707)
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)
self.assertEqual(score.sort_key,0.42)
ZScore(0.7)
score = ZScore.compute({'mean':3.,'std':1.},{'value':2.})
self.assertEqual(score.score,-1.)
CohenDScore(-0.3)
score = CohenDScore.compute({'mean':3.,'std':1.},{'mean':2.,'std':1.})
self.assertTrue(-0.708 < score.score < -0.707)
def test_converters(self):
from sciunit.converters import NoConversion,LambdaConversion,\
AtMostToBoolean,AtLeastToBoolean,\
RangeToBoolean
from sciunit.scores import BooleanScore,ZScore
old_score = ZScore(1.3)
new_score = NoConversion().convert(old_score)
self.assertEqual(old_score,new_score)
new_score = LambdaConversion(lambda x:x.score**2).convert(old_score)
self.assertEqual(old_score.score**2,new_score.score)
new_score = AtMostToBoolean(3).convert(old_score)
self.assertEqual(new_score,BooleanScore(True))
new_score = AtMostToBoolean(1).convert(old_score)
self.assertEqual(new_score,BooleanScore(False))
new_score = AtLeastToBoolean(1).convert(old_score)
self.assertEqual(new_score,BooleanScore(True))
new_score = AtLeastToBoolean(3).convert(old_score)
self.assertEqual(new_score,BooleanScore(False))
new_score = RangeToBoolean(1,3).convert(old_score)
self.assertEqual(new_score,BooleanScore(True))
new_score = RangeToBoolean(3,5).convert(old_score)
self.assertEqual(new_score,BooleanScore(False))
def test_regular_score_types_1(self):
score = PercentScore(42)
self.assertEqual(score.norm_score, 0.42)
ZScore(0.7)
score = ZScore.compute({'mean': 3., 'std': 1.},
{'value': 2.})
self.assertEqual(score.score, -1.)
CohenDScore(-0.3)
score = CohenDScore.compute({'mean': 3., 'std': 1.},
{'mean': 2., 'std': 1.})
self.assertTrue(-0.708 < score.score < -0.707)