Skip to content

Commit

Permalink
Use time.time instead of time.clock in gensim/models/hdpmodel.py (#2730)
Browse files Browse the repository at this point in the history
* Use time.process_time() instead of time.clock()

* time.process_time() -> time.time()
  • Loading branch information
tarohi24 authored and mpenkov committed Jan 23, 2020
1 parent 4d22327 commit 4710308
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions gensim/models/hdpmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,10 @@ def update(self, corpus):
"""
save_freq = max(1, int(10000 / self.chunksize)) # save every 10k docs, roughly
chunks_processed = 0
start_time = time.clock()
try:
start_time = time.time()
except AttributeError:
start_time = time.clock()

while True:
for chunk in utils.grouper(corpus, self.chunksize):
Expand Down Expand Up @@ -508,12 +511,16 @@ def update_finished(self, start_time, chunks_processed, docs_processed):
If True - model is updated, False otherwise.
"""
try:
start_time = time.time()
except AttributeError:
start_time = time.clock()
return (
# chunk limit reached
(self.max_chunks and chunks_processed == self.max_chunks)

# time limit reached
or (self.max_time and time.clock() - start_time > self.max_time)
or (self.max_time and start_time - start_time > self.max_time)

This comment has been minimized.

Copy link
@gojomo

gojomo Jan 27, 2020

Collaborator

Er: start_time - start_time doesn't make sense here. (But I'll have a fix for this shortly along with other updates for Python 3.7+ in #2715.)


# no limits and whole corpus has been processed once
or (not self.max_chunks and not self.max_time and docs_processed >= self.m_D))
Expand Down

0 comments on commit 4710308

Please sign in to comment.