Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(194)

Side by Side Diff: appengine/findit/crash/loglinear/test/feature_test.py

Issue 2613153006: [Predator] Add TouchCrashedFileMetaFeature. (Closed)
Patch Set: Add comments. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright 2016 The Chromium Authors. All rights reserved. 1 # Copyright 2016 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import copy 5 import copy
6 import unittest 6 import unittest
7 7
8 from crash.loglinear import feature 8 from crash.loglinear import feature
9 from crash.loglinear.feature import ChangedFile 9 from crash.loglinear.feature import ChangedFile
10 from crash.loglinear.feature import MetaFeatureValue 10 from crash.loglinear.feature import MetaFeatureValue
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 """Test that ``LogLinearlyScaled`` takes values over the max to log(0).""" 48 """Test that ``LogLinearlyScaled`` takes values over the max to log(0)."""
49 self.assertEqual(lmath.LOG_ZERO, feature.LogLinearlyScaled(42., 10.)) 49 self.assertEqual(lmath.LOG_ZERO, feature.LogLinearlyScaled(42., 10.))
50 50
51 51
52 class MetaFeatureValueTest(unittest.TestCase): 52 class MetaFeatureValueTest(unittest.TestCase):
53 53
54 def setUp(self): 54 def setUp(self):
55 super(MetaFeatureValueTest, self).setUp() 55 super(MetaFeatureValueTest, self).setUp()
56 self.feature = MetaFeatureValue( 56 self.feature = MetaFeatureValue(
57 'dummy', {feature.name: feature(3)(False) 57 'dummy', {feature.name: feature(3)(False)
58 for feature in [Feature0(), Feature1()]}) 58 for feature in [Feature0(), Feature1(), Feature3()]})
59 59
60 def testEqaul(self): 60 def testEqaul(self):
61 """Tests overriding ``__eq__`` and ``__ne__``.""" 61 """Tests overriding ``__eq__`` and ``__ne__``."""
62 copy_meta_feature = copy.deepcopy(self.feature) 62 copy_meta_feature = copy.deepcopy(self.feature)
63 self.assertTrue(self.feature == copy_meta_feature) 63 self.assertTrue(self.feature == copy_meta_feature)
64 copy_meta_feature._name = 'dummy2' 64 copy_meta_feature._name = 'dummy2'
65 self.assertTrue(self.feature != copy_meta_feature) 65 self.assertTrue(self.feature != copy_meta_feature)
66 66
67 def testLen(self): 67 def testLen(self):
68 """Tests overriding ``__len__``.""" 68 """Tests overriding ``__len__``."""
69 self.assertEqual(len(self.feature), 2) 69 self.assertEqual(len(self.feature), 3)
70 70
71 def testFormatReasons(self): 71 def testFormatReasons(self):
72 """Tests ``FormatReasons`` returnes a list of formated reasons.""" 72 """Tests ``FormatReasons`` returnes a list of formated reasons."""
73 self.assertEqual(self.feature.reason, 73 self.assertEqual(self.feature.reason,
74 'Feature0: 1.000000 -- reason0\n' 74 'Feature0: 1.000000 -- reason0\n'
75 'Feature1: 0.000000 -- reason1') 75 'Feature1: 0.000000 -- reason1')
76 self.assertEqual(self.feature.reason, self.feature._reason) 76 self.assertEqual(self.feature.reason, self.feature._reason)
77 77
78 def testAggregateChangedFilesAggregates(self): 78 def testAggregateChangedFilesAggregates(self):
79 """Test that ``AggregateChangedFiles`` does aggregate reasons per file. 79 """Test that ``AggregateChangedFiles`` does aggregate reasons per file.
(...skipping 28 matching lines...) Expand all
108 self.assertTrue( 108 self.assertTrue(
109 self._meta_feature(x)(y) == 109 self._meta_feature(x)(y) ==
110 MetaFeatureValue('WrapperFeature', 110 MetaFeatureValue('WrapperFeature',
111 {'Feature0': Feature0()(x)(y), 111 {'Feature0': Feature0()(x)(y),
112 'Feature1': Feature1()(x)(y), 112 'Feature1': Feature1()(x)(y),
113 'Feature2': Feature2()(x)(y), 113 'Feature2': Feature2()(x)(y),
114 'WrapperFeature': MetaFeatureValue( 114 'WrapperFeature': MetaFeatureValue(
115 'WrapperFeature', 115 'WrapperFeature',
116 {'Feature3': Feature3()(x)(y), 116 {'Feature3': Feature3()(x)(y),
117 'Feature4': Feature4()(x)(y)})})) 117 'Feature4': Feature4()(x)(y)})}))
OLDNEW
« no previous file with comments | « appengine/findit/crash/loglinear/test/changelist_classifier_test.py ('k') | appengine/findit/crash/predator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698