Skip to content

Commit

Permalink
Rectify PR#950 to follow PEP8 (#966)
Browse files Browse the repository at this point in the history
  • Loading branch information
ArifAhmed1995 authored and tmylk committed Oct 20, 2016
1 parent b5a2b58 commit 3b9bb59
Showing 1 changed file with 4 additions and 4 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

0 comments on commit 3b9bb59

Please sign in to comment.