Skip to content

Fix numpy 2.4 scalar conversion error#157

Open
chemonke wants to merge 4 commits into
BioPandas:mainfrom
chemonke:numpy2_4_TypErrorFix
Open

Fix numpy 2.4 scalar conversion error#157
chemonke wants to merge 4 commits into
BioPandas:mainfrom
chemonke:numpy2_4_TypErrorFix

Conversation

@chemonke

Copy link
Copy Markdown

Code of Conduct

Description

See #156

Related issues or pull requests

Fixes #156 , test now passes.

Pull Request Checklist

  • Added a note about the modification or contribution to the ./docs/sources/CHANGELOG.md file (if applicable)
  • Added appropriate unit test functions in the ./biopandas/*/tests directories (if applicable)
  • Modify documentation in the corresponding Jupyter Notebook under biopandas/docs/sources/ (if applicable)
  • Ran PYTHONPATH='.' pytest ./biopandas -sv and make sure that all unit tests pass (for small modifications, it might be sufficient to only run the specific test file, e.g., PYTHONPATH='.' pytest ./biopandas/classifier/tests/test_stacking_cv_classifier.py -sv)
  • Checked for style issues by running flake8 ./biopandas

@a-r-j

a-r-j commented May 22, 2026

Copy link
Copy Markdown
Contributor

Hi @chemonke thanks for the contribution. Do you mind checking out the failing test?

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses NumPy 2.4+ compatibility issues in BioPandas structure parsing, primarily fixing an MMTF parsing failure caused by stricter scalar conversion rules, and improving amino3to1 residue boundary detection across PDB/MMTF/mmCIF.

Changes:

  • Fix NumPy 2.4+ TypeError in mmtf_to_df by extracting a scalar index from np.argwhere(...).
  • Make amino3to1 residue grouping more robust by including chain IDs and safely handling missing insertion codes.
  • Add a changelog entry describing the update (needs alignment with the PR’s actual fixes).

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
docs/CHANGELOG.md Adds a release note entry for the change (currently misaligned with the PR’s primary fix).
biopandas/pdb/pandas_pdb.py Updates amino3to1 residue boundary key to include chain_id and tolerate missing insertion codes.
biopandas/mmtf/pandas_mmtf.py Fixes NumPy 2.4 scalar conversion in mmtf_to_df; updates amino3to1 residue boundary key similarly.
biopandas/mmcif/pandas_mmcif.py Updates amino3to1 residue boundary key to include chain + insertion handling for mmCIF.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread docs/CHANGELOG.md
Comment thread docs/CHANGELOG.md
@chemonke

Copy link
Copy Markdown
Author

I'll have a look at it tomorrow when I'm home again.

@chemonke chemonke force-pushed the numpy2_4_TypErrorFix branch from 4e879a3 to 5cf868e Compare May 24, 2026 08:20
@chemonke

chemonke commented May 24, 2026

Copy link
Copy Markdown
Author

Full disclosure: my background is in chemistry, and I haven't finished my data science degree yet, so I'm basically a beginner.

I don't expect any problems from the indexing change in b4b69b1.

But the test__construct_df() series seems odd to me. Was it ever intended behavior to convert None to a str? What I did in 89e961f seems a bit hacky, maybe the test should be rewritten?

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.

test_rmsd.py fails with numpy 2.4 scalar conversion TypeError

3 participants