Skip to content

Bug in bitclust #5

@mverissi

Description

@mverissi

Dear BitClust developers,

I installed BitClust through pip recently in my computer in a miniconda environment. I'm running python 3.10 and have matplotlib 3.9.2 py310h06a4308_1, matplotlib-base 3.9.2 py310hbfdbfaf_1, matplotlib-inline 0.1.6 py310h06a4308_0, numpy 1.26.4 py310heeff2f4_0 and numpy-base 1.26.4 py310h8a23956_0.

I tried running BitClust (installed through pip), but I got some errors:

`/home/mverissi/miniconda3/envs/protprep/lib/python3.10/site-packages/bitclust/main.py:402: FutureWarning: ChainedAssignmentError: behaviour will change in pandas 3.0!
You are setting values through chained assignment. Currently this works in certain cases, but when using Copy-on-Write (which will become the default behaviour in pandas 3.0) this will never work to update the original DataFrame or Series, because the intermediate object on which we are setting values will behave as a copy.
A typical example is when you are setting values in a column of a DataFrame, like:

df["col"][row_indexer] = value

Use df.loc[row_indexer, "col"] = values instead, to perform the assignment in a single step and ensure this keeps updating the original df.

See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy

clusters_stats.leader[:-1] = np.asarray(trajectory_idx)[clusters_stats.leader[:-1]]
/home/mverissi/miniconda3/envs/protprep/lib/python3.10/site-packages/bitclust/main.py:402: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame

See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
clusters_stats.leader[:-1] = np.asarray(trajectory_idx)[clusters_stats.leader[:-1]]
Traceback (most recent call last):
File "/home/mverissi/miniconda3/envs/protprep/bin/bitclust", line 8, in
sys.exit(main())
File "/home/mverissi/miniconda3/envs/protprep/lib/python3.10/site-packages/bitclust/main.py", line 421, in main
plt.savefig('rmsd_all_vs_reference', dpi=300,
File "/home/mverissi/miniconda3/envs/protprep/lib/python3.10/site-packages/matplotlib/pyplot.py", line 1228, in savefig
res = fig.savefig(*args, **kwargs) # type: ignore[func-returns-value]
File "/home/mverissi/miniconda3/envs/protprep/lib/python3.10/site-packages/matplotlib/figure.py", line 3395, in savefig
self.canvas.print_figure(fname, **kwargs)
File "/home/mverissi/miniconda3/envs/protprep/lib/python3.10/site-packages/matplotlib/backends/backend_qtagg.py", line 75, in print_figure
super().print_figure(*args, **kwargs)
File "/home/mverissi/miniconda3/envs/protprep/lib/python3.10/site-packages/matplotlib/backend_bases.py", line 2204, in print_figure
result = print_method(
File "/home/mverissi/miniconda3/envs/protprep/lib/python3.10/site-packages/matplotlib/backend_bases.py", line 2054, in
print_method = functools.wraps(meth)(lambda *args, **kwargs: meth(
TypeError: FigureCanvasAgg.print_png() got an unexpected keyword argument 'alpha'`

Since I'm not proficient in Pandas, ChatGPT suggested me the following corrections:

  1. Replace clusters_stats.leader[:-1] = np.asarray(trajectory_idx)[clusters_stats.leader[:-1]] by clusters_stats.loc[clusters_stats.index[:-1], 'leader'] = np.asarray(trajectory_idx)[clusters_stats.loc[clusters_stats.index[:-1], 'leader']] and clusters_stats.leader = np.asarray(trajectory_idx)[clusters_stats.leader] by clusters_stats.loc[:, 'leader'] = np.asarray(trajectory_idx)[clusters_stats.loc[:, 'leader']];
  2. Replace plt.savefig('rmsd_all_vs_reference', dpi=300, alpha=0.85) by plt.savefig('rmsd_all_vs_reference', dpi=300).

The code now terminates smoothly, but I'd like to ensure that the results are correct. Could you please check this?

Best,

Marcos

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions