Repository navigation
fix(core): add data type validation when setting topology attributes … - #5513
dhrubchatterjee16-lang wants to merge 4 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #5513 +/- ##
===========================================
+ Coverage 93.91% 93.93% +0.01%
===========================================
Files 184 184
Lines 22644 22696 +52
Branches 3219 3237 +18
===========================================
+ Hits 21267 21319 +52
Misses 917 917
Partials 460 460 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
BradyAJohnston
left a comment
There was a problem hiding this comment.
I'm blocking this as we currently don't accept AI contributions due to our AI policy. This will likely be changing in the near future. If you do want to continue with it, you'll need to address the coverage and linting issues before we review it then.
Documentation build overview
|
|
Hi @BradyAJohnston, Thanks for the head-up. I'd definitely like to continue with this and see it through. I've fixed the formatting with black (set to 79 chars) and added tests for boolean attributes and numpy arrays to cover all the branches. The linter and type checks are passing now. Please let me know if anything else needs to be adjusted. Thanks! |
Fixes #2764
Changes made in this Pull Request:
MDAnalysis.core.topologyattrs._check_dtypeinvoked by the setter decorator to ensure assigned values match the attribute's expected data type.AtomStringAttr,ResidueStringAttr,SegmentStringAttr) now reject non-string inputs with a clearTypeError(e.g.atom.name = 1raisesTypeError: name must be a stringrather than'int' object is not iterable, and group assignments likeatoms.names = [1, 2]raiseTypeError: All values for names must be strings).Resids,Atomids,Resnums, etc.) reject floats and booleans with aTypeErrorrather than silently truncating or coercing them.Masses,Charges, etc.) reject booleans and non-numeric types while allowing valid integers/floats.TestDtypeChecksinMDAnalysisTests.core.test_topologyattrs.package/CHANGELOGandpackage/AUTHORS.LLM / AI generated code disclosure
LLMs or other AI-powered tools (beyond simple IDE use cases) were used in this contribution: yes
Details of AI usage:
topologyattrs.py, designing the_check_dtypehelper with O(1) NumPy subdtype checks, and designing edge-case unit tests.PR Checklist
package/CHANGELOGfile updated?package/AUTHORS? (If it is not, add it!)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.