mbuild
mbuild copied to clipboard
Add option to reset child labels in Compound.remove()
Two changes are made:
- Add keyword argument to Compound.remove() for resetting the labels to achieve two goals. First, if all children of some category are removed, the parent category label will inherently be removed, while the ports are also renumbered.
- In Compound.add() if a single Compound is added without a label, the Compound.name attribute is used instead of Compound.class.name to align with the default behavior in:
- lib/atoms/n4.py : line 14
- conversion.py : line 586, 700
- lib/recipes/tiled_compound.py : line 139
PR Summary:
Resolves #1172
Using the code in the issue where the last line is now, Molecule.remove(remove_array, reset_labels=True)
, the results are now:
Before ['C', 'C[0]', 'H', 'H[0]', 'H[1]', 'C[1]', 'H[2]', 'H[3]', 'O', 'O[0]', 'down', 'up']
After Flatten ['monomer', 'H', 'C', 'C[0]', 'H[2]', 'H[3]', 'C[1]', 'H[4]', 'H[5]', 'O', 'O[0]', 'H[6]', 'H[7]']
After Remove H ['C', 'C[0]', 'C[1]', 'O', 'O[0]', 'port', 'port[0]', 'port[1]', 'port[2]', 'port[3]', 'port[4]', 'port[5]']
After
PR Checklist
- [x] Includes appropriate unit test(s)
- [X] Appropriate docstring(s) are added/updated
- [X] Code is (approximately) PEP8 compliant
- [X] Issue(s) raised/addressed?
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 87.32%. Comparing base (
df74ac1
) to head (d9c2cfa
).
Additional details and impacted files
@@ Coverage Diff @@
## main #1173 +/- ##
==========================================
+ Coverage 87.28% 87.32% +0.04%
==========================================
Files 62 62
Lines 6502 6525 +23
==========================================
+ Hits 5675 5698 +23
Misses 827 827
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
We should potentially add in a future PR a deprecation warning for reset_index