Fix COMPAS 1.x API calls that raise under COMPAS 2.x - #143
Conversation
key_index/index_vertex were renamed to vertex_index; edge_length and edge_coordinates now take a single edge tuple instead of two positional vertex keys. These broke the entire constraints/Newton/nullspace path (ConstraintsCollection.constraints_from_form, form_compute_nullspace, form_update_from_force_newton) under compas 2.15.1. Also: force_update_from_constraints() inside update_diagrams_from_constraints wasn't forwarding kmax, so it always solved with the default of 100 iterations regardless of the caller's setting. And export form_compute_nullspace/force_update_from_form_geometrical from compas_ags.ags, where they were missing. Added tests/test_ags_compas2_api.py to guard the fixed code paths. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Drops the graphstatics.py index_vertex() change: verified that the method does exist on Diagram and works, so the replacement was equivalent code resting on a wrong premise. Also removes a docstring reference to a file in a separate private repo, and narrows the changelog entry to the calls that actually raise. No functional change; matches BlockResearchGroup#143.
|
A bit of context I should have put up front, plus the template checklist I skipped by creating this through the CLI. Context. I'm an architect, not a structural engineer — I ran into these while building a Rhino plugin on top of The API fixes ( The Checklist
|
Under COMPAS 2.x (tested with 2.15.1), the constraints / Newton / nullspace code paths in
compas_ags.agsraise immediately, because a few call sites still use the pre-2.x API.Reproduce
With COMPAS 2.15.1 and current
main:form_compute_nullspace()andform_update_from_force_newton()fail the same way.scripts/example_nullspace.pyandscripts/example_fix_x.pycannot run onmainas a result.Changes
ags/core.py—force.key_index()andform.key_index()becomevertex_index().key_index()no longer exists in COMPAS 2.x, socompute_jacobian()andget_jacobian_and_residual()raiseAttributeError.ags/constraints.py—edge_length(*self.edge)andedge_coordinates(*self.edge)now pass the edge tuple as a single argument, which is the COMPAS 2.x signature. This is what breaksLengthFix, and thereforeconstraints_from_form().ags/graphstatics.py—update_diagrams_from_constraints()takes akmaxparameter but did not forward it to itsforce_update_from_constraints()call, so that step always ran with the default of 100 parallelisation iterations no matter what the caller asked for. Measured withmax_iter=20, kmax=20on the paper diagrams:gs_form_force(7v/7e)exD_truss(17v/21e)exE_truss_dense(32v/41e)ags/__init__.py— exportform_compute_nullspaceandforce_update_from_form_geometrical. Both are defined ingraphstatics.pybut were not re-exported;scripts/example_nullspace.pyimports the former fromcompas_ags.agsand fails on import.Test
tests/test_ags_compas2_api.pycovers the three affected entry points. All three fail onmain(TypeError/AttributeError) and pass with this change.The fixtures use
paper/gs_form_force.objrather thanpaper/gs_arch.json, because the latter is a COMPAS 0.17.2-era serialization thatFormGraph.from_jsoncan no longer reconstruct under COMPAS 2.x. That looked like a separate issue, so I left it alone here.