Skip to content

Commit 3067cb0

Browse files
committed
Win and OSX build fix
2 parents b42e181 + 3b9bb59 commit 3067cb0

File tree

6 files changed

+14
-14
lines changed

6 files changed

+14
-14
lines changed

gensim/matutils.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ def ret_normalized_vec(vec, length):
326326
else:
327327
return list(vec)
328328

329-
def ret_log_normalize_vec(vec, axis = 1):
329+
def ret_log_normalize_vec(vec, axis=1):
330330
log_max = 100.0
331331
if len(vec.shape) == 1:
332332
max_val = numpy.max(vec)
@@ -335,17 +335,17 @@ def ret_log_normalize_vec(vec, axis = 1):
335335
log_norm = numpy.log(tot) - log_shift
336336
vec = vec - log_norm
337337
else:
338-
if axis == 1:#independently normalize each sample
338+
if axis == 1: # independently normalize each sample
339339
max_val = numpy.max(vec, 1)
340340
log_shift = log_max - numpy.log(vec.shape[1] + 1.0) - max_val
341341
tot = numpy.sum(numpy.exp(vec + log_shift[:, numpy.newaxis]), 1)
342342
log_norm = numpy.log(tot) - log_shift
343343
vec = vec - log_norm[:, numpy.newaxis]
344-
elif axis == 0:#normalize each feature
344+
elif axis == 0: # normalize each feature
345345
k = ret_log_normalize_vec(vec.T)
346346
return (k[0].T, k[1])
347347
else:
348-
raise ValueError("'%d' is not a supported axis" % axis)
348+
raise ValueError("'%s' is not a supported axis" % axis)
349349
return (vec, log_norm)
350350

351351

gensim/models/lsi_worker.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class Worker(object):
3939
def __init__(self):
4040
self.model = None
4141

42-
42+
@Pyro4.expose
4343
def initialize(self, myid, dispatcher, **model_params):
4444
self.lock_update = threading.Lock()
4545
self.jobsdone = 0 # how many jobs has this worker completed?
@@ -49,7 +49,7 @@ def initialize(self, myid, dispatcher, **model_params):
4949
logger.info("initializing worker #%s" % myid)
5050
self.model = lsimodel.LsiModel(**model_params)
5151

52-
52+
@Pyro4.expose
5353
@Pyro4.oneway
5454
def requestjob(self):
5555
"""
@@ -81,7 +81,7 @@ def processjob(self, job):
8181
fname = os.path.join(tempfile.gettempdir(), 'lsi_worker.pkl')
8282
self.model.save(fname)
8383

84-
84+
@Pyro4.expose
8585
@utils.synchronous('lock_update')
8686
def getstate(self):
8787
logger.info("worker #%i returning its state after %s jobs" %
@@ -90,7 +90,7 @@ def getstate(self):
9090
self.finished = True
9191
return self.model.projection
9292

93-
93+
@Pyro4.expose
9494
@utils.synchronous('lock_update')
9595
def reset(self):
9696
logger.info("resetting worker #%i" % self.myid)
File renamed without changes.

gensim/test/test_hdpmodel.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from gensim.corpora import mmcorpus, Dictionary
2323
from gensim.models import hdpmodel
2424
from gensim import matutils
25-
from gensim.test import test_basemodel
25+
from gensim.test import basetests
2626

2727

2828
module_path = os.path.dirname(__file__) # needed because sample data files are located in the same folder
@@ -48,7 +48,7 @@ def testfile():
4848
return os.path.join(tempfile.gettempdir(), 'gensim_models.tst')
4949

5050

51-
class TestHdpModel(unittest.TestCase, test_basemodel.TestBaseTopicModel):
51+
class TestHdpModel(unittest.TestCase, basetests.TestBaseTopicModel):
5252
def setUp(self):
5353
self.corpus = mmcorpus.MmCorpus(datapath('testcorpus.mm'))
5454
self.class_ = hdpmodel.HdpModel

gensim/test/test_ldamodel.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from gensim.corpora import mmcorpus, Dictionary
2424
from gensim.models import ldamodel, ldamulticore
2525
from gensim import matutils
26-
from gensim.test import test_basemodel
26+
from gensim.test import basetests
2727

2828

2929
module_path = os.path.dirname(__file__) # needed because sample data files are located in the same folder
@@ -55,7 +55,7 @@ def testRandomState():
5555
assert(isinstance(ldamodel.get_random_state(testcase), numpy.random.RandomState))
5656

5757

58-
class TestLdaModel(unittest.TestCase, test_basemodel.TestBaseTopicModel):
58+
class TestLdaModel(unittest.TestCase, basetests.TestBaseTopicModel):
5959
def setUp(self):
6060
self.corpus = mmcorpus.MmCorpus(datapath('testcorpus.mm'))
6161
self.class_ = ldamodel.LdaModel

gensim/test/test_lsimodel.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from gensim.corpora import mmcorpus, Dictionary
2323
from gensim.models import lsimodel
2424
from gensim import matutils
25-
from gensim.test import test_basemodel
25+
from gensim.test import basetests
2626

2727

2828
module_path = os.path.dirname(__file__) # needed because sample data files are located in the same folder
@@ -51,7 +51,7 @@ def testfile():
5151
return os.path.join(tempfile.gettempdir(), 'gensim_models.tst')
5252

5353

54-
class TestLsiModel(unittest.TestCase, test_basemodel.TestBaseTopicModel):
54+
class TestLsiModel(unittest.TestCase, basetests.TestBaseTopicModel):
5555
def setUp(self):
5656
self.corpus = mmcorpus.MmCorpus(datapath('testcorpus.mm'))
5757
self.model = lsimodel.LsiModel(self.corpus, num_topics=2)

0 commit comments

Comments
 (0)