facebookresearch / theseus

A library for differentiable nonlinear optimization
MIT License
1.74k stars 124 forks source link

Modify Objective::_erase_function_variables(...) to also delete varia… #612

Closed Hesam-Vayu closed 11 months ago

Hesam-Vayu commented 11 months ago

…ble name from _all_variables.

Not deleting a variable name in _all_variables that is no longer used causes crashes when you try to add a CostFunction that includes the variable name again.

Motivation and Context

If you delete enough CostFunctions where the underlying variables are deleted and then add another CostFunction that uses the same variable, the following check passes, causing this statement to crash due to this statement not being executed.

How Has This Been Tested

Ran tests and optimizations in own code.

Types of changes

Checklist

facebook-github-bot commented 11 months ago

Hi @Hesam-Vayu!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

facebook-github-bot commented 11 months ago

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

mhmukadam commented 11 months ago

Thanks for catching this and the fix. Might be good to update the unit test so this delete behavior also gets checked.

Hesam-Vayu commented 11 months ago

Done, I added the test.

Hesam-Vayu commented 11 months ago

My pleasure :)