Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup (get rid py26 stuff) #2214

Merged
merged 6 commits into from
Oct 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
405 changes: 0 additions & 405 deletions ez_setup.py

This file was deleted.

9 changes: 1 addition & 8 deletions gensim/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,6 @@
__version__ = '3.6.0'


class NullHandler(logging.Handler):
"""For python versions <= 2.6; same as `logging.NullHandler` in 2.7."""

def emit(self, record):
pass


logger = logging.getLogger('gensim')
if len(logger.handlers) == 0: # To ensure reload() doesn't add another one
logger.addHandler(NullHandler())
logger.addHandler(logging.NullHandler())
2 changes: 1 addition & 1 deletion gensim/downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@

user_dir = os.path.expanduser('~')
base_dir = os.path.join(user_dir, 'gensim-data')
logger = logging.getLogger('gensim.api')
logger = logging.getLogger(__name__)

DATA_LIST_URL = "https://raw.githubusercontent.com/RaRe-Technologies/gensim-data/master/list.json"
DOWNLOAD_BASE_URL = "https://github.com/RaRe-Technologies/gensim-data/releases/download"
Expand Down
2 changes: 1 addition & 1 deletion gensim/models/rpmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
from gensim import interfaces, matutils, utils


logger = logging.getLogger('gensim.models.rpmodel')
logger = logging.getLogger(__name__)


class RpModel(interfaces.TransformationABC):
Expand Down
20 changes: 1 addition & 19 deletions gensim/models/wrappers/ldavowpalwabbit.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ def _get_vw_train_command(self, corpus_size, update=False):
# these params are read from model file if updating
cmd.extend([
'--lda', str(self.num_topics),
'-b', str(_bit_length(self.num_terms)),
'-b', str(self.num_terms.bit_length()),
'--lda_alpha', str(self.alpha),
'--lda_rho', str(self.eta)
])
Expand Down Expand Up @@ -857,24 +857,6 @@ def _run_vw_command(cmd):
return output


# if python2.6 support is ever dropped, can change to using int.bit_length()
def _bit_length(num):
"""Get number of bits needed to encode given number.

Parameters
----------
num : int
Number to encode.

Returns
-------
int
Number of bits needed to encode given number.

"""
return len(bin(num).lstrip('-0b'))


def vwmodel2ldamodel(vw_model, iterations=50):
"""Convert :class:`~gensim.models.wrappers.ldavowpalwabbit.LdaVowpalWabbit` to
:class:`~gensim.models.ldamodel.LdaModel`.
Expand Down
2 changes: 1 addition & 1 deletion gensim/summarization/textcleaner.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import re
import logging

logger = logging.getLogger('summarizer.preprocessing.cleaner')
logger = logging.getLogger(__name__)

try:
from pattern.en import tag
Expand Down
2 changes: 1 addition & 1 deletion gensim/test/test_miislita.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from gensim import utils, corpora, models, similarities
from gensim.test.utils import datapath, get_tmpfile

logger = logging.getLogger('test_miislita')
logger = logging.getLogger(__name__)


class CorpusMiislita(corpora.TextCorpus):
Expand Down
4 changes: 1 addition & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,12 @@
import platform
import sys
import warnings
import ez_setup
from setuptools import setup, find_packages, Extension
from setuptools.command.build_ext import build_ext

if sys.version_info[:2] < (2, 7) or (sys.version_info[:1] == 3 and sys.version_info[:2] < (3, 5)):
raise Exception('This version of gensim needs Python 2.7, 3.5 or later.')

ez_setup.use_setuptools()

# the following code is adapted from tornado's setup.py:
# https://github.com/tornadoweb/tornado/blob/master/setup.py
# to support installing without the extension on platforms where
Expand Down Expand Up @@ -334,6 +331,7 @@ def finalize_options(self):
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Topic :: Scientific/Engineering :: Artificial Intelligence',
'Topic :: Scientific/Engineering :: Information Analysis',
'Topic :: Text Processing :: Linguistic',
Expand Down