Skip to content

Conversation

erikagnvall
Copy link
Contributor

@erikagnvall erikagnvall commented Aug 16, 2019

This PR fixes a DeprecationWarning issued when running under Python 3 because SymEngine uses abstract base classes imported directly from collections instead of collections.abc. The abstract base classes were moved in 3.3 and the old way of importing them directly from collections will stop working in 3.8.

Running the following prints the DeprecationWarning when importing SymEngine:

$ python -Wall
Python 3.7.0 (default, Oct 22 2018, 09:00:22)
[Clang 9.0.0 (clang-900.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import symengine
/Users/erik/[...]/python3.7/site-packages/symengine/__init__.py:1: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working                                                                  
  from .lib.symengine_wrapper import (

(See also Python's documentation for the official deprecation note.)

Importing the abstract base classes directly from the collections module
is deprecated in Python 3.7. They have been moved to collections.abc and
the deprecated way will stop working in Python 3.8.

See: https://docs.python.org/3/library/collections.html
@certik
Copy link
Contributor

certik commented Aug 16, 2019

Thanks @meldanya for fixing it! Please ping me once tests pass, so that I can merge it.

@isuruf
Copy link
Member

isuruf commented Aug 16, 2019

Is it possible to run pytest with -Wall so that we catch these early?

@erikagnvall
Copy link
Contributor Author

@certik Tests have passed!

@isuruf pytest actually displays DeprecationWarnings, that's how I found the warning from one of our projects at work. I'm not super familiar with how you run the tests in CI but I think the problem is that the DeprecationWarning is issued only at import time of symengine in bin/test_python.py. Once pytest starts running the tests and captures the warnings, the DeprecationWarning has already been issued and ignored.

I think you can work around it by running python -Wall bin/test_python.py When launching the tests in CI.

@isuruf isuruf merged commit b53d68b into symengine:master Aug 16, 2019
@isuruf
Copy link
Member

isuruf commented Aug 16, 2019

Thanks.

@certik
Copy link
Contributor

certik commented Aug 16, 2019

@meldanya thanks. Just curious: what do you use symengine for?

@erikagnvall
Copy link
Contributor Author

@certik Some of my colleagues could probably give a better answer but I'll give it a shot:

We use symengine for modelling the dynamics of industrial robots (e.g. rigid body dynamics, friction, etc) and from measurement data identifying the model's parameters. The end goal being to combine that with compensation for kinematic errors and link/joint deflections to produce more accurate robots.

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.

3 participants