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

[BUG] secondary_structure_percentage doctest raises pandas-related AttributeError #123

Open
FloLangenfeld opened this issue Aug 12, 2020 · 2 comments · May be fixed by #124
Open

[BUG] secondary_structure_percentage doctest raises pandas-related AttributeError #123

FloLangenfeld opened this issue Aug 12, 2020 · 2 comments · May be fixed by #124

Comments

@FloLangenfeld
Copy link

I just launch the doctest code written in the rstoolbox.analysis.secondary_structure_percentage function docstring:

from rstoolbox.io import parse_rosetta_file
from rstoolbox.analysis import secondary_structure_percentage
import pandas as pd
pd.set_option('display.width', 1000)
pd.set_option('display.max_columns', 500)
df = parse_rosetta_file("../rstoolbox/tests/data/input_ssebig.minisilent.gz",
                        {'scores': ['score'], 'structure': 'C'})
df = secondary_structure_percentage(df, 'C')
df.head()

It raises the following error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/florent/anaconda3/envs/rstoolbox/lib/python3.8/site-packages/rstoolbox/analysis/structure.py", line 240, in secondary_structure_percentage
    df2 = df.apply(lambda row: secondary_structure_percentage(row,
  File "/home/florent/anaconda3/envs/rstoolbox/lib/python3.8/site-packages/pandas/core/frame.py", line 7541, in apply
    return op.get_result()
  File "/home/florent/anaconda3/envs/rstoolbox/lib/python3.8/site-packages/pandas/core/apply.py", line 180, in get_result
    return self.apply_standard()
  File "/home/florent/anaconda3/envs/rstoolbox/lib/python3.8/site-packages/pandas/core/apply.py", line 255, in apply_standard
    results, res_index = self.apply_series_generator()
  File "/home/florent/anaconda3/envs/rstoolbox/lib/python3.8/site-packages/pandas/core/apply.py", line 284, in apply_series_generator
    results[i] = self.f(v)
  File "/home/florent/anaconda3/envs/rstoolbox/lib/python3.8/site-packages/rstoolbox/analysis/structure.py", line 240, in <lambda>
    df2 = df.apply(lambda row: secondary_structure_percentage(row,
  File "/home/florent/anaconda3/envs/rstoolbox/lib/python3.8/site-packages/rstoolbox/analysis/structure.py", line 253, in secondary_structure_percentage
    dfp = df.append(pd.Series([float(csse['H']) / len(sse), float(csse['E']) / len(sse),
  File "/home/florent/anaconda3/envs/rstoolbox/lib/python3.8/site-packages/pandas/core/series.py", line 2688, in append
    return concat(
  File "/home/florent/anaconda3/envs/rstoolbox/lib/python3.8/site-packages/pandas/core/reshape/concat.py", line 274, in concat
    op = _Concatenator(
  File "/home/florent/anaconda3/envs/rstoolbox/lib/python3.8/site-packages/pandas/core/reshape/concat.py", line 395, in __init__
    axis = sample._constructor_expanddim._get_axis_number(axis)
AttributeError: 'function' object has no attribute '_get_axis_number'

I did a quick test with pandas 0.24.1 and it worked fine, so my best guess is that there was a change in the _Concatenator class for the pandas v1 major update.

I kind of solved that issue with a quick and dirty hack in rstoolbox.analysis.structure.py (just tested in my pandas 1.1.0 python environment). So if your interested, just let me know and I'll submit a PR.

>>> rstoolbox.show_versions():
yaml: 5.3.1
pandas: 1.1.0
seaborn: 0.10.1
libconfig: 0.9.2
six: 1.15.0
networkx: 2.4
>>> rstoolbox.__version__
'1.0.1'
@jaumebonet
Copy link
Owner

Hi @FloLangenfeld !
Thanks for your interest!
This comes, of course, from the bigger issue, which is the general integration of pandas 1 into the code 😕

I also need to fix the CI with travis, as it has changed a bit since last time I checked this code, but if you open the PR I'll be happy to merge it as soon as I can.

@FloLangenfeld FloLangenfeld linked a pull request Aug 12, 2020 that will close this issue
1 task
@FloLangenfeld
Copy link
Author

@jaumebonet
I've opened the PR with the small trick here : #124

And yeah, pandas 1 was a game-changer in so many ways that one may ask why not just add pandas<1.0.0 in the requirements 😆

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 a pull request may close this issue.

2 participants