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

MAINT: collections import is deprecated #6664

Merged
merged 1 commit into from Dec 8, 2018
Merged

Conversation

andyfaff
Copy link
Contributor

In Py37 importing from collections is a DeprecationWarning and will become an Exception in Py38.

/Users/anz/miniconda3/envs/dev3/lib/python3.7/site-packages/theano/compat/__init__.py:79: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
  not isinstance(default_factory, collections.Callable)):

@twiecki
Copy link
Contributor

twiecki commented Nov 29, 2018

Thanks @andyfaff, LGTM!

@nouiz nouiz merged commit 31b853f into Theano:master Dec 8, 2018
@hroncok
Copy link
Contributor

hroncok commented Feb 4, 2020

There is a slight problem in this PR that makes the code broken with Python 3.9.

OrderedDict is not an abstract base class, so the first import will always fail. The second one only succeeds on Python up to 3.8.

Traceback (most recent call last):
  File "/builddir/build/BUILD/Theano-rel-1.0.4/theano/compat/__init__.py", line 10, in <module>
    from collections.abc import (OrderedDict, MutableMapping as DictMixin,
ImportError: cannot import name 'OrderedDict' from 'collections.abc' (/usr/lib64/python3.9/collections/abc.py)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/sphinx/config.py", line 361, in eval_config_file
    execfile_(filename, namespace)
  File "/usr/lib/python3.9/site-packages/sphinx/util/pycompat.py", line 81, in execfile_
    exec(code, _globals)
  File "/builddir/build/BUILD/Theano-rel-1.0.4/doc/conf.py", line 25, in <module>
    import theano
  File "/builddir/build/BUILD/Theano-rel-1.0.4/theano/__init__.py", line 88, in <module>
    from theano.configdefaults import config
  File "/builddir/build/BUILD/Theano-rel-1.0.4/theano/configdefaults.py", line 17, in <module>
    from theano.configparser import (AddConfigVar, BoolParam, ConfigParam, EnumStr,
  File "/builddir/build/BUILD/Theano-rel-1.0.4/theano/configparser.py", line 16, in <module>
    from theano.compat import configparser as ConfigParser
  File "/builddir/build/BUILD/Theano-rel-1.0.4/theano/compat/__init__.py", line 16, in <module>
    from collections import (OrderedDict, MutableMapping as DictMixin,
ImportError: cannot import name 'MutableMapping' from 'collections' (/usr/lib64/python3.9/collections/__init__.py)

@nouiz
Copy link
Member

nouiz commented Feb 4, 2020

A new PR is welcome.

@hroncok
Copy link
Contributor

hroncok commented Feb 4, 2020

#6741

twiecki pushed a commit to aesara-devs/aesara that referenced this pull request Apr 10, 2020
* Fix subtensor numpy warning

* Fix simple typo: varible->size -> variable->size

Closes #6734

* Counteract hypot redefinition for old Python versions

* fix doc warning

* Update extending_theano.txt

* OrderedDict cannot be imported from collections.abc, it is not abstract

See Theano/Theano#6664 (comment)

* Move more collections.abc imports to theano.compat

* Use math.gcd instead of fractions.gcd when possible

fractions.gcd() function has been removed from Python 3.9, it was
deprecated since Python 3.5.

https://docs.python.org/3.9/whatsnew/3.9.html#removed

* DOC: Allow building with Sphinx >= 2.0

* MAINT: Avoid SyntaxWarnings on import in Python 3.8

* flake8 code style fixes

* DOC: Retain compatibility with older Sphinx

* MAINT: Be compatible with numpy 1.17 and scipy 1.3

Fixes #6715.  Includes and supersedes #6721.

* flake8 code style fixes

* Remove doctest in python 3.4

* Do not install sphinx_rtd_theme for python 3.4 as the installation doesn't work anymore.

* fixing typo in GammaIncC Op

* re-add min > max clip test with fixed reference

* DOC: min > max clip may not match numpy

* updating travis build for Python 3

* order of stages

* conda activate

* installing conda properly

* conda install on travis

* conda activate issues on travis

* conda activate issues on travis

* doctest needs older version of numpy

* doctest

* reverting setup.cfg

* conda version conflicts

* need old sphinx version

* sphinx version

* don't bother building docs

* moved nosetester import

* also moving known failures plugin

Co-authored-by: Adrian Seyboldt <adrian.seyboldt@gmail.com>
Co-authored-by: Frédéric Bastien <frederic.bastien@gmail.com>
Co-authored-by: Tim Gates <tim.gates@iress.com>
Co-authored-by: Marcel Bargull <marcel.bargull@udo.edu>
Co-authored-by: Arnaud Bergeron <abergeron@gmail.com>
Co-authored-by: Miro Hrončok <miro@hroncok.cz>
Co-authored-by: Rebecca N. Palmer <rebecca_palmer@zoho.com>
Co-authored-by: Frederic Bastien <fbastien@nvidia.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants