Summary
Several model/network block classes have near-duplicate __setattr__ implementations for updating named items and warning on invalid assignments. This came up while working on the now-closed PR #100 (block-setattr-logging-dedup). Rather than reviving that stale branch directly, this issue captures the underlying cleanup opportunity.
Suggested cleanup
- Deduplicate the repeated block
__setattr__ paths in bionetgen/modelapi/blocks.py and bionetgen/network/blocks.py behind a shared helper or similarly small abstraction.
- Preserve existing warning text/behavior for numeric assignment failures, especially parameter
value and compartment size warnings.
- Route remaining invalid-assignment warnings consistently through
BNGLogger rather than mixing logger calls and print(...).
- Add focused regression tests covering invalid assignments for model and network block subclasses.
Why
This is not an urgent bug fix, but it would reduce maintenance risk in fragile legacy block code. The main value is preventing future behavior drift when similar warning/update logic is changed in one block class but not another.
Notes
The stale branch/closed PR may still be useful as a reference, but the eventual fix should be based on current main rather than reopening that branch as-is.
Summary
Several model/network block classes have near-duplicate
__setattr__implementations for updating named items and warning on invalid assignments. This came up while working on the now-closed PR #100 (block-setattr-logging-dedup). Rather than reviving that stale branch directly, this issue captures the underlying cleanup opportunity.Suggested cleanup
__setattr__paths inbionetgen/modelapi/blocks.pyandbionetgen/network/blocks.pybehind a shared helper or similarly small abstraction.valueand compartmentsizewarnings.BNGLoggerrather than mixing logger calls andprint(...).Why
This is not an urgent bug fix, but it would reduce maintenance risk in fragile legacy block code. The main value is preventing future behavior drift when similar warning/update logic is changed in one block class but not another.
Notes
The stale branch/closed PR may still be useful as a reference, but the eventual fix should be based on current
mainrather than reopening that branch as-is.