Tags: imhutugui/symforce
Tags
[SymForce] Add symforce.set_epsilon_to_symbol It is moderately inconvenient to set epsilon to a symbol as is. This is because if one wants to set epsilont to a symbol, one might run ``` python import symforce.symbolic as sf import symforce symforce.set_epsilon(sf.Symbol("epsilon")) ``` The trouble with this, however, is that the file defining `Symbol` also defined `atan2`, `asin_safe`, and `acos_safe`, which themselves use the default epsilon. But since `symforce.set_epsilon` can only be called before the value of epsilon is used (a restriction we impose because default function arguments are bound at function definition time, not late bound), the above snippet produces an error. Now, we only import `symforce.symbolic` to have access to `Symbol`, and don't actually need those default epsilon using functions. A user could instead just import `sympy` or `symengine` directly, but that would be inconvenient and confusing (especially for such a common use case). So instead, I'm adding the function `symforce.set_epsilon_to_symbol` (along with `symforce.set_epsilon_to_number` and `symforce.set_epsilon_to_zero`). This function will handle the import of `Symbol` for the user, saving the user the trouble. The other `symforce.set_epsilon_to_XXX` functions aren't strictly necessary for anything, but in discussion with Aaron and Hayk, we thought this api seemed nicest. The default value for `symforce.set_epsilon_to_number` is supposed to be `sf.numeric_epsilon`, which posed a small problem (the same exact problem as `sf.Symbol`). To address this, I moved the definition of `numeric_epsilon` to `symforce/__init__.py`, then reexport it in `symforce.symbolic`. An alternative was to simply redefine `atan2`, `asin_safe`, and `acos_safe` whenever a new value of epsilon is set, allowing a user to set epsilon after importing `symforce.symbolic`, but in conversation it was deciding this was not something we wanted to allow. Topic: set_epsilon_to_symbol GitOrigin-RevId: 24d1a2389427316d21bd85322e43032ec7f7ae2e
[SymForce-External] Epsilon tutorial, rename ops tutorial Import of symforce-org#135 ORIGINAL_AUTHOR = Aaron Miller [email protected] - Epsilon tutorial, rename ops tutorial - More docs and tutorials updates - add intro to epsilon tutorial - Update optimization tutorial - Update README.md - Update wording on build in readme - Rename requirements.txt to dev_requirements.txt - Update theme settings - skymarshal updates - update sym packaging - Fix more stuff - Fix dev.rst, new badges + classifiers - Fix skymarshal setup.py - Data files, sym -> symforce-sym, scipy required - Fix tests, hopefully - Bump version to 0.4.0 - Fix tests