Skip to content

Fix #3500: preserve input floating-point precision in check_box and t… - #5499

Open
dhrubchatterjee16-lang wants to merge 1 commit into
MDAnalysis:developfrom
dhrubchatterjee16-lang:fix-box-dtype-3500
Open

dhrubchatterjee16-lang wants to merge 1 commit into
MDAnalysis:developfrom
dhrubchatterjee16-lang:fix-box-dtype-3500

Conversation

@dhrubchatterjee16-lang

@dhrubchatterjee16-lang dhrubchatterjee16-lang commented Oct 19, 2026 •

Copy link
Copy Markdown

Fixes #3500

Changes made in this Pull Request:

  • Added an optional dtype keyword argument to MDAnalysis.lib.mdamath.check_box (defaults to None which preserves the input box's dtype).
  • Updated MDAnalysis.lib.mdamath.triclinic_vectors to accept dtype=None and preserve the input box dtype when converting to box vectors.
  • Added unit tests in MDAnalysisTests.lib.test_mdamath testing float32, float64, and custom dtype preservation.
  • Updated package/CHANGELOG and package/AUTHORS.

LLM / AI generated code disclosure

LLMs or other AI-powered tools (beyond simple IDE use cases) were used in this contribution: yes

PR Checklist

  • Issue raised/referenced?
  • Tests updated/added?
  • Documentation updated/added?
  • package/CHANGELOG file updated?
  • Is your name in package/AUTHORS? (If it is not, add it!)
  • I have read and understand the current AI Policy
  • LLM/AI disclosure was updated.

Developers Certificate of Origin

I certify that I can submit this code contribution as described in the Developer Certificate of Origin, under the MDAnalysis LICENSE.

@read-the-docs-community

read-the-docs-community Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Documentation build overview

📚 MDAnalysis | 🛠️ Build #35259643 | 📁 Comparing 6a90c4b against latest (6cd1f7e)

  🔍 Preview build  

4 files changed
± index.html
± documentation_pages/analysis/wbridge_analysis.html
± documentation_pages/lib/util.html
± _modules/MDAnalysis/lib/util.html

@codecov

codecov Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.91%. Comparing base (6cd1f7e) to head (6a90c4b).

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #5499   +/-   ##
========================================
  Coverage    93.91%   93.91%           
========================================
  Files          184      184           
  Lines        22644    22644           
  Branches      3219     3219           
========================================
  Hits         21267    21267           
  Misses         917      917           
  Partials       460      460           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@IAlibay IAlibay left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please fill in the AI disclosure that is in the PR template.

@dhrubchatterjee16-lang

Copy link
Copy Markdown
Author

Hi @IAlibay , thank you for pointing that out! I have updated the PR description to include the full PR template along with the checklist and AI disclosure. Apologies for omitting the template initially!

@IAlibay

IAlibay commented Oct 20, 2026

Copy link
Copy Markdown
Member

Hi @IAlibay , thank you for pointing that out! I have updated the PR description to include the full PR template along with the checklist and AI disclosure. Apologies for omitting the template initially!

Thank you. Since you replied "yes" to the AI usage, can you please provide details about how you used AI tools for this PR?

@dhrubchatterjee16-lang

Copy link
Copy Markdown
Author

Hi @IAlibay,

Thank you for following up!

I used an AI assistant as an interactive pair-programming and debugging aid for this contribution. Specifically:

  • Investigating & Tracing: To trace how check_box and triclinic_vectors interact across the library, and to help debug test failures when running the test suite.
  • Designing the fix: To discuss the cleanest API design for Issue check_box and triclinic_vectors don't respect dtype #3500 — specifically keeping dtype=None as the default so that the input box's existing dtype is preserved by default (preventing unintended type upcasting/downcasting) while still allowing users to pass an explicit dtype when desired.
  • Test coverage: To help identify appropriate test cases verifying that float32, float64, and custom dtypes are preserved correctly without breaking existing box validation.

The code changes themselves are minimal and targeted (adding the optional dtype=None parameter and forwarding it), and I have thoroughly reviewed every line, run the unit tests locally and on CI, and take full responsibility for the code and design decisions in this PR.

Please let me know if you would like me to adjust anything!

This branch has not been deployed

No deployments
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.

check_box and triclinic_vectors don't respect dtype

2 participants