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

func.func_name is not used in Python 3 #183

Closed
PolyachenkoYA opened this issue Jul 24, 2020 · 4 comments · Fixed by #184
Closed

func.func_name is not used in Python 3 #183

PolyachenkoYA opened this issue Jul 24, 2020 · 4 comments · Fixed by #184

Comments

@PolyachenkoYA
Copy link
Contributor

File fileformats/xvg.py has func_name which was replaced with func.__name__ in python 3.0.
I thought it would be safer to run 2to3 on all files so I ran
2to3 -w ./*
in ~/anaconda3/lib/python3.7/site-packages/gromacs and it failed with
ImportError: cannot import name 'namedtuple' from 'collections' (/home/ypolyach/anaconda3/lib/python3.7/site-packages/gromacs/collections.py). Turns out python has https://docs.python.org/3/library/collections.html so 2to3 fails to run in a directory which has a collections.py in it.
So, the problem: 2to3 must be run on some files in gromacs/* but it fails because of collections.py naming.

@orbeckst
Copy link
Member

Why do you need to run 2to3? GW runs in Python 3 as well as in 2. Or do you have a particular issue with Python 3, i.e., does XVG fail in some way? If so, raise an issue for that specific bug, please.

@PolyachenkoYA
Copy link
Contributor Author

PolyachenkoYA commented Jul 28, 2020 via email

@orbeckst
Copy link
Member

Ok: need to change

% (ny, maxpoints, maxpoints, func.func_name),
to

            try:
                funcname = func.func_name    # Python 2
            except AttributeError:
                funcname = func.__name__     # Python 3
            warnings.warn("Plot had %d datapoints > maxpoints = %d; decimated to %d regularly "
                          "spaced points from the histogrammed data with %s()."
                          % (ny, maxpoints, maxpoints, funcname),
                          category=AutoCorrectionWarning)

@orbeckst orbeckst changed the title usage of 2to3 func.func_name is not used in Python 3 Jul 28, 2020
@PolyachenkoYA
Copy link
Contributor Author

PolyachenkoYA commented Jul 28, 2020 via email

@orbeckst orbeckst linked a pull request Jul 29, 2020 that will close this issue
orbeckst pushed a commit that referenced this issue Jul 29, 2020
* fix #183 
* gromacs/fileformats/xvg.py: func_name support for python 3.0 added
* AUTHORS and CHANGES updated
orbeckst added a commit that referenced this issue Sep 3, 2020
- close #190 
- add @PolyachenkoYA to CHANGES
- add note for fix in PR #186 
- reference #183
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants