Skip to content

Commit

Permalink
suppresses numpy overflow warning while computing fasttext hash
Browse files Browse the repository at this point in the history
  • Loading branch information
jayantj committed Jan 6, 2017
1 parent ab07ef9 commit 2f37b04
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions gensim/models/wrappers/fasttext.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,9 +344,12 @@ def ft_hash(string):
used in fastText.
"""
# Runtime warnings for integer overflow are raised, this is expected behaviour. These warnings are suppressed.
old_settings = np.seterr(all='ignore')
h = np.uint32(2166136261)
for c in string:
h = h ^ np.uint32(ord(c))
h = h * np.uint32(16777619)
np.seterr(**old_settings)
return h

0 comments on commit 2f37b04

Please sign in to comment.