Skip to content

tests: replaced deprecated assert_almost_equal in GNM analysis test ref #3743#5329

Open
MegaCoderNerd wants to merge 2 commits intoMDAnalysis:developfrom
MegaCoderNerd:gnm-assert-clean
Open

tests: replaced deprecated assert_almost_equal in GNM analysis test ref #3743#5329
MegaCoderNerd wants to merge 2 commits intoMDAnalysis:developfrom
MegaCoderNerd:gnm-assert-clean

Conversation

@MegaCoderNerd
Copy link

@MegaCoderNerd MegaCoderNerd commented Mar 22, 2026

Fixes #

Changes made in this Pull Request:

  • Replaced deprecated NumPy test helper calls in testsuite/MDAnalysisTests/analysis/test_gnm.py by switching from assert_almost_equal to assert_allclose.
  • Removed the deprecated import and kept a single assert_allclose import in testsuite/MDAnalysisTests/analysis/test_gnm.py.
  • Preserved the previous assertion intent by using explicit tolerances:
    previous decimal=4 checks now use rtol=0 and atol=1e-4
    previous default precision checks now use rtol=0 and atol=1e-7
  • No production code changes; test-only maintenance update.

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!)
  • LLM/AI disclosure was updated.
    No changelog/docs update needed; this is a test-only maintenance change.

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.


📚 Documentation preview 📚: https://mdanalysis--5329.org.readthedocs.build/en/5329/

Copilot AI review requested due to automatic review settings March 22, 2026 14:28
Copy link

Copilot AI left a comment

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 updates the GNM analysis test suite to remove usage of NumPy’s deprecated assert_almost_equal, standardizing on assert_allclose with explicit tolerances, and records the contributor in AUTHORS.

Changes:

  • Replaced assert_almost_equal assertions with assert_allclose in testsuite/MDAnalysisTests/analysis/test_gnm.py, adding explicit rtol/atol where needed.
  • Removed the deprecated assert_almost_equal import and kept a single assert_allclose import.
  • Added the contributor name to package/AUTHORS.

Reviewed changes

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

File Description
testsuite/MDAnalysisTests/analysis/test_gnm.py Migrates deprecated NumPy test assertions to assert_allclose with explicit tolerances.
package/AUTHORS Adds contributor to the chronological authors list.

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

0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
-2.263157894736841, -0.24333213169614382
]
],
Copy link

Copilot AI Mar 22, 2026

Choose a reason for hiding this comment

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

There is trailing whitespace after the closing bracket on this line. This can trigger lint failures (e.g., W291) and should be removed.

Suggested change
],
],

Copilot uses AI. Check for mistakes.
gnm.results.eigenvalues,
[3.57984776e-16, 3.53892581e-16],
rtol=0,
atol=1e-7
Copy link

Copilot AI Mar 22, 2026

Choose a reason for hiding this comment

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

This multi-line call is missing a trailing comma after the last keyword argument. In this repo, files using # fmt: off/on are typically autoformatted; adding the trailing comma will keep formatting consistent and avoids formatter churn.

Suggested change
atol=1e-7
atol=1e-7,

Copilot uses AI. Check for mistakes.
import numpy as np
import pytest
from numpy.testing import assert_almost_equal
from numpy.testing import assert_allclose
Copy link

Copilot AI Mar 22, 2026

Choose a reason for hiding this comment

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

PR description still contains the placeholder Fixes # without an issue number. Please either link the intended issue (the title mentions ref #3743) or remove the Fixes # line to avoid confusion/auto-closing the wrong issue.

Copilot uses AI. Check for mistakes.
@codecov
Copy link

codecov bot commented Mar 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.83%. Comparing base (c32fe45) to head (2dada97).

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #5329      +/-   ##
===========================================
- Coverage    93.84%   93.83%   -0.01%     
===========================================
  Files          182      182              
  Lines        22492    22492              
  Branches      3199     3199              
===========================================
- Hits         21107    21106       -1     
- Misses         923      924       +1     
  Partials       462      462              

☔ View full report in Codecov by Sentry.
📢 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.

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.

2 participants