def test_evaluation_dict(self): """Tests that the evaluation dictionary is generated correctly.""" e = TargetEvaluator(self.submitted_targets, self.real_targets) d = e.evaluation_dict() self.assertIn('matched_target_value', d) self.assertIn('unmatched_target_count', d) self.assertIn('targets', d) for t in d['targets'].values(): keys = [ 'match_value', 'image_approved', 'classifications', 'location_accuracy', 'actionable' ] for key in keys: self.assertIn(key, t) for s in self.real_targets: self.assertIn(s.pk, d['targets'].keys()) self.assertEqual(19, d['matched_target_value']) self.assertEqual(1, d['unmatched_target_count']) self.assertEqual(8, d['targets'][self.real1.pk]['match_value']) self.assertEqual(True, d['targets'][self.real1.pk]['image_approved']) self.assertEqual(1.0, d['targets'][self.real1.pk]['classifications']) self.assertEqual(0.0, d['targets'][self.real1.pk]['location_accuracy']) self.assertEqual('objective', d['targets'][self.real1.pk]['actionable']) self.assertEqual(None, d['targets'][self.real2.pk]['actionable'])
def test_evaluation_dict(self): """Tests that the evaluation dictionary is generated correctly.""" e = TargetEvaluator(self.submitted_targets, self.real_targets) d = e.evaluation_dict() self.assertIn('matched_target_value', d) self.assertIn('unmatched_target_count', d) self.assertIn('targets', d) for t in d['targets'].values(): keys = ['match_value', 'image_approved', 'classifications', 'location_accuracy', 'actionable'] for key in keys: self.assertIn(key, t) for s in self.real_targets: self.assertIn(s.pk, d['targets'].keys()) self.assertEqual(11, d['matched_target_value']) self.assertEqual(2, d['unmatched_target_count']) self.assertEqual(8, d['targets'][self.real1.pk]['match_value']) self.assertEqual(True, d['targets'][self.real1.pk]['image_approved']) self.assertEqual(1.0, d['targets'][self.real1.pk]['classifications']) self.assertEqual(0.0, d['targets'][self.real1.pk]['location_accuracy']) self.assertEqual('objective', d['targets'][self.real1.pk]['actionable']) self.assertEqual(None, d['targets'][self.real2.pk]['actionable'])
def test_match_value(self): """Tests the match value for two targets.""" e = TargetEvaluator(self.submitted_targets, self.real_targets) self.assertEqual(8, e.match_value(self.submit1, self.real1)) self.assertEqual(3, e.match_value(self.submit2, self.real2)) self.assertEqual(0, e.match_value(self.submit3, self.real3)) self.assertEqual(0, e.match_value(self.submit4, self.real4))
def test_evaluation_dict_no_real_targets(self): """Tests that evaluation_dict works with no submitted targets.""" e = TargetEvaluator(self.submitted_targets, []) d = e.evaluation_dict() self.assertEqual(0, d['matched_target_value']) self.assertEqual(5, d['unmatched_target_count']) self.assertEqual({}, d['targets'])
def test_evaluation_dict_no_real_targets(self): """Tests that evaluation_dict works with no submitted targets.""" e = TargetEvaluator(self.submitted_targets, []) d = e.evaluation_dict() self.assertEqual(0, d["matched_target_value"]) self.assertEqual(5, d["unmatched_target_count"]) self.assertEqual({}, d["targets"])
def test_evaluation_dict_no_submitted_targets(self): """Tests that evaluation_dict works with no submitted targets.""" e = TargetEvaluator([], self.real_targets) d = e.evaluation_dict() self.assertEqual(0, d['matched_target_value']) self.assertEqual(0, d['unmatched_target_count']) self.assertEqual({}, d['targets'])
def test_evaluation_dict_no_submitted_targets(self): """Tests that evaluation_dict works with no submitted targets.""" e = TargetEvaluator([], self.real_targets) d = e.evaluation_dict() self.assertEqual(0, d['matched_target_value']) self.assertEqual(0, d['unmatched_target_count']) for td in d['targets'].values(): for v in td.values(): self.assertEqual('', v)
def test_evaluation_dict_no_submitted_targets(self): """Tests that evaluation_dict works with no submitted targets.""" e = TargetEvaluator([], self.real_targets) d = e.evaluation_dict() self.assertEqual(0, d["matched_target_value"]) self.assertEqual(0, d["unmatched_target_count"]) for td in d["targets"].values(): for v in td.values(): self.assertEqual("", v)
def test_match_targets(self): """Tests that matching targets produce maximal matches.""" e = TargetEvaluator(self.submitted_targets, self.real_targets) self.assertEqual( { self.submit1: self.real1, self.submit2: self.real2, self.real1: self.submit1, self.real2: self.submit2 }, e.match_targets(self.submitted_targets, self.real_targets))
def test_evaluation_dict(self): """Tests that the evaluation dictionary is generated correctly.""" e = TargetEvaluator(self.submitted_targets, self.real_targets) d = e.evaluation_dict() self.assertIn("matched_target_value", d) self.assertIn("unmatched_target_count", d) self.assertIn("targets", d) for t in d["targets"].values(): keys = ["match_value", "image_approved", "classifications", "location_accuracy", "actionable"] for key in keys: self.assertIn(key, t) for s in self.real_targets: self.assertIn(s.pk, d["targets"].keys()) self.assertEqual(19, d["matched_target_value"]) self.assertEqual(1, d["unmatched_target_count"]) self.assertEqual(8, d["targets"][self.real1.pk]["match_value"]) self.assertEqual(True, d["targets"][self.real1.pk]["image_approved"]) self.assertEqual(1.0, d["targets"][self.real1.pk]["classifications"]) self.assertEqual(0.0, d["targets"][self.real1.pk]["location_accuracy"]) self.assertEqual("objective", d["targets"][self.real1.pk]["actionable"]) self.assertEqual(None, d["targets"][self.real2.pk]["actionable"])