Commit 8c4cf7e
committed
Accept list vec args in genned code by default
By default, I mean if `use_numba=False` and `reshape_vecs=True`.
Previously, only ndarrays could be passed as vector args to generated
code. However, lists in python are ubiquitous and natural, so it would
be good for our generated functions to accept them.
So, this commit allows generated functions to accept lists for matrix
arguments when the argument is either a row vector or a column vector.
Nested lists are not accepted to represent matrices because I simply did
not consider that until right now. (Perhaps we should add that?)
`PythonConfig.use_numba` must be `False` because list arguments have
been deprecated in numba (instead you should use `numba.typed.List`, but
if you have to use that you might as well use `numpy.ndarray` as far as
I can tell).
`PythonConfig.reshape_vecs` must be `True` because accepting lists
requires conversion to an ndarray and reshaping, which is presumably
more or less the entire thing meant to be avoided by setting
`reshape_vecs` to `False`.
This change did involve mucking up a bit the python `util.jinja` type
printing macros, as a `sf.Matrix` type should be rendered as an
`numpy.ndarray` is it is a return type, `reshape_vectors=False`,
`use_numba=True`, or is not a row or column vector, and rendered as
`T.Union[T.Sequence[float], numpy.ndarray]` otherwise.1 parent ab2c850 commit 8c4cf7e
File tree
30 files changed
+459
-123
lines changed- gen/python/sym
- ops
- atan_camera_cal
- double_sphere_camera_cal
- equirectangular_camera_cal
- linear_camera_cal
- polynomial_camera_cal
- pose2
- pose3
- rot2
- rot3
- spherical_camera_cal
- symforce/codegen/backends/python/templates/util
- test
- symforce_function_codegen_test_data
- symengine
- sympy
30 files changed
+459
-123
lines changedSome generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 32 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments