-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove ignore of E731 #1689
Remove ignore of E731 #1689
Changes from 1 commit
04d7f87
15b4f85
7dddab3
9ea799b
7a84bf8
fc5461f
b96b363
93bce72
ad66770
16711c3
bf80cc2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,7 +37,10 @@ | |
# Test that models are compatiple across versions, as done in LdaModel. | ||
|
||
module_path = os.path.dirname(__file__) # needed because sample data files are located in the same folder | ||
datapath = lambda fname: os.path.join(module_path, 'test_data', fname) | ||
|
||
|
||
def datapath(fname): | ||
return os.path.join(module_path, 'test_data', fname) | ||
|
||
# set up vars used in testing ("Deerwester" from the web tutorial) | ||
texts = [ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmm,
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
@@ -475,24 +478,26 @@ def testPasses(self): | |
# long message includes the original error message with a custom one | ||
self.longMessage = True | ||
# construct what we expect when passes aren't involved | ||
test_rhots = list() | ||
test_rhots = [] | ||
model = self.class_(id2word=dictionary, chunksize=1, num_topics=2) | ||
final_rhot = lambda: pow(model.offset + (1 * model.num_updates) / model.chunksize, -model.decay) | ||
|
||
def final_rhot(model): | ||
return pow(model.offset + (1 * model.num_updates) / model.chunksize, -model.decay) | ||
|
||
# generate 5 updates to test rhot on | ||
for x in range(5): | ||
for _ in range(5): | ||
model.update(corpus, author2doc) | ||
test_rhots.append(final_rhot()) | ||
test_rhots.append(final_rhot(model)) | ||
|
||
for passes in [1, 5, 10, 50, 100]: | ||
model = self.class_(id2word=dictionary, chunksize=1, num_topics=2, passes=passes) | ||
self.assertEqual(final_rhot(), 1.0) | ||
self.assertEqual(final_rhot(model), 1.0) | ||
# make sure the rhot matches the test after each update | ||
for test_rhot in test_rhots: | ||
model.update(corpus, author2doc) | ||
|
||
msg = "{}, {}, {}".format(passes, model.num_updates, model.state.numdocs) | ||
self.assertAlmostEqual(final_rhot(), test_rhot, msg=msg) | ||
self.assertAlmostEqual(final_rhot(model), test_rhot, msg=msg) | ||
|
||
self.assertEqual(model.state.numdocs, len(corpus) * len(test_rhots)) | ||
self.assertEqual(model.num_updates, len(corpus) * len(test_rhots)) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please create
utils
file and move this function (replace to import everywhere).