From ec4eeadc4b9fc248327154338e16a9303b019b7d Mon Sep 17 00:00:00 2001 From: Mark Susoil Date: Mon, 22 Mar 2021 09:47:09 -0600 Subject: [PATCH] vs 3.3.0 Deprecate PY 2.7, PY <3.7 Upgrading to be more current in PY3, fixing a few nits and bugs. --- .gitignore | 37 ++ .travis.yml | 28 +- CONTRIBUTING.rst | 29 +- HISTORY.rst | 9 + Pipfile | 24 ++ Pipfile.lock | 413 +++++++++++++++++++++++ notebooks/Gensim Newsgroup.ipynb | 2 +- pyLDAvis/__init__.py | 6 +- pyLDAvis/_display.py | 8 +- pyLDAvis/_prepare.py | 3 +- pyLDAvis/_server.py | 8 +- pyLDAvis/{gensim.py => gensim_models.py} | 5 +- pyLDAvis/graphlab.py | 2 - pyLDAvis/utils.py | 8 +- pyproject.toml | 3 + requirements.txt | 16 +- setup.cfg | 2 +- setup.py | 20 +- tests/pyLDAvis/test_gensim_models.py | 23 +- tests/pyLDAvis/test_prepare.py | 5 +- tox.ini | 14 +- 21 files changed, 573 insertions(+), 92 deletions(-) create mode 100644 Pipfile create mode 100644 Pipfile.lock rename pyLDAvis/{gensim.py => gensim_models.py} (97%) create mode 100644 pyproject.toml diff --git a/.gitignore b/.gitignore index 24cab940..af3fb36c 100644 --- a/.gitignore +++ b/.gitignore @@ -52,3 +52,40 @@ docs/_build # Mac OS .DS_Store + +### Python.VirtualEnv Stack ### +# Virtualenv +# http://iamzed.com/2009/05/07/a-primer-on-virtualenv/ +[Bb]in +[Ii]nclude +[Ll]ib +[Ll]ib64 +[Ll]ocal +[Ss]cripts +pyvenv.cfg +pip-selfcheck.json + +# Pip +# Pipfile +# Pipfile.lock +pypi_package.iml +# pyproject.toml + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST diff --git a/.travis.yml b/.travis.yml index 9ce0015c..3b529737 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,24 +3,17 @@ language: python python: + - "3.9" + - "3.8" - "3.7" - - "3.6" - - "3.5" - - "2.7" env: - - DEPS="pytest gensim smart_open==2.0.0" PY35_DEPS="pytest gensim" PY27_DEPS="pytest gensim==3.4.0 pytz" + - DEPS="pytest gensim smart_open==2.0.0" before_install: # conda instructions from http://conda.pydata.org/docs/travis.html - sudo apt-get update - # We do this conditionally because it saves us some downloading if the - # version is the same. - - if [[ "$TRAVIS_PYTHON_VERSION" == "2.7" ]]; then - wget https://repo.continuum.io/miniconda/Miniconda2-latest-Linux-x86_64.sh -O miniconda.sh; - else - wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh; - fi + - wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh - bash miniconda.sh -b -p $HOME/miniconda - source "$HOME/miniconda/etc/profile.d/conda.sh" - hash -r @@ -33,17 +26,10 @@ install: # download JSON data from github since travis does not have git-lfs rolled out yet - (cd tests/data; curl -L -O https://github.com/bmabey/pyLDAvis/raw/master/tests/data/movie_reviews_input.json && curl -L -O https://github.com/bmabey/pyLDAvis/raw/master/tests/data/movie_reviews_output.json) - ls -la tests/data/ - # Python 2.7 needs a pinned version of gensim and a few other things with Conda - - if [[ "$TRAVIS_PYTHON_VERSION" == "2.7" ]]; then - conda create -n testenv --yes python=$TRAVIS_PYTHON_VERSION $PY27_DEPS; - elif [[ "$TRAVIS_PYTHON_VERSION" == "3.5" ]]; then - conda create -n testenv --yes python=$TRAVIS_PYTHON_VERSION $PY35_DEPS; - else - conda create -n testenv --yes python=$TRAVIS_PYTHON_VERSION $DEPS; - fi + - conda create -n testenv --yes python=$TRAVIS_PYTHON_VERSION $DEPS - conda activate testenv - pip install . -# command to run tests, e.g. python setup.py test +# command to run tests, e.g. pytest script: - - pytest \ No newline at end of file + - pytest diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index b86e8f05..fde94bc6 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -99,6 +99,33 @@ Before you submit a pull request, check that it meets these guidelines: 2. If the pull request adds functionality, the docs should be updated. Put your new functionality into a function with a docstring, and add the feature to the list in README.rst. -3. The pull request should work for Python 2.7, 3.5, 3.6, 3.7, 3.8, 3.9, and for PyPy. Check +3. The pull request should work for Python 3.7, 3.8, 3.9, and for PyPI. Check https://travis-ci.org/bmabey/pyLDAvis/pull_requests and make sure that the tests pass for all supported Python versions. + +Maintainers +------------ + +Ready to publish a new version to PyPi? Here's how the workflow to follow. + +1. Ensure you are in the pyLDAvis directory +2. Pipenv workflow:: + + $ pipenv install -e . + $ pipenv install --dev + $ pipenv shell + (pyLDAvis) $ flake8 pyLDAvis tests + (pyLDAvis) $ pytest + (pyLDAvis) $ tox + + -- TestPyPi + (pyLDAvis) $ python setup.py sdist + (pyLDAvis) $ twine check dist/* + (pyLDAvis) $ twine upload --repository testpypi dist/* + + -- Publish + (pyLDAvis) $ twine upload --repository-url https://upload.pypi.org/legacy/ dist/* + +Note: MacOS Big Sur is both 10.16 and 11.0 – it’s official (https://eclecticlight.co/2020/07/21/big-sur-is-both-10-16-and-11-0-its-official/) :: + + $ export SYSTEM_VERSION_COMPAT=1 diff --git a/HISTORY.rst b/HISTORY.rst index ec32adea..83779b3e 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -3,6 +3,15 @@ History ------- +3.3.0 (2021-03-16) +-------------------- + +* Python 3.7, 3.8, 3.9: dropped 2.7, 3.5, 3.6 support. +* RuntimeWarning: divide by zero encountered in log #174 +* Deprecation warning due to invalid escape sequences #166 +* `python setup.py test` is deprecated +* FutureWarning: pandas.util.testing is deprecated + 3.2.2 (2021-02-19) -------------------- diff --git a/Pipfile b/Pipfile new file mode 100644 index 00000000..80f2d1c0 --- /dev/null +++ b/Pipfile @@ -0,0 +1,24 @@ +[[source]] +url = "https://pypi.org/simple" +verify_ssl = true +name = "pypi" + +[packages] +pyLDAvis = {editable = true, path = "."} +numpy = ">=1.20.1" +scipy = "*" +pandas = "*" +joblib = "*" +numexpr = "*" +future = "*" +funcy = "*" +sklearn = "*" +scikit-learn = "*" +gensim = "*" +Jinja2 = "*" + +[dev-packages] +pytest = ">=3.7" + +[requires] +python_version = "3.9" diff --git a/Pipfile.lock b/Pipfile.lock new file mode 100644 index 00000000..efbd3e1f --- /dev/null +++ b/Pipfile.lock @@ -0,0 +1,413 @@ +{ + "_meta": { + "hash": { + "sha256": "2fa2288a26aecbe2df783decec619957f925a9bff8044da959f04a6dd0809764" + }, + "pipfile-spec": 6, + "requires": { + "python_version": "3.9" + }, + "sources": [ + { + "name": "pypi", + "url": "https://pypi.org/simple", + "verify_ssl": true + } + ] + }, + "default": { + "funcy": { + "hashes": [ + "sha256:65b746fed572b392d886810a98d56939c6e0d545abb750527a717c21ced21008", + "sha256:c247c3d085e03a89974e0c9e8331e9a79db3768a263556ba896d6c92d665bba2" + ], + "index": "pypi", + "version": "==1.15" + }, + "future": { + "hashes": [ + "sha256:b1bead90b70cf6ec3f0710ae53a525360fa360d306a86583adc6bf83a4db537d" + ], + "index": "pypi", + "version": "==0.18.2" + }, + "gensim": { + "hashes": [ + "sha256:05bfc02e102a34c9c795095b688b1b4aaa2529c624821368c9c3ea6a16536f77", + "sha256:1e3d66c2eec494376fc599701d9c2868549aed6e93e47177e39217f0188e2d88", + "sha256:22f45fd239cacd0e3715ac447a2c8a5eea02e730ec1f701c55b359e9298e63a8", + "sha256:3af62709369331c85552fd26caa21504baa64accc426dc094172f5c688750013", + "sha256:41dcf6ecdc9acc657157967c791b8cbaba90ee6391f64efd28339b72f5e0c327", + "sha256:440700e29b494bc2e1d52e14b69a821f46ab09ecf85cf36c8988f18e1d6c7a8b", + "sha256:4e34cf2e50f3eab3e303da46089ea4972567bf216e28f7535ada155770784ac8", + "sha256:61eed1d6b5fbe6dda0586ea447ebc2dc7890a7f70c2ed953d5abc3fe3cfb94bb", + "sha256:637fc5969f3cef4b7c8fd3e78e31ef09565c5566d5ceabf076b4170eb6444a80", + "sha256:6711b6d3a0007530ee7de7adc30a4c48a1d26ec6312ac50e1d1e0a1d54f9de5b", + "sha256:685a7657278161628821c8f873c5d7d2ffc0c28866648e39f76b450e4c7d5390", + "sha256:7629b33cf35f672efdd5269381f7e301958ee2638f27dfc63b80c5bfeaa827d3", + "sha256:786adb0571f75114e9c5f7a31dd2e6eb39a9791f22c8757621545e2ded3ea367", + "sha256:7a90549dfc8ee3822fcad6da957de07d927e4e90ef42b3699543dee35ab2da13", + "sha256:8ff471921b3b10ffb3ae6cbb598dd9c07d9dc030dee5aa167e7682b549c42f87", + "sha256:90115d12ee545c21cc75521ef1bb3dd66aae8a378e9c2eb029c9f22df173c125", + "sha256:91fa62d61b21f1878f140b10520f9de4a26a52672fbe407edfc7e09ca2eff235", + "sha256:9c214b341f5304b906c79844e2787c13b46505df9dc70afca79a9a7dc0894478", + "sha256:a47903d104469a7a8b6f22ad5ef74681b19c4f4b71ff2c2893271b53161a43e4", + "sha256:a61179df454a0d4b06a111c4ede0536f61c8121b4c0d0d02d23560a2fd4b3aff", + "sha256:a8807ebf324dd11e1298a91a92d6e57c7bdabb91d0d5240bf1efa0c0eacd86f0", + "sha256:b36e6330471061cfd78aad751e24c6b4f56d575697af0fbab42655128927d296", + "sha256:b61a7c841a752c84b685674aa0d610289faad38795b325176481abe19b487e98", + "sha256:cc387d0d8bddbf3609ab95b3453296e4c9ff92c35e9799a17d86b1571d77a5fc", + "sha256:d79370f78e9013b9d1e867c85ecc678d46a7ae0f01a8ca29e8f4291e5373b170", + "sha256:ef2ddeceff482aee17c1e185f63bf027c8de8f595fdd9fd2d2503de96008f3b7", + "sha256:f8ea67bf8c47ee55cb1b32c97fa1474b7d6d22959dd8097c019a5d9c9df34f5f", + "sha256:fe98277a7b3b4987b40c928056bbaae1d0715022cf27bba89d05cd0d4fe51a84" + ], + "index": "pypi", + "version": "==3.8.3" + }, + "jinja2": { + "hashes": [ + "sha256:03e47ad063331dd6a3f04a43eddca8a966a26ba0c5b7207a9a9e4e08f1b29419", + "sha256:a6d58433de0ae800347cab1fa3043cebbabe8baa9d29e668f1c768cb87a333c6" + ], + "index": "pypi", + "version": "==2.11.3" + }, + "joblib": { + "hashes": [ + "sha256:9c17567692206d2f3fb9ecf5e991084254fe631665c450b443761c4186a613f7", + "sha256:feeb1ec69c4d45129954f1b7034954241eedfd6ba39b5e9e4b6883be3332d5e5" + ], + "index": "pypi", + "version": "==1.0.1" + }, + "markupsafe": { + "hashes": [ + "sha256:00bc623926325b26bb9605ae9eae8a215691f33cae5df11ca5424f06f2d1f473", + "sha256:09027a7803a62ca78792ad89403b1b7a73a01c8cb65909cd876f7fcebd79b161", + "sha256:09c4b7f37d6c648cb13f9230d847adf22f8171b1ccc4d5682398e77f40309235", + "sha256:1027c282dad077d0bae18be6794e6b6b8c91d58ed8a8d89a89d59693b9131db5", + "sha256:13d3144e1e340870b25e7b10b98d779608c02016d5184cfb9927a9f10c689f42", + "sha256:195d7d2c4fbb0ee8139a6cf67194f3973a6b3042d742ebe0a9ed36d8b6f0c07f", + "sha256:22c178a091fc6630d0d045bdb5992d2dfe14e3259760e713c490da5323866c39", + "sha256:24982cc2533820871eba85ba648cd53d8623687ff11cbb805be4ff7b4c971aff", + "sha256:29872e92839765e546828bb7754a68c418d927cd064fd4708fab9fe9c8bb116b", + "sha256:2beec1e0de6924ea551859edb9e7679da6e4870d32cb766240ce17e0a0ba2014", + "sha256:3b8a6499709d29c2e2399569d96719a1b21dcd94410a586a18526b143ec8470f", + "sha256:43a55c2930bbc139570ac2452adf3d70cdbb3cfe5912c71cdce1c2c6bbd9c5d1", + "sha256:46c99d2de99945ec5cb54f23c8cd5689f6d7177305ebff350a58ce5f8de1669e", + "sha256:500d4957e52ddc3351cabf489e79c91c17f6e0899158447047588650b5e69183", + "sha256:535f6fc4d397c1563d08b88e485c3496cf5784e927af890fb3c3aac7f933ec66", + "sha256:596510de112c685489095da617b5bcbbac7dd6384aeebeda4df6025d0256a81b", + "sha256:62fe6c95e3ec8a7fad637b7f3d372c15ec1caa01ab47926cfdf7a75b40e0eac1", + "sha256:6788b695d50a51edb699cb55e35487e430fa21f1ed838122d722e0ff0ac5ba15", + "sha256:6dd73240d2af64df90aa7c4e7481e23825ea70af4b4922f8ede5b9e35f78a3b1", + "sha256:6f1e273a344928347c1290119b493a1f0303c52f5a5eae5f16d74f48c15d4a85", + "sha256:6fffc775d90dcc9aed1b89219549b329a9250d918fd0b8fa8d93d154918422e1", + "sha256:717ba8fe3ae9cc0006d7c451f0bb265ee07739daf76355d06366154ee68d221e", + "sha256:79855e1c5b8da654cf486b830bd42c06e8780cea587384cf6545b7d9ac013a0b", + "sha256:7c1699dfe0cf8ff607dbdcc1e9b9af1755371f92a68f706051cc8c37d447c905", + "sha256:7fed13866cf14bba33e7176717346713881f56d9d2bcebab207f7a036f41b850", + "sha256:84dee80c15f1b560d55bcfe6d47b27d070b4681c699c572af2e3c7cc90a3b8e0", + "sha256:88e5fcfb52ee7b911e8bb6d6aa2fd21fbecc674eadd44118a9cc3863f938e735", + "sha256:8defac2f2ccd6805ebf65f5eeb132adcf2ab57aa11fdf4c0dd5169a004710e7d", + "sha256:98bae9582248d6cf62321dcb52aaf5d9adf0bad3b40582925ef7c7f0ed85fceb", + "sha256:98c7086708b163d425c67c7a91bad6e466bb99d797aa64f965e9d25c12111a5e", + "sha256:9add70b36c5666a2ed02b43b335fe19002ee5235efd4b8a89bfcf9005bebac0d", + "sha256:9bf40443012702a1d2070043cb6291650a0841ece432556f784f004937f0f32c", + "sha256:a6a744282b7718a2a62d2ed9d993cad6f5f585605ad352c11de459f4108df0a1", + "sha256:acf08ac40292838b3cbbb06cfe9b2cb9ec78fce8baca31ddb87aaac2e2dc3bc2", + "sha256:ade5e387d2ad0d7ebf59146cc00c8044acbd863725f887353a10df825fc8ae21", + "sha256:b00c1de48212e4cc9603895652c5c410df699856a2853135b3967591e4beebc2", + "sha256:b1282f8c00509d99fef04d8ba936b156d419be841854fe901d8ae224c59f0be5", + "sha256:b1dba4527182c95a0db8b6060cc98ac49b9e2f5e64320e2b56e47cb2831978c7", + "sha256:b2051432115498d3562c084a49bba65d97cf251f5a331c64a12ee7e04dacc51b", + "sha256:b7d644ddb4dbd407d31ffb699f1d140bc35478da613b441c582aeb7c43838dd8", + "sha256:ba59edeaa2fc6114428f1637ffff42da1e311e29382d81b339c1817d37ec93c6", + "sha256:bf5aa3cbcfdf57fa2ee9cd1822c862ef23037f5c832ad09cfea57fa846dec193", + "sha256:c8716a48d94b06bb3b2524c2b77e055fb313aeb4ea620c8dd03a105574ba704f", + "sha256:caabedc8323f1e93231b52fc32bdcde6db817623d33e100708d9a68e1f53b26b", + "sha256:cd5df75523866410809ca100dc9681e301e3c27567cf498077e8551b6d20e42f", + "sha256:cdb132fc825c38e1aeec2c8aa9338310d29d337bebbd7baa06889d09a60a1fa2", + "sha256:d53bc011414228441014aa71dbec320c66468c1030aae3a6e29778a3382d96e5", + "sha256:d73a845f227b0bfe8a7455ee623525ee656a9e2e749e4742706d80a6065d5e2c", + "sha256:d9be0ba6c527163cbed5e0857c451fcd092ce83947944d6c14bc95441203f032", + "sha256:e249096428b3ae81b08327a63a485ad0878de3fb939049038579ac0ef61e17e7", + "sha256:e8313f01ba26fbbe36c7be1966a7b7424942f670f38e666995b88d012765b9be", + "sha256:feb7b34d6325451ef96bc0e36e1a6c0c1c64bc1fbec4b854f4529e51887b1621" + ], + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", + "version": "==1.1.1" + }, + "numexpr": { + "hashes": [ + "sha256:05b97b19e864a5d1a0b106933b1637233a2444fd375685bead264a818f847ef2", + "sha256:0732c9989bff8568ee78fa461f3698166d4ac79363860be22ff49eae1dcd15e7", + "sha256:23718ac5f2ebae995f5899509624781b375da568f2b645b5d1fd6dbb17f41a56", + "sha256:24cdb8c0e93f31387a4c2ddd09a687874c006e6139fd68bcf77b96e51d17cb01", + "sha256:2e14b44a79030fbe25f16393162a4d21ced14056fac49ff73856f661a78db731", + "sha256:3daa55515ee3cb40bf5ab8263c0c13fff8d484d64d107a9c414e8ca151dc08a6", + "sha256:43616529f9b7d1afc83386f943dc66c4da5e052f00217ba7e3ad8dd1b5f3a825", + "sha256:4527a0a7b04f858a73c348c9c4ce8441b7a54965db74a32ba808c51d9d53b7cd", + "sha256:51277a530a353e0f94665b44615249d7e7075f0c73f78d4743da632fc44bc648", + "sha256:5223a519f48754dd350723d9fbcadbcd0476881bc954a281a09a6538ecabfc27", + "sha256:5d6dbf050a9b8ebff0b7706ebeaf1cd57d64ef4dfe61aef3790851b481daf6b5", + "sha256:5f4122bd58aa4e4891814c2f72bd47b1cdb202c9d863ea96c5394dffb72a16e2", + "sha256:602df9b5c500d0a887dc96b4cfd16fb60ae7ef39ccd6f013f4df2ee11ae70553", + "sha256:618259287b8b81a352a7d088ad03fe3b393a842ccb45f0b3cfc6a712d41b7595", + "sha256:74df157ab4577bfc83c14f4e39d14781b06ade5406d3efef049f90c88d8c28ea", + "sha256:785065819ce98e3d3dd853794244e0de190d7ba36ab42c8fd79e0e9cd40de7af", + "sha256:7ab40e2b438f4ea2ea8234c63639cdf5072cdb29d0ac521307854efe0281a567", + "sha256:833a363c86266424349467b53f4060f77aaa7ec03c1e6f38c54e69c65ceebf30", + "sha256:8b76bcca930cbf0db0fe98b6a51d6286dff77d525dad670cb7750e29a138d434", + "sha256:8fc23a49f4266c24a23310c0cb92ff54c4b4f535635f90372b3a2d5cb1f83329", + "sha256:90ea6d5813e1906bb203ef220a600b30d83e75aea2607a7e7037cceae9e93346", + "sha256:97753d17d1ea39e082b1907b99b6cb63cac7d1dfa512d2ff5079eb7bfab1ea88", + "sha256:99472731bc1111f5d73285dd2a4c228b5bfb176f785a567872e0fbfec6584f2b", + "sha256:a3f1cec8657bd3920869a2ea27f98d68ac3000334f366d844a9670ae671fe4bd", + "sha256:a8e0e48d72391543b68d0471fac2e31c614efdce4036e2a0a8a182fde1edb0e0", + "sha256:aae4ce158da53ebc47df053de90fed9d0d51fa0df8cc481abc8a901ea4f0cec7", + "sha256:b0a9124a66a61b05ea84b832358d6aa5561c30e69b4dcaea819b296f4f025f89", + "sha256:c2605e5665b0d7362e0d2b92683387c12e15c7440daf702a7637f7502a967810", + "sha256:c9218aeb76717768f617362b72a87e9219da95ba7cdec0732ccecc4a4719124c", + "sha256:c978c49bd9dded6a4ba6b3501e3a34e3aba9312cbb7d800bed7ac6fcd2d5949d", + "sha256:d14ae09318ad86579e35aacf1596c83d5db1139cd68615967ee23605e11f5d82", + "sha256:d423441593a952ac56d1f774068b81fb22f514fb68873c066578345a6af74c0d", + "sha256:dc707486b1f3dda18a39bc4d06a0a09d3c0ea47bd6b99fdb98adb26d1277253f", + "sha256:dfdca3d1f4c83fa8fd3ee7573110efd13e838543896641b89367622ec6a67eb4", + "sha256:e000570a6a704c594832ff4fc45f18864b721b7b444a185b365dbb03d3fe3abb", + "sha256:e985026e64350dd59fd91a09bc364edf706d58b12e01362ddfa63829878bd434", + "sha256:eeeb6325df6cf3f3ab7d9dbabf3bc03ac88b7e2f2aed21419c31e23c3048dce1", + "sha256:f9df0a74d39616fd011071c5850418f244bac414f24ed55c00dcf3c5385e8374" + ], + "index": "pypi", + "version": "==2.7.3" + }, + "numpy": { + "hashes": [ + "sha256:032be656d89bbf786d743fee11d01ef318b0781281241997558fa7950028dd29", + "sha256:104f5e90b143dbf298361a99ac1af4cf59131218a045ebf4ee5990b83cff5fab", + "sha256:125a0e10ddd99a874fd357bfa1b636cd58deb78ba4a30b5ddb09f645c3512e04", + "sha256:12e4ba5c6420917571f1a5becc9338abbde71dd811ce40b37ba62dec7b39af6d", + "sha256:13adf545732bb23a796914fe5f891a12bd74cf3d2986eed7b7eba2941eea1590", + "sha256:2d7e27442599104ee08f4faed56bb87c55f8b10a5494ac2ead5c98a4b289e61f", + "sha256:3bc63486a870294683980d76ec1e3efc786295ae00128f9ea38e2c6e74d5a60a", + "sha256:3d3087e24e354c18fb35c454026af3ed8997cfd4997765266897c68d724e4845", + "sha256:4ed8e96dc146e12c1c5cdd6fb9fd0757f2ba66048bf94c5126b7efebd12d0090", + "sha256:60759ab15c94dd0e1ed88241fd4fa3312db4e91d2c8f5a2d4cf3863fad83d65b", + "sha256:65410c7f4398a0047eea5cca9b74009ea61178efd78d1be9847fac1d6716ec1e", + "sha256:66b467adfcf628f66ea4ac6430ded0614f5cc06ba530d09571ea404789064adc", + "sha256:7199109fa46277be503393be9250b983f325880766f847885607d9b13848f257", + "sha256:72251e43ac426ff98ea802a931922c79b8d7596480300eb9f1b1e45e0543571e", + "sha256:89e5336f2bec0c726ac7e7cdae181b325a9c0ee24e604704ed830d241c5e47ff", + "sha256:89f937b13b8dd17b0099c7c2e22066883c86ca1575a975f754babc8fbf8d69a9", + "sha256:9c94cab5054bad82a70b2e77741271790304651d584e2cdfe2041488e753863b", + "sha256:9eb551d122fadca7774b97db8a112b77231dcccda8e91a5bc99e79890797175e", + "sha256:a1d7995d1023335e67fb070b2fae6f5968f5be3802b15ad6d79d81ecaa014fe0", + "sha256:ae61f02b84a0211abb56462a3b6cd1e7ec39d466d3160eb4e1da8bf6717cdbeb", + "sha256:b9410c0b6fed4a22554f072a86c361e417f0258838957b78bd063bde2c7f841f", + "sha256:c26287dfc888cf1e65181f39ea75e11f42ffc4f4529e5bd19add57ad458996e2", + "sha256:c91ec9569facd4757ade0888371eced2ecf49e7982ce5634cc2cf4e7331a4b14", + "sha256:ecb5b74c702358cdc21268ff4c37f7466357871f53a30e6f84c686952bef16a9" + ], + "index": "pypi", + "version": "==1.20.1" + }, + "pandas": { + "hashes": [ + "sha256:09761bf5f8c741d47d4b8b9073288de1be39bbfccc281d70b889ade12b2aad29", + "sha256:0f27fd1adfa256388dc34895ca5437eaf254832223812afd817a6f73127f969c", + "sha256:43e00770552595c2250d8d712ec8b6e08ca73089ac823122344f023efa4abea3", + "sha256:46fc671c542a8392a4f4c13edc8527e3a10f6cb62912d856f82248feb747f06e", + "sha256:475b7772b6e18a93a43ea83517932deff33954a10d4fbae18d0c1aba4182310f", + "sha256:4d821b9b911fc1b7d428978d04ace33f0af32bb7549525c8a7b08444bce46b74", + "sha256:5e3c8c60541396110586bcbe6eccdc335a38e7de8c217060edaf4722260b158f", + "sha256:621c044a1b5e535cf7dcb3ab39fca6f867095c3ef223a524f18f60c7fee028ea", + "sha256:72ffcea00ae8ffcdbdefff800284311e155fbb5ed6758f1a6110fc1f8f8f0c1c", + "sha256:8a051e957c5206f722e83f295f95a2cf053e890f9a1fba0065780a8c2d045f5d", + "sha256:97b1954533b2a74c7e20d1342c4f01311d3203b48f2ebf651891e6a6eaf01104", + "sha256:9f5829e64507ad10e2561b60baf285c470f3c4454b007c860e77849b88865ae7", + "sha256:a93e34f10f67d81de706ce00bf8bb3798403cabce4ccb2de10c61b5ae8786ab5", + "sha256:d59842a5aa89ca03c2099312163ffdd06f56486050e641a45d926a072f04d994", + "sha256:dbb255975eb94143f2e6ec7dadda671d25147939047839cd6b8a4aff0379bb9b", + "sha256:df6f10b85aef7a5bb25259ad651ad1cc1d6bb09000595cab47e718cbac250b1d" + ], + "index": "pypi", + "version": "==1.2.3" + }, + "pyldavis": { + "editable": true, + "path": "." + }, + "python-dateutil": { + "hashes": [ + "sha256:73ebfe9dbf22e832286dafa60473e4cd239f8592f699aa5adaf10050e6e1823c", + "sha256:75bb3f31ea686f1197762692a9ee6a7550b59fc6ca3a1f4b5d7e32fb98e2da2a" + ], + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2'", + "version": "==2.8.1" + }, + "pytz": { + "hashes": [ + "sha256:83a4a90894bf38e243cf052c8b58f381bfe9a7a483f6a9cab140bc7f702ac4da", + "sha256:eb10ce3e7736052ed3623d49975ce333bcd712c7bb19a58b9e2089d4057d0798" + ], + "version": "==2021.1" + }, + "scikit-learn": { + "hashes": [ + "sha256:0567a2d29ad08af98653300c623bd8477b448fe66ced7198bef4ed195925f082", + "sha256:087dfede39efb06ab30618f9ab55a0397f29c38d63cd0ab88d12b500b7d65fd7", + "sha256:1adf483e91007a87171d7ce58c34b058eb5dab01b5fee6052f15841778a8ecd8", + "sha256:259ec35201e82e2db1ae2496f229e63f46d7f1695ae68eef9350b00dc74ba52f", + "sha256:3c4f07f47c04e81b134424d53c3f5e16dfd7f494e44fd7584ba9ce9de2c5e6c1", + "sha256:4562dcf4793e61c5d0f89836d07bc37521c3a1889da8f651e2c326463c4bd697", + "sha256:4ddd2b6f7449a5d539ff754fa92d75da22de261fd8fdcfb3596799fadf255101", + "sha256:7b04691eb2f41d2c68dbda8d1bd3cb4ef421bdc43aaa56aeb6c762224552dfb6", + "sha256:826b92bf45b8ad80444814e5f4ac032156dd481e48d7da33d611f8fe96d5f08b", + "sha256:83b21ff053b1ff1c018a2d24db6dd3ea339b1acfbaa4d9c881731f43748d8b3b", + "sha256:8772b99d683be8f67fcc04789032f1b949022a0e6880ee7b75a7ec97dbbb5d0b", + "sha256:895dbf2030aa7337649e36a83a007df3c9811396b4e2fa672a851160f36ce90c", + "sha256:8aa1b3ac46b80eaa552b637eeadbbce3be5931e4b5002b964698e33a1b589e1e", + "sha256:99349d77f54e11f962d608d94dfda08f0c9e5720d97132233ebdf35be2858b2d", + "sha256:9a24d1ccec2a34d4cd3f2a1f86409f3f5954cc23d4d2270ba0d03cf018aa4780", + "sha256:9bed8a1ef133c8e2f13966a542cb8125eac7f4b67dcd234197c827ba9c7dd3e0", + "sha256:9c6097b6a9b2bafc5e0f31f659e6ab5e131383209c30c9e978c5b8abdac5ed2a", + "sha256:9dfa564ef27e8e674aa1cc74378416d580ac4ede1136c13dd555a87996e13422", + "sha256:a0334a1802e64d656022c3bfab56a73fbd6bf4b1298343f3688af2151810bbdf", + "sha256:a29460499c1e62b7a830bb57ca42e615375a6ab1bcad053cd25b493588348ea8", + "sha256:a36e159a0521e13bbe15ca8c8d038b3a1dd4c7dad18d276d76992e03b92cf643", + "sha256:c13ebac42236b1c46397162471ea1c46af68413000e28b9309f8c05722c65a09", + "sha256:c3deb3b19dd9806acf00cf0d400e84562c227723013c33abefbbc3cf906596e9", + "sha256:c658432d8a20e95398f6bb95ff9731ce9dfa343fdf21eea7ec6a7edfacd4b4d9", + "sha256:c7f4eb77504ac586d8ac1bde1b0c04b504487210f95297235311a0ab7edd7e38", + "sha256:d54dbaadeb1425b7d6a66bf44bee2bb2b899fe3e8850b8e94cfb9c904dcb46d0", + "sha256:ddb52d088889f5596bc4d1de981f2eca106b58243b6679e4782f3ba5096fd645", + "sha256:ed9d65594948678827f4ff0e7ae23344e2f2b4cabbca057ccaed3118fdc392ca", + "sha256:fab31f48282ebf54dd69f6663cd2d9800096bad1bb67bbc9c9ac84eb77b41972" + ], + "index": "pypi", + "version": "==0.24.1" + }, + "scipy": { + "hashes": [ + "sha256:0c8a51d33556bf70367452d4d601d1742c0e806cd0194785914daf19775f0e67", + "sha256:0e5b0ccf63155d90da576edd2768b66fb276446c371b73841e3503be1d63fb5d", + "sha256:2481efbb3740977e3c831edfd0bd9867be26387cacf24eb5e366a6a374d3d00d", + "sha256:33d6b7df40d197bdd3049d64e8e680227151673465e5d85723b3b8f6b15a6ced", + "sha256:5da5471aed911fe7e52b86bf9ea32fb55ae93e2f0fac66c32e58897cfb02fa07", + "sha256:5f331eeed0297232d2e6eea51b54e8278ed8bb10b099f69c44e2558c090d06bf", + "sha256:5fa9c6530b1661f1370bcd332a1e62ca7881785cc0f80c0d559b636567fab63c", + "sha256:6725e3fbb47da428794f243864f2297462e9ee448297c93ed1dcbc44335feb78", + "sha256:68cb4c424112cd4be886b4d979c5497fba190714085f46b8ae67a5e4416c32b4", + "sha256:794e768cc5f779736593046c9714e0f3a5940bc6dcc1dba885ad64cbfb28e9f0", + "sha256:83bf7c16245c15bc58ee76c5418e46ea1811edcc2e2b03041b804e46084ab627", + "sha256:8e403a337749ed40af60e537cc4d4c03febddcc56cd26e774c9b1b600a70d3e4", + "sha256:a15a1f3fc0abff33e792d6049161b7795909b40b97c6cc2934ed54384017ab76", + "sha256:a423533c55fec61456dedee7b6ee7dce0bb6bfa395424ea374d25afa262be261", + "sha256:a5193a098ae9f29af283dcf0041f762601faf2e595c0db1da929875b7570353f", + "sha256:bd50daf727f7c195e26f27467c85ce653d41df4358a25b32434a50d8870fc519", + "sha256:c4fceb864890b6168e79b0e714c585dbe2fd4222768ee90bc1aa0f8218691b11", + "sha256:e79570979ccdc3d165456dd62041d9556fb9733b86b4b6d818af7a0afc15f092", + "sha256:f46dd15335e8a320b0fb4685f58b7471702234cba8bb3442b69a3e1dc329c345" + ], + "index": "pypi", + "version": "==1.6.1" + }, + "six": { + "hashes": [ + "sha256:30639c035cdb23534cd4aa2dd52c3bf48f06e5f4a941509c8bafd8ce11080259", + "sha256:8b74bedcbbbaca38ff6d7491d76f2b06b3592611af620f8426e82dddb04a5ced" + ], + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2'", + "version": "==1.15.0" + }, + "sklearn": { + "hashes": [ + "sha256:e23001573aa194b834122d2b9562459bf5ae494a2d59ca6b8aa22c85a44c0e31" + ], + "index": "pypi", + "version": "==0.0" + }, + "smart-open": { + "hashes": [ + "sha256:d9f5a0f173ccb9bbae528db5a3804f57145815774f77ef755b9b0f3b4b2a9dcb" + ], + "markers": "python_version >= '3.6'", + "version": "==4.2.0" + }, + "threadpoolctl": { + "hashes": [ + "sha256:38b74ca20ff3bb42caca8b00055111d74159ee95c4370882bbff2b93d24da725", + "sha256:ddc57c96a38beb63db45d6c159b5ab07b6bced12c45a1f07b2b92f272aebfa6b" + ], + "markers": "python_version >= '3.5'", + "version": "==2.1.0" + } + }, + "develop": { + "attrs": { + "hashes": [ + "sha256:31b2eced602aa8423c2aea9c76a724617ed67cf9513173fd3a4f03e3a929c7e6", + "sha256:832aa3cde19744e49938b91fea06d69ecb9e649c93ba974535d08ad92164f700" + ], + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", + "version": "==20.3.0" + }, + "iniconfig": { + "hashes": [ + "sha256:011e24c64b7f47f6ebd835bb12a743f2fbe9a26d4cecaa7f53bc4f35ee9da8b3", + "sha256:bc3af051d7d14b2ee5ef9969666def0cd1a000e121eaea580d4a313df4b37f32" + ], + "version": "==1.1.1" + }, + "packaging": { + "hashes": [ + "sha256:5b327ac1320dc863dca72f4514ecc086f31186744b84a230374cc1fd776feae5", + "sha256:67714da7f7bc052e064859c05c595155bd1ee9f69f76557e21f051443c20947a" + ], + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", + "version": "==20.9" + }, + "pluggy": { + "hashes": [ + "sha256:15b2acde666561e1298d71b523007ed7364de07029219b604cf808bfa1c765b0", + "sha256:966c145cd83c96502c3c3868f50408687b38434af77734af1e9ca461a4081d2d" + ], + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", + "version": "==0.13.1" + }, + "py": { + "hashes": [ + "sha256:21b81bda15b66ef5e1a777a21c4dcd9c20ad3efd0b3f817e7a809035269e1bd3", + "sha256:3b80836aa6d1feeaa108e046da6423ab8f6ceda6468545ae8d02d9d58d18818a" + ], + "markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'", + "version": "==1.10.0" + }, + "pyparsing": { + "hashes": [ + "sha256:c203ec8783bf771a155b207279b9bccb8dea02d8f0c9e5f8ead507bc3246ecc1", + "sha256:ef9d7589ef3c200abe66653d3f1ab1033c3c419ae9b9bdb1240a85b024efc88b" + ], + "markers": "python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2'", + "version": "==2.4.7" + }, + "pytest": { + "hashes": [ + "sha256:9d1edf9e7d0b84d72ea3dbcdfd22b35fb543a5e8f2a60092dd578936bf63d7f9", + "sha256:b574b57423e818210672e07ca1fa90aaf194a4f63f3ab909a2c67ebb22913839" + ], + "index": "pypi", + "version": "==6.2.2" + }, + "toml": { + "hashes": [ + "sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b", + "sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f" + ], + "markers": "python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2'", + "version": "==0.10.2" + } + } +} diff --git a/notebooks/Gensim Newsgroup.ipynb b/notebooks/Gensim Newsgroup.ipynb index 509f62bb..2282381e 100644 --- a/notebooks/Gensim Newsgroup.ipynb +++ b/notebooks/Gensim Newsgroup.ipynb @@ -300,7 +300,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.5" + "version": "3.9.2" }, "name": "Gensim Newsgroup.ipynb" }, diff --git a/pyLDAvis/__init__.py b/pyLDAvis/__init__.py index 14085648..98b438c4 100755 --- a/pyLDAvis/__init__.py +++ b/pyLDAvis/__init__.py @@ -39,7 +39,7 @@ "display", "show", "save_html", "save_json", "enable_notebook", "disable_notebook"] -__version__ = '3.2.2' +__version__ = "3.3.0" -from ._display import * -from ._prepare import prepare, js_PCoA, PreparedData +from pyLDAvis._display import * +from pyLDAvis._prepare import prepare, js_PCoA, PreparedData diff --git a/pyLDAvis/_display.py b/pyLDAvis/_display.py index 39782984..17eec756 100644 --- a/pyLDAvis/_display.py +++ b/pyLDAvis/_display.py @@ -6,10 +6,10 @@ import json import jinja2 import re -from ._server import serve -from .utils import get_id, write_ipynb_local_js, NumPyEncoder -from ._prepare import PreparedData -from . import urls +from pyLDAvis._server import serve +from pyLDAvis.utils import get_id, write_ipynb_local_js, NumPyEncoder +from pyLDAvis._prepare import PreparedData +import pyLDAvis.urls as urls __all__ = ["prepared_data_to_html", "display", "show", "save_html", "save_json", diff --git a/pyLDAvis/_prepare.py b/pyLDAvis/_prepare.py index 8291db22..d50c1881 100644 --- a/pyLDAvis/_prepare.py +++ b/pyLDAvis/_prepare.py @@ -4,7 +4,6 @@ Main transformation functions for preparing LDAdata to the visualization's data structures """ -from __future__ import absolute_import from past.builtins import basestring from collections import namedtuple import json @@ -14,7 +13,7 @@ import pandas as pd from scipy.stats import entropy from scipy.spatial.distance import pdist, squareform -from .utils import NumPyEncoder +from pyLDAvis.utils import NumPyEncoder try: from sklearn.manifold import MDS, TSNE sklearn_present = True diff --git a/pyLDAvis/_server.py b/pyLDAvis/_server.py index 9c0bb731..5bb84b27 100644 --- a/pyLDAvis/_server.py +++ b/pyLDAvis/_server.py @@ -9,6 +9,7 @@ import socket import itertools import random +from http import server IPYTHON_WARNING = """ Note: if you're in the IPython notebook, pyLDAvis.show() is not the best command @@ -18,13 +19,6 @@ You must interrupt the kernel to end this command """ -try: - # Python 2.x - import BaseHTTPServer as server -except ImportError: - # Python 3.x - from http import server - def generate_handler(html, files=None): if files is None: diff --git a/pyLDAvis/gensim.py b/pyLDAvis/gensim_models.py similarity index 97% rename from pyLDAvis/gensim.py rename to pyLDAvis/gensim_models.py index 84e0c079..90d356e8 100644 --- a/pyLDAvis/gensim.py +++ b/pyLDAvis/gensim_models.py @@ -4,11 +4,10 @@ Helper functions to visualize LDA models trained by Gensim """ -from __future__ import absolute_import import funcy as fp import numpy as np from scipy.sparse import issparse -from . import prepare as vis_prepare +import pyLDAvis._prepare def _extract_data(topic_model, corpus, dictionary, doc_topic_dists=None): @@ -121,4 +120,4 @@ def prepare(topic_model, corpus, dictionary, doc_topic_dist=None, **kwargs): See `pyLDAvis.prepare` for **kwargs. """ opts = fp.merge(_extract_data(topic_model, corpus, dictionary, doc_topic_dist), kwargs) - return vis_prepare(**opts) + return pyLDAvis.prepare(**opts) diff --git a/pyLDAvis/graphlab.py b/pyLDAvis/graphlab.py index 9ef4b8ac..4af40f6a 100644 --- a/pyLDAvis/graphlab.py +++ b/pyLDAvis/graphlab.py @@ -4,8 +4,6 @@ Helper functions to visualize GraphLab Create's TopicModel (an implementation of LDA) """ -from __future__ import absolute_import - import funcy as fp import numpy as np import pandas as pd diff --git a/pyLDAvis/utils.py b/pyLDAvis/utils.py index 5d688a06..240e3e72 100644 --- a/pyLDAvis/utils.py +++ b/pyLDAvis/utils.py @@ -10,7 +10,7 @@ import shutil import warnings import numpy as np -from . import urls +import pyLDAvis.urls # Make sure that DeprecationWarning gets printed warnings.simplefilter("always", DeprecationWarning) @@ -83,11 +83,11 @@ def write_ipynb_local_js(location=None, d3_src=None, ldavis_src=None, ldavis_css location = os.getcwd() if d3_src is None: - d3_src = urls.D3_LOCAL + d3_src = pyLDAvis.urls.D3_LOCAL if ldavis_src is None: - ldavis_src = urls.LDAVIS_LOCAL + ldavis_src = pyLDAvis.urls.LDAVIS_LOCAL if ldavis_css is None: - ldavis_css = urls.LDAVIS_CSS_LOCAL + ldavis_css = pyLDAvis.urls.LDAVIS_CSS_LOCAL d3js = os.path.basename(d3_src) ldavisjs = os.path.basename(ldavis_src) diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..fed528d4 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["setuptools"] +build-backend = "setuptools.build_meta" diff --git a/requirements.txt b/requirements.txt index 63668b74..1d569ee4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,10 +1,12 @@ -wheel>=0.23.0 -numpy>=1.9.2 -scipy>=0.18.0 -pandas>=0.17.0,<0.24.0a; python_version <= "3.5" -pandas>=0.17.0; python_version > "3.5" -joblib>=0.8.4 -jinja2>=2.7.2 +numpy>=1.20.0 +scipy +pandas>=1.2.0 +joblib +jinja2 numexpr future funcy +sklearn +scikit-learn +gensim +setuptools \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index 5e409001..2a9acf13 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,2 +1,2 @@ -[wheel] +[bdist_wheel] universal = 1 diff --git a/setup.py b/setup.py index 3959d4a6..a8dc6c25 100755 --- a/setup.py +++ b/setup.py @@ -1,8 +1,6 @@ import os -from setuptools import setup, find_packages - -setup(name='reproducer', version='0.0.1', packages=find_packages(exclude=['tests'])) +from setuptools import setup with open('README.rst') as readme_file: readme = readme_file.read() @@ -20,32 +18,28 @@ setup( name='pyLDAvis', - version='3.2.2', - description="Interactive topic model visualization. Port of the R package.", + version='3.3.0', + description='Interactive topic model visualization. Port of the R package.', long_description=readme, - author="Ben Mabey", + author='Ben Mabey', author_email='ben@benmabey.com', url='https://github.com/bmabey/pyLDAvis', - download_url = 'https://github.com/bmabey/pyLDAvis/tarball/3.2.2', + download_url = 'https://github.com/bmabey/pyLDAvis/tarball/3.3.0', packages=['pyLDAvis'], package_dir={'pyLDAvis': 'pyLDAvis'}, tests_require=['pytest'], include_package_data=True, install_requires=requirements, - license="MIT", + license='MIT', zip_safe=False, keywords=['data science', 'visualization'], classifiers=[ - 'Development Status :: 2 - Pre-Alpha', + 'Development Status :: 5 - Production/Stable', 'Intended Audience :: Developers', 'Intended Audience :: Science/Research', 'License :: OSI Approved :: MIT License', 'Natural Language :: English', - "Programming Language :: Python :: 2", - 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.5', - 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', diff --git a/tests/pyLDAvis/test_gensim_models.py b/tests/pyLDAvis/test_gensim_models.py index 4ed8a51b..49d9704f 100755 --- a/tests/pyLDAvis/test_gensim_models.py +++ b/tests/pyLDAvis/test_gensim_models.py @@ -1,14 +1,16 @@ -#! /usr/bin/venv python +#! /usr/bin/venv python3 + +import os from gensim.models import LdaModel, HdpModel from gensim.corpora.dictionary import Dictionary -import pyLDAvis.gensim -import os + +import pyLDAvis +import pyLDAvis.gensim_models as gensim_models def get_corpus_dictionary(): """Crafts a toy corpus and the dictionary associated.""" - # Toy corpus. corpus = [ ['carrot', 'salad', 'tomato'], ['carrot', 'salad', 'dish'], @@ -20,7 +22,6 @@ def get_corpus_dictionary(): ['moto', 'break'], ['accident', 'moto', 'car'] ] - dictionary = Dictionary(corpus) # Transforming corpus with dictionary. @@ -36,11 +37,9 @@ def get_corpus_dictionary(): def test_lda(): """Trains a LDA model and tests the html outputs.""" corpus, dictionary = get_corpus_dictionary() + lda = LdaModel(corpus=corpus, num_topics=2) - lda = LdaModel(corpus=corpus, - num_topics=2) - - data = pyLDAvis.gensim.prepare(lda, corpus, dictionary) + data = gensim_models.prepare(lda, corpus, dictionary) pyLDAvis.save_html(data, 'index_lda.html') os.remove('index_lda.html') @@ -48,10 +47,9 @@ def test_lda(): def test_hdp(): """Trains a HDP model and tests the html outputs.""" corpus, dictionary = get_corpus_dictionary() - hdp = HdpModel(corpus, dictionary.id2token) - data = pyLDAvis.gensim.prepare(hdp, corpus, dictionary) + data = gensim_models.prepare(hdp, corpus, dictionary) pyLDAvis.save_html(data, 'index_hdp.html') os.remove('index_hdp.html') @@ -66,7 +64,7 @@ def test_sorted_terms(): corpus, dictionary = get_corpus_dictionary() lda = LdaModel(corpus=corpus, num_topics=2) - data = pyLDAvis.gensim.prepare(lda, corpus, dictionary) + data = gensim_models.prepare(lda, corpus, dictionary) # https://nlp.stanford.edu/events/illvi2014/papers/sievert-illvi2014.pdf # lambda = 0 should rank the terms by loglift # lambda = 1 should rank them by logprob. @@ -79,3 +77,4 @@ def test_sorted_terms(): if __name__ == "__main__": test_lda() test_hdp() + test_sorted_terms() diff --git a/tests/pyLDAvis/test_prepare.py b/tests/pyLDAvis/test_prepare.py index 153c5b0d..0324e82d 100644 --- a/tests/pyLDAvis/test_prepare.py +++ b/tests/pyLDAvis/test_prepare.py @@ -1,11 +1,8 @@ -from __future__ import division +#! /usr/bin/venv python3 import json import os.path as path - import funcy as fp - - from numpy.testing import assert_array_equal import numpy as np import pandas as pd diff --git a/tox.ini b/tox.ini index 17ef03b2..de819b5c 100644 --- a/tox.ini +++ b/tox.ini @@ -1,11 +1,11 @@ [tox] -envlist = py27, py33, py34 +envlist = py37, py38, py39 [testenv] -setenv = - PYTHONPATH = {toxinidir}:{toxinidir}/pyLDAvis -commands= - py.test \ - {posargs} # substitute with tox' positional arguments +install_command = pip3 install {opts} {packages} +whitelist_externals = sh, pytest +setenv = PYTHONPATH = {toxinidir}:{toxinidir}/pyLDAvis +commands = pytest {posargs} # substitute with tox' positional arguments deps = - -r{toxinidir}/requirements.txt + pytest + -r{toxinidir}/requirements.txt \ No newline at end of file