Skip to content

Commit

Permalink
Win and OSX build fix
Browse files Browse the repository at this point in the history
  • Loading branch information
tmylk committed Oct 21, 2016
2 parents b42e181 + 3b9bb59 commit 3067cb0
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions gensim/matutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ def ret_normalized_vec(vec, length):
else:
return list(vec)

def ret_log_normalize_vec(vec, axis = 1):
def ret_log_normalize_vec(vec, axis=1):
log_max = 100.0
if len(vec.shape) == 1:
max_val = numpy.max(vec)
Expand All @@ -335,17 +335,17 @@ def ret_log_normalize_vec(vec, axis = 1):
log_norm = numpy.log(tot) - log_shift
vec = vec - log_norm
else:
if axis == 1:#independently normalize each sample
if axis == 1: # independently normalize each sample
max_val = numpy.max(vec, 1)
log_shift = log_max - numpy.log(vec.shape[1] + 1.0) - max_val
tot = numpy.sum(numpy.exp(vec + log_shift[:, numpy.newaxis]), 1)
log_norm = numpy.log(tot) - log_shift
vec = vec - log_norm[:, numpy.newaxis]
elif axis == 0:#normalize each feature
elif axis == 0: # normalize each feature
k = ret_log_normalize_vec(vec.T)
return (k[0].T, k[1])
else:
raise ValueError("'%d' is not a supported axis" % axis)
raise ValueError("'%s' is not a supported axis" % axis)
return (vec, log_norm)


Expand Down
8 changes: 4 additions & 4 deletions gensim/models/lsi_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class Worker(object):
def __init__(self):
self.model = None


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


@Pyro4.expose
@Pyro4.oneway
def requestjob(self):
"""
Expand Down Expand Up @@ -81,7 +81,7 @@ def processjob(self, job):
fname = os.path.join(tempfile.gettempdir(), 'lsi_worker.pkl')
self.model.save(fname)


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


@Pyro4.expose
@utils.synchronous('lock_update')
def reset(self):
logger.info("resetting worker #%i" % self.myid)
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions gensim/test/test_hdpmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from gensim.corpora import mmcorpus, Dictionary
from gensim.models import hdpmodel
from gensim import matutils
from gensim.test import test_basemodel
from gensim.test import basetests


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


class TestHdpModel(unittest.TestCase, test_basemodel.TestBaseTopicModel):
class TestHdpModel(unittest.TestCase, basetests.TestBaseTopicModel):
def setUp(self):
self.corpus = mmcorpus.MmCorpus(datapath('testcorpus.mm'))
self.class_ = hdpmodel.HdpModel
Expand Down
4 changes: 2 additions & 2 deletions gensim/test/test_ldamodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from gensim.corpora import mmcorpus, Dictionary
from gensim.models import ldamodel, ldamulticore
from gensim import matutils
from gensim.test import test_basemodel
from gensim.test import basetests


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


class TestLdaModel(unittest.TestCase, test_basemodel.TestBaseTopicModel):
class TestLdaModel(unittest.TestCase, basetests.TestBaseTopicModel):
def setUp(self):
self.corpus = mmcorpus.MmCorpus(datapath('testcorpus.mm'))
self.class_ = ldamodel.LdaModel
Expand Down
4 changes: 2 additions & 2 deletions gensim/test/test_lsimodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from gensim.corpora import mmcorpus, Dictionary
from gensim.models import lsimodel
from gensim import matutils
from gensim.test import test_basemodel
from gensim.test import basetests


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


class TestLsiModel(unittest.TestCase, test_basemodel.TestBaseTopicModel):
class TestLsiModel(unittest.TestCase, basetests.TestBaseTopicModel):
def setUp(self):
self.corpus = mmcorpus.MmCorpus(datapath('testcorpus.mm'))
self.model = lsimodel.LsiModel(self.corpus, num_topics=2)
Expand Down

0 comments on commit 3067cb0

Please sign in to comment.