Closed johhat closed 1 year ago
Describe the bug Optimizing a factor with an sf.Unit3 type as input in python yields an incompatible function arguments error.
To Reproduce See the error of the following example
import symforce symforce.set_epsilon_to_symbol("epsilon") import sym import numpy as np import symforce.symbolic as sf from symforce.opt.factor import Factor from symforce.opt.optimizer import Optimizer from symforce.values import Values def residual(unit3: sf.Unit3) -> sf.V3: return unit3.to_unit_vector() def main(): values = Values( { "unit3": sym.Unit3.from_vector(np.array([0, 0, 1]), sym.epsilon), } ) optimizer = Optimizer( factors=[ Factor( residual=residual, keys=["unit3"], ) ], optimized_keys=["unit3"], ) # Fails here result = optimizer.optimize(values) if __name__ == "__main__": main()
Expected behavior I'd expect the optimization to run without error.
Environment
Example dockerfile
FROM python:3.8.16 RUN pip3 install symforce COPY example.py /example.py CMD ["python", "example.py"]
Additional context Excerpt of the error message
TypeError: set(): incompatible function arguments. The following argument types are supported: 1. (self: cc_sym.Values, key: cc_sym.Key, value: float) -> bool 2. (self: cc_sym.Values, key: index_entry_t, value: float) -> None 3. (self: cc_sym.Values, key: cc_sym.Key, value: Rot2) -> bool ... Invoked with: <Valuesd entries=0 array=0 storage_dim=0 tangent_dim=0 >, x_0, <Unit3 [0.0, 0.0, 0.0, 1.0]>
Thanks for reporting, we forgot to add Unit3 to the Python wrappers when we added it - will have a fix shortly
Describe the bug Optimizing a factor with an sf.Unit3 type as input in python yields an incompatible function arguments error.
To Reproduce See the error of the following example
Expected behavior I'd expect the optimization to run without error.
Environment
Example dockerfile
Additional context Excerpt of the error message