8000 Preserve model objects when renamed keys overlap existing names by Tonylo-lab · Pull Request #372 · JWock82/Pynite · GitHub
[go: up one dir, main page]

Skip to content

Preserve model objects when renamed keys overlap existing names - #372

Open
Tonylo-lab wants to merge 1 commit into
JWock82:mainfrom
Tonylo-lab:fix/rename-object-name-collisions
Open

Tonylo-lab wants to merge 1 commit into
JWock82:mainfrom
Tonylo-lab:fix/rename-object-name-collisions

Conversation

@Tonylo-lab
Copy link
Copy Markdown

FEModel3D.rename() can overwrite an object whose old name matches another object's new name. Creating N2 before N1 and calling rename() leaves only one node; elements still reference the missing node, and a two-node spring model subsequently raises TypeError during analysis. The same collision affects springs, members, plates and quads.

Clear each dictionary after taking its existing snapshot, then populate the numbered keys from that snapshot. This preserves the objects, dictionary identity and insertion order. Apply the same two-line change in all five existing rename loops and add one explanatory comment. Add six focused cases in Testing/test_rename.py (the five object dictionaries, with a repeated-rename control, plus an actual spring analysis) and one short changelog entry.

The spring check uses F=10 and k=100: after renaming, displacement is F/k=0.1 and the fixed reaction is -10.

Validation on Windows / Python 3.12.15, based on fdf3e12b:

  • New tests on unmodified production code: 6 failed.
  • pytest Testing/test_rename.py Testing/test_node_spring_coverage.py Testing/test_node_merge.py Testing/test_springs.py Testing/test_reactions.py Testing/test_2D_frames.py -q: 38 passed, 8 subtests passed.
  • Ruff 0.14.9 on the changed Python files and git diff --check: passed.

Not run: the full test suite, graphical visualization validation, or other platforms/Python versions.

AI assistance: OpenAI Codex assisted with investigation, the patch and regression tests. The concrete diff and validation results were presented for approval before submission.

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.

1 participant

0