diff --git a/Makefile b/Makefile index f5d757ae7..65df7ca56 100644 --- a/Makefile +++ b/Makefile @@ -25,22 +25,18 @@ FIND_CPP_FILES_TO_FORMAT=find . \ -and -not -path "./symforce/benchmarks/matrix_multiplication/gen/*" \ -regextype posix-extended -regex ".*\.(h|cc|tcc)" -# Format using black, isort, and clang-format -BLACK_CMD=$(PYTHON) -m black . --exclude "third_party/.*|build/.*|\.eggs/.*" -ISORT_CMD=$(PYTHON) -m isort \ - --skip-glob="**/third_party" \ - --extend-skip-glob="**/build" \ - --extend-skip-glob="**/.eggs" \ - . +# Format using ruff and clang-format +RUFF_FORMAT_CMD=ruff format . +RUFF_ISORT_CMD=ruff check . --select=I format: - $(BLACK_CMD) - $(ISORT_CMD) + $(RUFF_FORMAT_CMD) + $(RUFF_ISORT_CMD) --fix $(FIND_CPP_FILES_TO_FORMAT) | xargs $(CPP_FORMAT) -i -# Check formatting using black and clang-format - print diff, do not modify files +# Check formatting using ruff and clang-format - print diff, do not modify files check_format: - $(BLACK_CMD) --check --diff - $(ISORT_CMD) --check --diff + $(RUFF_FORMAT_CMD) --check --diff + $(RUFF_ISORT_CMD) --diff $(FIND_CPP_FILES_TO_FORMAT) | xargs $(CPP_FORMAT) --dry-run -Werror # Check type hints using mypy diff --git a/dev_requirements.txt b/dev_requirements.txt index 27dea5e6e..358d007b6 100644 --- a/dev_requirements.txt +++ b/dev_requirements.txt @@ -31,8 +31,6 @@ beautifulsoup4==4.12.2 # via # furo # nbconvert -black[jupyter]==21.12b0 - # via symforce (setup.py) bleach==6.1.0 # via nbconvert breathe==4.35.0 @@ -46,10 +44,7 @@ charset-normalizer==3.3.0 clang-format==17.0.2 # via symforce (setup.py) click==8.0.4 - # via - # black - # pip-tools - # symforce (setup.py) + # via pip-tools cmake==3.26.4 # via symforce (setup.py) comm==0.1.4 @@ -105,15 +100,11 @@ importlib-resources==6.1.0 ipykernel==6.25.2 # via symforce (setup.py) ipython==8.12.3 - # via - # black - # ipykernel + # via ipykernel ipython-genutils==0.2.0 # via symforce (setup.py) isort==5.12.0 - # via - # pylint - # symforce (setup.py) + # via pylint jedi==0.19.1 # via ipython jinja2==3.0.3 @@ -176,9 +167,7 @@ mpmath==1.3.0 mypy==0.910 # via symforce (setup.py) mypy-extensions==0.4.4 - # via - # black - # mypy + # via mypy myst-parser==2.0.0 # via symforce (setup.py) nbclient==0.8.0 @@ -223,8 +212,6 @@ pandocfilters==1.5.0 # via nbconvert parso==0.8.3 # via jedi -pathspec==0.11.2 - # via black pexpect==4.8.0 # via ipython pickleshare==0.7.5 @@ -237,7 +224,6 @@ pkgutil-resolve-name==1.3.10 # via jsonschema platformdirs==3.11.0 # via - # black # jupyter-core # pylint plotly==5.17.0 @@ -291,6 +277,8 @@ rpds-py==0.10.4 # via # jsonschema # referencing +ruff==0.1.7 + # via symforce (setup.py) scipy==1.10.1 # via symforce (setup.py) six==1.16.0 @@ -343,13 +331,10 @@ tenacity==8.2.3 # via plotly tinycss2==1.2.1 # via nbconvert -tokenize-rt==5.2.0 - # via black toml==0.10.2 # via mypy tomli==1.2.3 # via - # black # build # pylint # pyproject-hooks @@ -388,7 +373,6 @@ types-setuptools==68.2.0.0 typing-extensions==4.8.0 # via # astroid - # black # ipython # mypy # pylint diff --git a/docs/development.rst b/docs/development.rst index d25a98c74..08545b594 100644 --- a/docs/development.rst +++ b/docs/development.rst @@ -77,11 +77,9 @@ When debugging a specific test, the use of `ipdb `_ formatter for Python code. To quote the authors: +Symforce uses the `Ruff `_ formatter for Python code. - `Black is the uncompromising Python code formatter. By using it, you agree to cede control over minutiae of hand-formatting. In return, Black gives you speed, determinism, and freedom from nagging about formatting. You will save time and mental energy for more important matters.` - -Running ``make format`` will format the entire codebase. It's recommended to develop with `VSCode `_ and integrate black. +Running ``make format`` will format the entire codebase. It's recommended to develop with `VSCode `_ and integrate black or ruff. ************************************************* Templates diff --git a/gen/python/sym/ops/__init__.py b/gen/python/sym/ops/__init__.py index 74700b501..4fa936fcc 100644 --- a/gen/python/sym/ops/__init__.py +++ b/gen/python/sym/ops/__init__.py @@ -3,3 +3,4 @@ # ops/__init__.py.jinja # Do NOT modify by hand. # ----------------------------------------------------------------------------- + diff --git a/gen/python/sym/ops/atan_camera_cal/camera_ops.py b/gen/python/sym/ops/atan_camera_cal/camera_ops.py index 0febe9e99..59f57fe2f 100644 --- a/gen/python/sym/ops/atan_camera_cal/camera_ops.py +++ b/gen/python/sym/ops/atan_camera_cal/camera_ops.py @@ -145,7 +145,7 @@ def pixel_from_camera_point_with_jacobians(self, point, epsilon): _tmp21 = _self[0] * point[0, 0] _tmp22 = _tmp10 * _tmp21 _tmp23 = _tmp12 * _tmp19 / _self[4] ** 2 - _tmp24 = _tmp18 ** 2 + _tmp24 = _tmp18**2 _tmp25 = 4 * _tmp6 _tmp26 = 1.0 * (_tmp24 + 1) / (_tmp24 * _tmp25 + 1) _tmp27 = _tmp13 * _tmp21 @@ -155,7 +155,7 @@ def pixel_from_camera_point_with_jacobians(self, point, epsilon): _tmp31 = _self[0] * _tmp5 _tmp32 = _tmp3 ** (-3) _tmp33 = _tmp11 * _tmp32 - _tmp34 = _tmp1 / (_tmp6 * (_tmp1 ** 2 * _tmp25 + 1)) + _tmp34 = _tmp1 / (_tmp6 * (_tmp1**2 * _tmp25 + 1)) _tmp35 = 2 * _tmp33 * _tmp34 _tmp36 = _tmp9 / _tmp6 ** (3.0 / 2.0) _tmp37 = _tmp33 * _tmp36 @@ -222,7 +222,7 @@ def camera_ray_from_pixel(self, pixel, epsilon): # Intermediate terms (5) _tmp0 = -_self[2] + pixel[0, 0] _tmp1 = -_self[3] + pixel[1, 0] - _tmp2 = math.sqrt(epsilon + _tmp1 ** 2 / _self[1] ** 2 + _tmp0 ** 2 / _self[0] ** 2) + _tmp2 = math.sqrt(epsilon + _tmp1**2 / _self[1] ** 2 + _tmp0**2 / _self[0] ** 2) _tmp3 = _self[4] * _tmp2 _tmp4 = (1.0 / 2.0) * math.tan(_tmp3) / (_tmp2 * math.tan(0.5 * _self[4])) @@ -270,9 +270,9 @@ def camera_ray_from_pixel_with_jacobians(self, pixel, epsilon): # Intermediate terms (54) _tmp0 = -_self[2] + pixel[0, 0] _tmp1 = -_self[3] + pixel[1, 0] - _tmp2 = _tmp1 ** 2 + _tmp2 = _tmp1**2 _tmp3 = _self[1] ** (-2) - _tmp4 = _tmp0 ** 2 + _tmp4 = _tmp0**2 _tmp5 = _self[0] ** (-2) _tmp6 = _tmp2 * _tmp3 + _tmp4 * _tmp5 + epsilon _tmp7 = math.sqrt(_tmp6) @@ -289,10 +289,10 @@ def camera_ray_from_pixel_with_jacobians(self, pixel, epsilon): _tmp18 = (1.0 / 2.0) * _tmp17 _tmp19 = _tmp1 * _tmp18 _tmp20 = _tmp10 * _tmp12 - _tmp21 = _tmp0 ** 3 / _self[0] ** 4 + _tmp21 = _tmp0**3 / _self[0] ** 4 _tmp22 = math.tan(_tmp11) _tmp23 = 1 / _tmp22 - _tmp24 = _tmp9 ** 2 + 1 + _tmp24 = _tmp9**2 + 1 _tmp25 = _tmp23 * _tmp24 _tmp26 = _self[4] / _tmp6 _tmp27 = (1.0 / 2.0) * _tmp26 @@ -313,9 +313,9 @@ def camera_ray_from_pixel_with_jacobians(self, pixel, epsilon): _tmp42 = _tmp25 * _tmp41 _tmp43 = _tmp26 * _tmp42 _tmp44 = _tmp38 * _tmp41 - _tmp45 = _tmp1 ** 3 / _self[1] ** 4 + _tmp45 = _tmp1**3 / _self[1] ** 4 _tmp46 = _tmp1 * _tmp3 - _tmp47 = _tmp22 ** 2 + _tmp47 = _tmp22**2 _tmp48 = 0.25 * _tmp10 * (_tmp47 + 1) / _tmp47 _tmp49 = _tmp12 * _tmp30 _tmp50 = _tmp12 * _tmp24 diff --git a/gen/python/sym/ops/double_sphere_camera_cal/camera_ops.py b/gen/python/sym/ops/double_sphere_camera_cal/camera_ops.py index af0d7cb3c..5a0bf6b16 100644 --- a/gen/python/sym/ops/double_sphere_camera_cal/camera_ops.py +++ b/gen/python/sym/ops/double_sphere_camera_cal/camera_ops.py @@ -82,18 +82,18 @@ def pixel_from_camera_point(self, point, epsilon): ) # Intermediate terms (13) - _tmp0 = epsilon ** 2 + point[0, 0] ** 2 + point[1, 0] ** 2 + _tmp0 = epsilon**2 + point[0, 0] ** 2 + point[1, 0] ** 2 _tmp1 = math.sqrt(_tmp0 + point[2, 0] ** 2) _tmp2 = _self[4] * _tmp1 + point[2, 0] _tmp3 = min(0, (0.0 if _self[5] - 0.5 == 0 else math.copysign(1, _self[5] - 0.5))) _tmp4 = 2 * _tmp3 _tmp5 = _self[5] - epsilon * (_tmp4 + 1) _tmp6 = -_tmp5 - _tmp7 = 1 / max(epsilon, _tmp2 * (_tmp6 + 1) + _tmp5 * math.sqrt(_tmp0 + _tmp2 ** 2)) + _tmp7 = 1 / max(epsilon, _tmp2 * (_tmp6 + 1) + _tmp5 * math.sqrt(_tmp0 + _tmp2**2)) _tmp8 = _tmp3 + _tmp5 _tmp9 = (1.0 / 2.0) * _tmp4 + _tmp6 + 1 _tmp10 = _self[4] ** 2 - _tmp11 = _tmp9 ** 2 / _tmp8 ** 2 + _tmp11 = _tmp9**2 / _tmp8**2 _tmp12 = _tmp10 * _tmp11 - _tmp10 + 1 # Output terms @@ -174,10 +174,10 @@ def pixel_from_camera_point_with_jacobians(self, point, epsilon): ) # Intermediate terms (40) - _tmp0 = epsilon ** 2 + point[0, 0] ** 2 + point[1, 0] ** 2 + _tmp0 = epsilon**2 + point[0, 0] ** 2 + point[1, 0] ** 2 _tmp1 = math.sqrt(_tmp0 + point[2, 0] ** 2) _tmp2 = _self[4] * _tmp1 + point[2, 0] - _tmp3 = math.sqrt(_tmp0 + _tmp2 ** 2) + _tmp3 = math.sqrt(_tmp0 + _tmp2**2) _tmp4 = min(0, (0.0 if _self[5] - 0.5 == 0 else math.copysign(1, _self[5] - 0.5))) _tmp5 = 2 * _tmp4 _tmp6 = _self[5] - epsilon * (_tmp5 + 1) @@ -192,7 +192,7 @@ def pixel_from_camera_point_with_jacobians(self, point, epsilon): _tmp15 = _tmp4 + _tmp6 _tmp16 = (1.0 / 2.0) * _tmp5 + _tmp7 + 1 _tmp17 = _self[4] ** 2 - _tmp18 = _tmp16 ** 2 / _tmp15 ** 2 + _tmp18 = _tmp16**2 / _tmp15**2 _tmp19 = _tmp17 * _tmp18 - _tmp17 + 1 _tmp20 = _self[0] * point[0, 0] _tmp21 = _tmp6 / _tmp3 @@ -200,7 +200,7 @@ def pixel_from_camera_point_with_jacobians(self, point, epsilon): _tmp23 = ( (1.0 / 2.0) * ((0.0 if _tmp9 - epsilon == 0 else math.copysign(1, _tmp9 - epsilon)) + 1) - / _tmp10 ** 2 + / _tmp10**2 ) _tmp24 = _tmp23 * (_tmp1 * _tmp22 + _tmp1 * _tmp8) _tmp25 = _self[1] * point[1, 0] @@ -309,12 +309,12 @@ def camera_ray_from_pixel(self, pixel, epsilon): # Intermediate terms (12) _tmp0 = -_self[2] + pixel[0, 0] _tmp1 = -_self[3] + pixel[1, 0] - _tmp2 = _tmp1 ** 2 / _self[1] ** 2 + _tmp0 ** 2 / _self[0] ** 2 - _tmp3 = -_self[5] ** 2 * _tmp2 + 1 + _tmp2 = _tmp1**2 / _self[1] ** 2 + _tmp0**2 / _self[0] ** 2 + _tmp3 = -(_self[5] ** 2) * _tmp2 + 1 _tmp4 = -_tmp2 * (2 * _self[5] - 1) + 1 _tmp5 = _self[5] * math.sqrt(max(_tmp4, epsilon)) - _self[5] + 1 _tmp6 = _tmp5 + epsilon * (2 * min(0, (0.0 if _tmp5 == 0 else math.copysign(1, _tmp5))) + 1) - _tmp7 = _tmp3 ** 2 / _tmp6 ** 2 + _tmp7 = _tmp3**2 / _tmp6**2 _tmp8 = _tmp2 + _tmp7 _tmp9 = _tmp3 / _tmp6 _tmp10 = _tmp2 * (1 - _self[4] ** 2) + _tmp7 @@ -363,14 +363,14 @@ def camera_ray_from_pixel_with_jacobians(self, pixel, epsilon): _tmp0 = -_self[2] + pixel[0, 0] _tmp1 = 1 / _self[0] _tmp2 = -_self[3] + pixel[1, 0] - _tmp3 = _tmp2 ** 2 + _tmp3 = _tmp2**2 _tmp4 = _self[1] ** (-2) - _tmp5 = _tmp0 ** 2 + _tmp5 = _tmp0**2 _tmp6 = _self[0] ** (-2) _tmp7 = _tmp3 * _tmp4 + _tmp5 * _tmp6 _tmp8 = _self[5] ** 2 _tmp9 = -_tmp7 * _tmp8 + 1 - _tmp10 = _tmp9 ** 2 + _tmp10 = _tmp9**2 _tmp11 = 2 * _self[5] _tmp12 = _tmp11 - 1 _tmp13 = -_tmp12 * _tmp7 + 1 @@ -404,7 +404,7 @@ def camera_ray_from_pixel_with_jacobians(self, pixel, epsilon): _tmp37 = _tmp17 * _tmp9 _tmp38 = 4 * _tmp37 _tmp39 = _tmp38 * _tmp8 - _tmp40 = _tmp10 / _tmp16 ** 3 + _tmp40 = _tmp10 / _tmp16**3 _tmp41 = -epsilon _tmp42 = ( _self[5] @@ -414,7 +414,7 @@ def camera_ray_from_pixel_with_jacobians(self, pixel, epsilon): _tmp43 = _tmp12 * _tmp42 _tmp44 = _tmp40 * _tmp43 _tmp45 = _tmp35 * _tmp39 - _tmp35 * _tmp44 - _tmp46 = _tmp27 / _tmp20 ** 2 + _tmp46 = _tmp27 / _tmp20**2 _tmp47 = _tmp46 * (-_tmp36 + _tmp45) _tmp48 = (1.0 / 2.0) * _tmp37 * _tmp43 _tmp49 = _self[4] * _tmp48 diff --git a/gen/python/sym/ops/equirectangular_camera_cal/camera_ops.py b/gen/python/sym/ops/equirectangular_camera_cal/camera_ops.py index 4c92cde06..4f903fbbb 100644 --- a/gen/python/sym/ops/equirectangular_camera_cal/camera_ops.py +++ b/gen/python/sym/ops/equirectangular_camera_cal/camera_ops.py @@ -139,7 +139,7 @@ def pixel_from_camera_point_with_jacobians(self, point, epsilon): _tmp4 = math.sqrt(_tmp3 + epsilon) _tmp5 = math.atan2(point[1, 0], _tmp4) _tmp6 = _tmp3 + point[1, 0] ** 2 - _tmp7 = _self[0] / (_tmp0 ** 2 + _tmp2) + _tmp7 = _self[0] / (_tmp0**2 + _tmp2) _tmp8 = _self[1] / (_tmp6 + epsilon) _tmp9 = _tmp8 * point[1, 0] / _tmp4 diff --git a/gen/python/sym/ops/linear_camera_cal/camera_ops.py b/gen/python/sym/ops/linear_camera_cal/camera_ops.py index 131deb845..67dd4c164 100644 --- a/gen/python/sym/ops/linear_camera_cal/camera_ops.py +++ b/gen/python/sym/ops/linear_camera_cal/camera_ops.py @@ -128,7 +128,7 @@ def pixel_from_camera_point_with_jacobians(self, point, epsilon): (0.0 if -epsilon + point[2, 0] == 0 else math.copysign(1, -epsilon + point[2, 0])) + 1 ) - / _tmp0 ** 2 + / _tmp0**2 ) # Output terms diff --git a/gen/python/sym/ops/polynomial_camera_cal/camera_ops.py b/gen/python/sym/ops/polynomial_camera_cal/camera_ops.py index 0d50960ae..bf88da65a 100644 --- a/gen/python/sym/ops/polynomial_camera_cal/camera_ops.py +++ b/gen/python/sym/ops/polynomial_camera_cal/camera_ops.py @@ -86,7 +86,7 @@ def pixel_from_camera_point(self, point, epsilon): _tmp1 = _tmp0 ** (-2) _tmp2 = _tmp1 * point[0, 0] ** 2 + _tmp1 * point[1, 0] ** 2 + epsilon _tmp3 = ( - 1.0 * _self[5] * _tmp2 + 1.0 * _self[6] * _tmp2 ** 2 + 1.0 * _self[7] * _tmp2 ** 3 + 1.0 + 1.0 * _self[5] * _tmp2 + 1.0 * _self[6] * _tmp2**2 + 1.0 * _self[7] * _tmp2**3 + 1.0 ) / _tmp0 # Output terms @@ -140,8 +140,8 @@ def pixel_from_camera_point_with_jacobians(self, point, epsilon): _tmp4 = point[0, 0] ** 2 _tmp5 = _tmp2 * _tmp4 _tmp6 = _tmp3 + _tmp5 + epsilon - _tmp7 = 1.0 * _tmp6 ** 3 - _tmp8 = _tmp6 ** 2 + _tmp7 = 1.0 * _tmp6**3 + _tmp8 = _tmp6**2 _tmp9 = 1.0 * _tmp8 _tmp10 = 1.0 * _self[5] _tmp11 = _self[6] * _tmp9 + _self[7] * _tmp7 + _tmp10 * _tmp6 + 1.0 @@ -167,7 +167,7 @@ def pixel_from_camera_point_with_jacobians(self, point, epsilon): 0.0 if -epsilon + point[2, 0] == 0 else math.copysign(1, -epsilon + point[2, 0]) ) + 1 _tmp31 = (1.0 / 2.0) * _tmp11 * _tmp30 - _tmp32 = _tmp30 / _tmp1 ** 3 + _tmp32 = _tmp30 / _tmp1**3 _tmp33 = -_tmp0 * _tmp32 - _tmp32 * _tmp4 _tmp34 = _tmp12 * (_tmp10 * _tmp33 + 3.0 * _tmp23 * _tmp33 + 2.0 * _tmp25 * _tmp33) diff --git a/gen/python/sym/ops/pose2/group_ops.py b/gen/python/sym/ops/pose2/group_ops.py index 1224edf93..6c429971b 100644 --- a/gen/python/sym/ops/pose2/group_ops.py +++ b/gen/python/sym/ops/pose2/group_ops.py @@ -117,7 +117,7 @@ def inverse_with_jacobian(a): _res[2] = -_tmp1 _res[3] = -_tmp2 + _tmp3 _res_D_a = numpy.zeros((3, 3)) - _res_D_a[0, 0] = -_a[0] ** 2 - _a[1] ** 2 + _res_D_a[0, 0] = -(_a[0] ** 2) - _a[1] ** 2 _res_D_a[1, 0] = -_tmp2 + _tmp3 _res_D_a[2, 0] = _tmp1 _res_D_a[0, 1] = 0 @@ -146,7 +146,7 @@ def compose_with_jacobians(a, b): _tmp4 = _a[0] * _b[2] - _a[1] * _b[3] _tmp5 = _a[1] * _b[2] _tmp6 = _a[0] * _b[3] - _tmp7 = _tmp0 ** 2 - _tmp3 * (-_tmp1 - _tmp2) + _tmp7 = _tmp0**2 - _tmp3 * (-_tmp1 - _tmp2) # Output terms _res = [0.0] * 4 @@ -209,7 +209,7 @@ def between_with_jacobians(a, b): _res[2] = -_tmp6 + _tmp7 + _tmp8 _res[3] = _tmp10 + _tmp11 - _tmp9 _res_D_a = numpy.zeros((3, 3)) - _res_D_a[0, 0] = _tmp2 * (-_tmp0 - _tmp1) - _tmp5 ** 2 + _res_D_a[0, 0] = _tmp2 * (-_tmp0 - _tmp1) - _tmp5**2 _res_D_a[1, 0] = _tmp10 + _tmp11 - _tmp9 _res_D_a[2, 0] = _tmp6 - _tmp7 - _tmp8 _res_D_a[0, 1] = 0 @@ -219,7 +219,7 @@ def between_with_jacobians(a, b): _res_D_a[1, 2] = _tmp13 _res_D_a[2, 2] = _tmp12 _res_D_b = numpy.zeros((3, 3)) - _res_D_b[0, 0] = _tmp2 ** 2 - _tmp5 * (_tmp3 - _tmp4) + _res_D_b[0, 0] = _tmp2**2 - _tmp5 * (_tmp3 - _tmp4) _res_D_b[1, 0] = 0 _res_D_b[2, 0] = 0 _res_D_b[0, 1] = 0 diff --git a/gen/python/sym/ops/pose3/lie_group_ops.py b/gen/python/sym/ops/pose3/lie_group_ops.py index 746cbfe96..bae16ab23 100644 --- a/gen/python/sym/ops/pose3/lie_group_ops.py +++ b/gen/python/sym/ops/pose3/lie_group_ops.py @@ -34,7 +34,7 @@ def from_tangent(vec, epsilon): ) # Intermediate terms (3) - _tmp0 = math.sqrt(epsilon ** 2 + vec[0, 0] ** 2 + vec[1, 0] ** 2 + vec[2, 0] ** 2) + _tmp0 = math.sqrt(epsilon**2 + vec[0, 0] ** 2 + vec[1, 0] ** 2 + vec[2, 0] ** 2) _tmp1 = (1.0 / 2.0) * _tmp0 _tmp2 = math.sin(_tmp1) / _tmp0 @@ -64,7 +64,7 @@ def to_tangent(a, epsilon): 2 * (2 * min(0, (0.0 if _a[3] == 0 else math.copysign(1, _a[3]))) + 1) * math.acos(_tmp0) - / math.sqrt(1 - _tmp0 ** 2) + / math.sqrt(1 - _tmp0**2) ) # Output terms @@ -95,7 +95,7 @@ def retract(a, vec, epsilon): ) # Intermediate terms (8) - _tmp0 = math.sqrt(epsilon ** 2 + vec[0, 0] ** 2 + vec[1, 0] ** 2 + vec[2, 0] ** 2) + _tmp0 = math.sqrt(epsilon**2 + vec[0, 0] ** 2 + vec[1, 0] ** 2 + vec[2, 0] ** 2) _tmp1 = (1.0 / 2.0) * _tmp0 _tmp2 = math.sin(_tmp1) / _tmp0 _tmp3 = _tmp2 * vec[1, 0] @@ -133,7 +133,7 @@ def local_coordinates(a, b, epsilon): 2 * (2 * min(0, (0.0 if -_tmp0 + _tmp1 == 0 else math.copysign(1, -_tmp0 + _tmp1))) + 1) * math.acos(_tmp2) - / math.sqrt(1 - _tmp2 ** 2) + / math.sqrt(1 - _tmp2**2) ) # Output terms @@ -164,12 +164,10 @@ def interpolate(a, b, alpha, epsilon): _tmp4 = min(1 - epsilon, abs(_tmp2 - _tmp3)) _tmp5 = math.acos(_tmp4) _tmp6 = 2 * min(0, (0.0 if -_tmp2 + _tmp3 == 0 else math.copysign(1, -_tmp2 + _tmp3))) + 1 - _tmp7 = 1 - _tmp4 ** 2 - _tmp8 = 4 * _tmp5 ** 2 * _tmp6 ** 2 * alpha ** 2 / _tmp7 + _tmp7 = 1 - _tmp4**2 + _tmp8 = 4 * _tmp5**2 * _tmp6**2 * alpha**2 / _tmp7 _tmp9 = -_a[0] * _b[3] - _a[1] * _b[2] + _a[2] * _b[1] + _a[3] * _b[0] - _tmp10 = math.sqrt( - _tmp0 ** 2 * _tmp8 + _tmp1 ** 2 * _tmp8 + _tmp8 * _tmp9 ** 2 + epsilon ** 2 - ) + _tmp10 = math.sqrt(_tmp0**2 * _tmp8 + _tmp1**2 * _tmp8 + _tmp8 * _tmp9**2 + epsilon**2) _tmp11 = (1.0 / 2.0) * _tmp10 _tmp12 = 2 * _tmp5 * _tmp6 * alpha * math.sin(_tmp11) / (_tmp10 * math.sqrt(_tmp7)) _tmp13 = _tmp0 * _tmp12 diff --git a/gen/python/sym/ops/rot2/group_ops.py b/gen/python/sym/ops/rot2/group_ops.py index 1af84dbf1..0dd8a035b 100644 --- a/gen/python/sym/ops/rot2/group_ops.py +++ b/gen/python/sym/ops/rot2/group_ops.py @@ -102,7 +102,7 @@ def inverse_with_jacobian(a): _res[0] = _a[0] _res[1] = -_a[1] _res_D_a = numpy.zeros(1) - _res_D_a[0] = -_a[0] ** 2 - _a[1] ** 2 + _res_D_a[0] = -(_a[0] ** 2) - _a[1] ** 2 return sym.Rot2.from_storage(_res), _res_D_a @staticmethod @@ -120,7 +120,7 @@ def compose_with_jacobians(a, b): _tmp1 = _a[0] * _b[1] _tmp2 = _a[1] * _b[0] _tmp3 = _tmp1 + _tmp2 - _tmp4 = _tmp0 ** 2 - _tmp3 * (-_tmp1 - _tmp2) + _tmp4 = _tmp0**2 - _tmp3 * (-_tmp1 - _tmp2) # Output terms _res = [0.0] * 2 @@ -155,7 +155,7 @@ def between_with_jacobians(a, b): _res[0] = _tmp2 _res[1] = _tmp5 _res_D_a = numpy.zeros(1) - _res_D_a[0] = _tmp2 * (-_tmp0 - _tmp1) - _tmp5 ** 2 + _res_D_a[0] = _tmp2 * (-_tmp0 - _tmp1) - _tmp5**2 _res_D_b = numpy.zeros(1) - _res_D_b[0] = _tmp2 ** 2 - _tmp5 * (-_tmp3 + _tmp4) + _res_D_b[0] = _tmp2**2 - _tmp5 * (-_tmp3 + _tmp4) return sym.Rot2.from_storage(_res), _res_D_a, _res_D_b diff --git a/gen/python/sym/ops/rot3/group_ops.py b/gen/python/sym/ops/rot3/group_ops.py index 06b3ff113..a227a029d 100644 --- a/gen/python/sym/ops/rot3/group_ops.py +++ b/gen/python/sym/ops/rot3/group_ops.py @@ -106,7 +106,7 @@ def inverse_with_jacobian(a): # Intermediate terms (13) _tmp0 = _a[2] ** 2 _tmp1 = _a[0] ** 2 - _tmp2 = -_a[3] ** 2 + _tmp2 = -(_a[3] ** 2) _tmp3 = _a[1] ** 2 _tmp4 = _tmp2 + _tmp3 _tmp5 = 2 * _a[2] diff --git a/gen/python/sym/ops/rot3/lie_group_ops.py b/gen/python/sym/ops/rot3/lie_group_ops.py index 0ad486103..c8e079e16 100644 --- a/gen/python/sym/ops/rot3/lie_group_ops.py +++ b/gen/python/sym/ops/rot3/lie_group_ops.py @@ -34,7 +34,7 @@ def from_tangent(vec, epsilon): ) # Intermediate terms (3) - _tmp0 = math.sqrt(epsilon ** 2 + vec[0, 0] ** 2 + vec[1, 0] ** 2 + vec[2, 0] ** 2) + _tmp0 = math.sqrt(epsilon**2 + vec[0, 0] ** 2 + vec[1, 0] ** 2 + vec[2, 0] ** 2) _tmp1 = (1.0 / 2.0) * _tmp0 _tmp2 = math.sin(_tmp1) / _tmp0 @@ -61,7 +61,7 @@ def to_tangent(a, epsilon): 2 * (2 * min(0, (0.0 if _a[3] == 0 else math.copysign(1, _a[3]))) + 1) * math.acos(_tmp0) - / math.sqrt(1 - _tmp0 ** 2) + / math.sqrt(1 - _tmp0**2) ) # Output terms @@ -89,7 +89,7 @@ def retract(a, vec, epsilon): ) # Intermediate terms (8) - _tmp0 = math.sqrt(epsilon ** 2 + vec[0, 0] ** 2 + vec[1, 0] ** 2 + vec[2, 0] ** 2) + _tmp0 = math.sqrt(epsilon**2 + vec[0, 0] ** 2 + vec[1, 0] ** 2 + vec[2, 0] ** 2) _tmp1 = (1.0 / 2.0) * _tmp0 _tmp2 = math.cos(_tmp1) _tmp3 = math.sin(_tmp1) / _tmp0 @@ -123,7 +123,7 @@ def local_coordinates(a, b, epsilon): 2 * (2 * min(0, (0.0 if _tmp0 == 0 else math.copysign(1, _tmp0))) + 1) * math.acos(_tmp1) - / math.sqrt(1 - _tmp1 ** 2) + / math.sqrt(1 - _tmp1**2) ) # Output terms @@ -147,15 +147,13 @@ def interpolate(a, b, alpha, epsilon): _tmp0 = -_a[0] * _b[3] - _a[1] * _b[2] + _a[2] * _b[1] + _a[3] * _b[0] _tmp1 = _a[0] * _b[0] + _a[1] * _b[1] + _a[2] * _b[2] + _a[3] * _b[3] _tmp2 = min(abs(_tmp1), 1 - epsilon) - _tmp3 = 1 - _tmp2 ** 2 + _tmp3 = 1 - _tmp2**2 _tmp4 = 2 * min(0, (0.0 if _tmp1 == 0 else math.copysign(1, _tmp1))) + 1 _tmp5 = -_a[0] * _b[1] + _a[1] * _b[0] - _a[2] * _b[3] + _a[3] * _b[2] _tmp6 = math.acos(_tmp2) - _tmp7 = 4 * _tmp4 ** 2 * _tmp6 ** 2 * alpha ** 2 / _tmp3 + _tmp7 = 4 * _tmp4**2 * _tmp6**2 * alpha**2 / _tmp3 _tmp8 = _a[0] * _b[2] - _a[1] * _b[3] - _a[2] * _b[0] + _a[3] * _b[1] - _tmp9 = math.sqrt( - _tmp0 ** 2 * _tmp7 + _tmp5 ** 2 * _tmp7 + _tmp7 * _tmp8 ** 2 + epsilon ** 2 - ) + _tmp9 = math.sqrt(_tmp0**2 * _tmp7 + _tmp5**2 * _tmp7 + _tmp7 * _tmp8**2 + epsilon**2) _tmp10 = (1.0 / 2.0) * _tmp9 _tmp11 = 2 * _tmp4 * _tmp6 * alpha * math.sin(_tmp10) / (math.sqrt(_tmp3) * _tmp9) _tmp12 = _a[3] * _tmp11 diff --git a/gen/python/sym/ops/spherical_camera_cal/camera_ops.py b/gen/python/sym/ops/spherical_camera_cal/camera_ops.py index 774ee3e87..a56a4eca1 100644 --- a/gen/python/sym/ops/spherical_camera_cal/camera_ops.py +++ b/gen/python/sym/ops/spherical_camera_cal/camera_ops.py @@ -86,10 +86,10 @@ def pixel_from_camera_point(self, point, epsilon): _tmp1 = math.atan2(_tmp0, point[2, 0]) _tmp2 = min(_tmp1, _self[4] - epsilon) _tmp3 = ( - _self[5] * _tmp2 ** 3 - + _self[6] * _tmp2 ** 5 - + _self[7] * _tmp2 ** 7 - + _self[8] * _tmp2 ** 9 + _self[5] * _tmp2**3 + + _self[6] * _tmp2**5 + + _self[7] * _tmp2**7 + + _self[8] * _tmp2**9 + _tmp2 ) / _tmp0 @@ -134,10 +134,10 @@ def pixel_from_camera_point_with_jacobians(self, point, epsilon): _tmp4 = math.sqrt(_tmp3) _tmp5 = math.atan2(_tmp4, point[2, 0]) _tmp6 = min(_tmp5, _self[4] + _tmp0) - _tmp7 = _tmp6 ** 5 - _tmp8 = _tmp6 ** 7 - _tmp9 = _tmp6 ** 9 - _tmp10 = _tmp6 ** 3 + _tmp7 = _tmp6**5 + _tmp8 = _tmp6**7 + _tmp9 = _tmp6**9 + _tmp10 = _tmp6**3 _tmp11 = _self[5] * _tmp10 + _self[6] * _tmp7 + _self[7] * _tmp8 + _self[8] * _tmp9 + _tmp6 _tmp12 = 1 / _tmp4 _tmp13 = _tmp11 * _tmp12 @@ -149,18 +149,18 @@ def pixel_from_camera_point_with_jacobians(self, point, epsilon): _tmp19 = _self[1] * point[1, 0] _tmp20 = _tmp12 * _tmp19 _tmp21 = _tmp12 * _tmp9 - _tmp22 = (9.0 / 2.0) * _self[8] * _tmp6 ** 8 + _tmp22 = (9.0 / 2.0) * _self[8] * _tmp6**8 _tmp23 = ((0.0 if _tmp0 + _tmp16 == 0 else math.copysign(1, _tmp0 + _tmp16)) + 1) / ( _tmp3 + point[2, 0] ** 2 ) _tmp24 = _tmp12 * point[2, 0] _tmp25 = _tmp23 * _tmp24 _tmp26 = _tmp22 * _tmp25 - _tmp27 = (5.0 / 2.0) * _self[6] * _tmp6 ** 4 + _tmp27 = (5.0 / 2.0) * _self[6] * _tmp6**4 _tmp28 = _tmp25 * _tmp27 - _tmp29 = (7.0 / 2.0) * _self[7] * _tmp6 ** 6 + _tmp29 = (7.0 / 2.0) * _self[7] * _tmp6**6 _tmp30 = _tmp25 * _tmp29 - _tmp31 = (3.0 / 2.0) * _self[5] * _tmp6 ** 2 + _tmp31 = (3.0 / 2.0) * _self[5] * _tmp6**2 _tmp32 = _tmp25 * _tmp31 _tmp33 = (1.0 / 2.0) * _tmp23 _tmp34 = _tmp24 * _tmp33 diff --git a/gen/python/sym/ops/unit3/lie_group_ops.py b/gen/python/sym/ops/unit3/lie_group_ops.py index f1429a446..069bf493e 100644 --- a/gen/python/sym/ops/unit3/lie_group_ops.py +++ b/gen/python/sym/ops/unit3/lie_group_ops.py @@ -34,7 +34,7 @@ def from_tangent(vec, epsilon): ) # Intermediate terms (3) - _tmp0 = math.sqrt(epsilon ** 2 + vec[0, 0] ** 2 + vec[1, 0] ** 2) + _tmp0 = math.sqrt(epsilon**2 + vec[0, 0] ** 2 + vec[1, 0] ** 2) _tmp1 = (1.0 / 2.0) * _tmp0 _tmp2 = math.sin(_tmp1) / _tmp0 @@ -61,7 +61,7 @@ def to_tangent(a, epsilon): 2 * (2 * min(0, (0.0 if _a[3] == 0 else math.copysign(1, _a[3]))) + 1) * math.acos(_tmp0) - / math.sqrt(1 - _tmp0 ** 2) + / math.sqrt(1 - _tmp0**2) ) # Output terms @@ -88,7 +88,7 @@ def retract(a, vec, epsilon): ) # Intermediate terms (8) - _tmp0 = math.sqrt(epsilon ** 2 + vec[0, 0] ** 2 + vec[1, 0] ** 2) + _tmp0 = math.sqrt(epsilon**2 + vec[0, 0] ** 2 + vec[1, 0] ** 2) _tmp1 = (1.0 / 2.0) * _tmp0 _tmp2 = math.cos(_tmp1) _tmp3 = math.sin(_tmp1) / _tmp0 @@ -122,7 +122,7 @@ def local_coordinates(a, b, epsilon): 2 * (2 * min(0, (0.0 if _tmp0 == 0 else math.copysign(1, _tmp0))) + 1) * math.acos(_tmp1) - / math.sqrt(1 - _tmp1 ** 2) + / math.sqrt(1 - _tmp1**2) ) # Output terms @@ -145,12 +145,12 @@ def interpolate(a, b, alpha, epsilon): _tmp0 = _a[0] * _b[2] - _a[1] * _b[3] - _a[2] * _b[0] + _a[3] * _b[1] _tmp1 = _a[0] * _b[0] + _a[1] * _b[1] + _a[2] * _b[2] + _a[3] * _b[3] _tmp2 = min(abs(_tmp1), 1 - epsilon) - _tmp3 = 1 - _tmp2 ** 2 + _tmp3 = 1 - _tmp2**2 _tmp4 = 2 * min(0, (0.0 if _tmp1 == 0 else math.copysign(1, _tmp1))) + 1 _tmp5 = -_a[0] * _b[3] - _a[1] * _b[2] + _a[2] * _b[1] + _a[3] * _b[0] _tmp6 = math.acos(_tmp2) - _tmp7 = 4 * _tmp4 ** 2 * _tmp6 ** 2 * alpha ** 2 / _tmp3 - _tmp8 = math.sqrt(_tmp0 ** 2 * _tmp7 + _tmp5 ** 2 * _tmp7 + epsilon ** 2) + _tmp7 = 4 * _tmp4**2 * _tmp6**2 * alpha**2 / _tmp3 + _tmp8 = math.sqrt(_tmp0**2 * _tmp7 + _tmp5**2 * _tmp7 + epsilon**2) _tmp9 = (1.0 / 2.0) * _tmp8 _tmp10 = 2 * _tmp4 * _tmp6 * alpha * math.sin(_tmp9) / (math.sqrt(_tmp3) * _tmp8) _tmp11 = _tmp0 * _tmp10 diff --git a/gen/python/sym/rot3.py b/gen/python/sym/rot3.py index 22c19f7fd..88179c6fa 100644 --- a/gen/python/sym/rot3.py +++ b/gen/python/sym/rot3.py @@ -56,10 +56,10 @@ def __init__(self, q=None): def from_rotation_matrix(cls, R, epsilon=0.0): # type: (numpy.ndarray, float) -> Rot3 assert R.shape == (3, 3) - w = numpy.sqrt(max(epsilon ** 2, 1 + R[0, 0] + R[1, 1] + R[2, 2])) / 2 - x = numpy.sqrt(max(epsilon ** 2, 1 + R[0, 0] - R[1, 1] - R[2, 2])) / 2 - y = numpy.sqrt(max(epsilon ** 2, 1 - R[0, 0] + R[1, 1] - R[2, 2])) / 2 - z = numpy.sqrt(max(epsilon ** 2, 1 - R[0, 0] - R[1, 1] + R[2, 2])) / 2 + w = numpy.sqrt(max(epsilon**2, 1 + R[0, 0] + R[1, 1] + R[2, 2])) / 2 + x = numpy.sqrt(max(epsilon**2, 1 + R[0, 0] - R[1, 1] - R[2, 2])) / 2 + y = numpy.sqrt(max(epsilon**2, 1 - R[0, 0] + R[1, 1] - R[2, 2])) / 2 + z = numpy.sqrt(max(epsilon**2, 1 - R[0, 0] - R[1, 1] + R[2, 2])) / 2 x = abs(x) if (R[2, 1] - R[1, 2]) < 0: @@ -223,7 +223,7 @@ def to_yaw_pitch_roll(self): _tmp1 = 2 * _self[2] _tmp2 = _self[2] ** 2 _tmp3 = _self[0] ** 2 - _tmp4 = -_self[1] ** 2 + _self[3] ** 2 + _tmp4 = -(_self[1] ** 2) + _self[3] ** 2 # Output terms _res = numpy.zeros(3) @@ -328,8 +328,8 @@ def from_two_unit_vectors(a, b, epsilon): # Intermediate terms (7) _tmp0 = 1.0 / 2.0 - 1.0 / 2.0 * ( 0.0 - if a[1, 0] ** 2 + a[2, 0] ** 2 - epsilon ** 2 == 0 - else math.copysign(1, a[1, 0] ** 2 + a[2, 0] ** 2 - epsilon ** 2) + if a[1, 0] ** 2 + a[2, 0] ** 2 - epsilon**2 == 0 + else math.copysign(1, a[1, 0] ** 2 + a[2, 0] ** 2 - epsilon**2) ) _tmp1 = a[0, 0] * b[0, 0] + a[1, 0] * b[1, 0] + a[2, 0] * b[2, 0] _tmp2 = ( diff --git a/gen/python/sym/unit3.py b/gen/python/sym/unit3.py index bf8b3c092..f3cdc334d 100644 --- a/gen/python/sym/unit3.py +++ b/gen/python/sym/unit3.py @@ -82,7 +82,7 @@ def from_vector(a, epsilon): # Intermediate terms (8) _tmp0 = 1.0 / 2.0 - 1.0 / 2.0 * ( - 0.0 if 1 - epsilon ** 2 == 0 else math.copysign(1, 1 - epsilon ** 2) + 0.0 if 1 - epsilon**2 == 0 else math.copysign(1, 1 - epsilon**2) ) _tmp1 = 1 / math.sqrt(a[0, 0] ** 2 + a[1, 0] ** 2 + a[2, 0] ** 2 + epsilon) _tmp2 = _tmp1 * a[2, 0] diff --git a/notebooks/geo_types_python.ipynb b/notebooks/geo_types_python.ipynb index 2160484c2..c33532dde 100644 --- a/notebooks/geo_types_python.ipynb +++ b/notebooks/geo_types_python.ipynb @@ -6,8 +6,9 @@ "metadata": {}, "outputs": [], "source": [ - "import sym\n", - "import numpy as np" + "import numpy as np\n", + "\n", + "import sym" ] }, { diff --git a/notebooks/n-pendulum-control.ipynb b/notebooks/n-pendulum-control.ipynb index dbdb2147f..e2a9a826a 100644 --- a/notebooks/n-pendulum-control.ipynb +++ b/notebooks/n-pendulum-control.ipynb @@ -796,7 +796,7 @@ " n = a.shape[0]\n", " controllability_matrix = []\n", " for i in range(n):\n", - " controllability_matrix.append(a ** i * b)\n", + " controllability_matrix.append(a**i * b)\n", " controllability_matrix = np.hstack(controllability_matrix)\n", "\n", " return np.linalg.matrix_rank(controllability_matrix, tol=1e-6) == n" diff --git a/notebooks/storage_D_tangent.ipynb b/notebooks/storage_D_tangent.ipynb index a70132d5b..0fba0f343 100644 --- a/notebooks/storage_D_tangent.ipynb +++ b/notebooks/storage_D_tangent.ipynb @@ -12,8 +12,8 @@ "symforce.set_log_level(\"warning\")\n", "\n", "import symforce.symbolic as sf\n", - "from symforce.ops import StorageOps\n", "from symforce.ops import LieGroupOps\n", + "from symforce.ops import StorageOps\n", "\n", "epsilon = 1e-9" ] diff --git a/notebooks/tangent_D_storage.ipynb b/notebooks/tangent_D_storage.ipynb index 15e524fb1..adfbabafd 100644 --- a/notebooks/tangent_D_storage.ipynb +++ b/notebooks/tangent_D_storage.ipynb @@ -12,8 +12,8 @@ "symforce.set_log_level(\"warning\")\n", "\n", "import symforce.symbolic as sf\n", - "from symforce.ops import StorageOps\n", "from symforce.ops import LieGroupOps\n", + "from symforce.ops import StorageOps\n", "\n", "epsilon = 1e-9" ] diff --git a/notebooks/tutorials/cameras_tutorial.ipynb b/notebooks/tutorials/cameras_tutorial.ipynb index a31050b60..93ec71759 100644 --- a/notebooks/tutorials/cameras_tutorial.ipynb +++ b/notebooks/tutorials/cameras_tutorial.ipynb @@ -26,8 +26,8 @@ "symforce.set_symbolic_api(\"sympy\")\n", "symforce.set_log_level(\"warning\")\n", "\n", - "from symforce.notebook_util import display\n", - "import symforce.symbolic as sf" + "import symforce.symbolic as sf\n", + "from symforce.notebook_util import display" ] }, { diff --git a/notebooks/tutorials/codegen_tutorial.ipynb b/notebooks/tutorials/codegen_tutorial.ipynb index 46cd10c70..17beb861c 100644 --- a/notebooks/tutorials/codegen_tutorial.ipynb +++ b/notebooks/tutorials/codegen_tutorial.ipynb @@ -34,6 +34,7 @@ "source": [ "# Setup\n", "import numpy as np\n", + "\n", "import symforce\n", "\n", "symforce.set_symbolic_api(\"symengine\")\n", @@ -43,12 +44,14 @@ "# https://symforce.org/tutorials/epsilon_tutorial.html\n", "symforce.set_epsilon_to_symbol()\n", "\n", + "import symforce.symbolic as sf\n", "from symforce import codegen\n", - "from symforce.codegen import codegen_util\n", "from symforce import ops\n", - "import symforce.symbolic as sf\n", - "from symforce.values import Values\n", - "from symforce.notebook_util import display, display_code, display_code_file" + "from symforce.codegen import codegen_util\n", + "from symforce.notebook_util import display\n", + "from symforce.notebook_util import display_code\n", + "from symforce.notebook_util import display_code_file\n", + "from symforce.values import Values" ] }, { diff --git a/notebooks/tutorials/epsilon_tutorial.ipynb b/notebooks/tutorials/epsilon_tutorial.ipynb index 719d6c55a..d69304e63 100644 --- a/notebooks/tutorials/epsilon_tutorial.ipynb +++ b/notebooks/tutorials/epsilon_tutorial.ipynb @@ -384,7 +384,7 @@ "outputs": [], "source": [ "# Original fails, singular at 0\n", - "assert is_epsilon_correct(lambda x, eps: x / sm.sqrt(x ** 2)) == False" + "assert is_epsilon_correct(lambda x, eps: x / sm.sqrt(x**2)) == False" ] }, { @@ -394,7 +394,7 @@ "outputs": [], "source": [ "# Broken fix #1\n", - "assert is_epsilon_correct(lambda x, eps: x / sm.sqrt(x ** 2 + eps ** 2)) == False" + "assert is_epsilon_correct(lambda x, eps: x / sm.sqrt(x**2 + eps**2)) == False" ] }, { @@ -406,7 +406,7 @@ "# Broken fix #2\n", "assert (\n", " is_epsilon_correct(\n", - " lambda x, eps: (x + eps) / sm.sqrt(x ** 2 + eps ** 2),\n", + " lambda x, eps: (x + eps) / sm.sqrt(x**2 + eps**2),\n", " )\n", " == False\n", ")" @@ -421,7 +421,7 @@ "# Broken fix #3, ugh\n", "assert (\n", " is_epsilon_correct(\n", - " lambda x, eps: (x + eps) / (eps + sm.sqrt(x ** 2 + eps ** 2)),\n", + " lambda x, eps: (x + eps) / (eps + sm.sqrt(x**2 + eps**2)),\n", " )\n", " == False\n", ")" @@ -459,7 +459,7 @@ "# Original fails, singular at 1\n", "assert (\n", " is_epsilon_correct(\n", - " lambda x, eps: sm.acos(x) / sm.sqrt(1 - x ** 2),\n", + " lambda x, eps: sm.acos(x) / sm.sqrt(1 - x**2),\n", " singularity=1,\n", " )\n", " == False\n", @@ -678,7 +678,7 @@ "assert (\n", " is_epsilon_correct(\n", " lambda x, eps: add_epsilon_near_1_sign(\n", - " sm.cos(x) / sm.sqrt(1 - x ** 2),\n", + " sm.cos(x) / sm.sqrt(1 - x**2),\n", " x,\n", " eps,\n", " ),\n", @@ -729,7 +729,7 @@ "source": [ "assert (\n", " is_epsilon_correct(\n", - " lambda x, eps: add_epsilon_sign((sm.sin(x) + x ** 2) / x, x, eps),\n", + " lambda x, eps: add_epsilon_sign((sm.sin(x) + x**2) / x, x, eps),\n", " )\n", " == True\n", ")" @@ -751,7 +751,7 @@ "source": [ "assert (\n", " is_epsilon_correct(\n", - " lambda x, eps: add_epsilon_max((sm.sin(x) + x ** 2) / x, x, eps),\n", + " lambda x, eps: add_epsilon_max((sm.sin(x) + x**2) / x, x, eps),\n", " )\n", " == False\n", ")" @@ -968,7 +968,7 @@ "source": [ "# Looking at a normalization function\n", "epsilon = sm.Symbol(\"epsilon\")\n", - "expr = x / sm.sqrt(x ** 2 + y ** 2)\n", + "expr = x / sm.sqrt(x**2 + y**2)\n", "sm.series(expr, x, n=2)\n", "sm.simplify(expr.diff(x).limit(x, 0))" ] @@ -1000,7 +1000,7 @@ "metadata": {}, "outputs": [], "source": [ - "is_epsilon_correct(lambda x, eps: (x + eps) / sm.sqrt(eps ** 2 + (x + eps) ** 2))" + "is_epsilon_correct(lambda x, eps: (x + eps) / sm.sqrt(eps**2 + (x + eps) ** 2))" ] }, { @@ -1009,7 +1009,7 @@ "metadata": {}, "outputs": [], "source": [ - "is_epsilon_correct(lambda x, eps: (x + eps) / sm.sqrt(eps ** 2 + (x + eps) ** 2))" + "is_epsilon_correct(lambda x, eps: (x + eps) / sm.sqrt(eps**2 + (x + eps) ** 2))" ] } ], diff --git a/notebooks/tutorials/geometry_tutorial.ipynb b/notebooks/tutorials/geometry_tutorial.ipynb index e4374693b..95b9933f4 100644 --- a/notebooks/tutorials/geometry_tutorial.ipynb +++ b/notebooks/tutorials/geometry_tutorial.ipynb @@ -28,9 +28,9 @@ "symforce.set_symbolic_api(\"sympy\")\n", "symforce.set_log_level(\"warning\")\n", "\n", - "from symforce.notebook_util import display\n", "import symforce.symbolic as sf\n", - "from symforce import ops" + "from symforce import ops\n", + "from symforce.notebook_util import display" ] }, { diff --git a/notebooks/tutorials/ops_tutorial.ipynb b/notebooks/tutorials/ops_tutorial.ipynb index 6c67915e7..37645c91b 100644 --- a/notebooks/tutorials/ops_tutorial.ipynb +++ b/notebooks/tutorials/ops_tutorial.ipynb @@ -30,10 +30,12 @@ "symforce.set_symbolic_api(\"sympy\")\n", "symforce.set_log_level(\"warning\")\n", "\n", - "from symforce.notebook_util import display\n", "import symforce.symbolic as sf\n", - "from symforce.values import Values\n", - "from symforce.ops import StorageOps, GroupOps, LieGroupOps" + "from symforce.notebook_util import display\n", + "from symforce.ops import GroupOps\n", + "from symforce.ops import LieGroupOps\n", + "from symforce.ops import StorageOps\n", + "from symforce.values import Values" ] }, { diff --git a/notebooks/tutorials/sympy_tutorial.ipynb b/notebooks/tutorials/sympy_tutorial.ipynb index 6d03b610f..b51ae5737 100644 --- a/notebooks/tutorials/sympy_tutorial.ipynb +++ b/notebooks/tutorials/sympy_tutorial.ipynb @@ -26,7 +26,8 @@ "\n", "symforce.set_symbolic_api(\"sympy\")\n", "symforce.set_log_level(\"warning\")\n", - "from symforce.notebook_util import display, print_expression_tree" + "from symforce.notebook_util import display\n", + "from symforce.notebook_util import print_expression_tree" ] }, { @@ -61,7 +62,7 @@ "metadata": {}, "outputs": [], "source": [ - "expr = x ** 2 + sf.sin(y) / x ** 2\n", + "expr = x**2 + sf.sin(y) / x**2\n", "display(expr)" ] }, diff --git a/notebooks/tutorials/values_tutorial.ipynb b/notebooks/tutorials/values_tutorial.ipynb index be61d0a67..fd9427074 100644 --- a/notebooks/tutorials/values_tutorial.ipynb +++ b/notebooks/tutorials/values_tutorial.ipynb @@ -29,8 +29,10 @@ "symforce.set_log_level(\"warning\")\n", "\n", "import symforce.symbolic as sf\n", - "from symforce.values import Values\n", - "from symforce.notebook_util import display, display_code, display_code_file" + "from symforce.notebook_util import display\n", + "from symforce.notebook_util import display_code\n", + "from symforce.notebook_util import display_code_file\n", + "from symforce.values import Values" ] }, { @@ -77,7 +79,7 @@ "outputs": [], "source": [ "x, y = sf.symbols(\"x y\")\n", - "expr = x ** 2 + sf.sin(y) / x ** 2\n", + "expr = x**2 + sf.sin(y) / x**2\n", "inputs[\"states\"] = Values(p=expr)\n", "display(inputs)" ] @@ -273,7 +275,7 @@ "source": [ "v = Values()\n", "with v.scope(\"hello\"):\n", - " v[\"y\"] = x ** 2\n", + " v[\"y\"] = x**2\n", " v[\"z\"] = sf.Symbol(\"z\")\n", "v" ] diff --git a/pyproject.toml b/pyproject.toml index 353ba53ba..8cc361c33 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -46,28 +46,32 @@ dynamic = ["version", "readme", "dependencies", "optional-dependencies"] Source = "https://github.com/symforce-org/symforce" # -------------------------------------------------------------------------------- -# Other configuration +# Ruff # -------------------------------------------------------------------------------- -[tool.black] +[tool.ruff] line-length = 100 +exclude = ["third_party", "build", ".eggs"] +extend-include = ["*.ipynb"] -[tool.isort] -profile = "black" -line_length = 100 -py_version = "all" -sections = [ - "FUTURE", - "STDLIB", - "THIRDPARTY", - "GENERATED", - "FIRSTPARTY", - "LOCALFOLDER", +[tool.ruff.lint.isort] +known-first-party = ["sym", "symforce"] +force-single-line = true +section-order = [ + "future", + "standard-library", + "third-party", + "generated", + "first-party", + "local-folder", ] -known_generated = ["lcmtypes"] -src_paths = [] -known_first_party = ["sym", "symforce"] -force_single_line = true + +[tool.ruff.lint.isort.sections] +"generated" = ["lcmtypes"] + +# -------------------------------------------------------------------------------- +# Mypy +# -------------------------------------------------------------------------------- [tool.mypy] python_version = "3.8" @@ -79,11 +83,11 @@ mypy_path = [".", "gen/python", "$SYMFORCE_LCMTYPES_DIR", "symforce/pybind"] module = [ "IPython.*", "argh.*", - "black.*", "graphviz.*", "matplotlib.*", "mpl_toolkits.*", "numba.*", + "ruff.*", "scipy.*", "skymarshal.*", "symengine.*", diff --git a/setup.py b/setup.py index 53ee16ccf..6bb4778fd 100644 --- a/setup.py +++ b/setup.py @@ -252,7 +252,8 @@ def filter_local(s: str) -> str: return s self.distribution.install_requires = [ # type: ignore[attr-defined] - filter_local(requirement) for requirement in self.distribution.install_requires # type: ignore[attr-defined] + filter_local(requirement) + for requirement in self.distribution.install_requires # type: ignore[attr-defined] ] self.distribution.extras_require = { # type: ignore[attr-defined] k: [filter_local(requirement) for requirement in v] @@ -425,7 +426,7 @@ def fixed_readme() -> str: ext_modules=[CMakeExtension("cc_sym"), CMakeExtension("lcmtypes")], # Barebones packages needed to run symforce install_requires=[ - "black", + "ruff", "clang-format", "graphviz", "jinja2", @@ -440,11 +441,8 @@ def fixed_readme() -> str: "docs": docs_requirements, "dev": docs_requirements + [ - "click~=8.0.4", # Required by black, but not specified by our version of black "argh", - "black[jupyter]==21.12b0", "coverage", - "isort", "jinja2~=3.0.3", "mypy==0.910", "numba", diff --git a/symforce/_sympy_count_ops.py b/symforce/_sympy_count_ops.py index 2a5916fcf..5ba2be0ae 100644 --- a/symforce/_sympy_count_ops.py +++ b/symforce/_sympy_count_ops.py @@ -131,7 +131,6 @@ def count_ops(expr: T.Any, visual: bool = False) -> T.Union[Expr, int]: # pylint: disable=too-many-nested-blocks if isinstance(expr, Expr) and not expr.is_Relational: - ops = [] args = [expr] NEG = Symbol("NEG") diff --git a/symforce/benchmarks/matrix_multiplication/generate_matrix_multiplication_benchmark.py b/symforce/benchmarks/matrix_multiplication/generate_matrix_multiplication_benchmark.py index e52ddfe77..85bc924eb 100644 --- a/symforce/benchmarks/matrix_multiplication/generate_matrix_multiplication_benchmark.py +++ b/symforce/benchmarks/matrix_multiplication/generate_matrix_multiplication_benchmark.py @@ -181,7 +181,7 @@ def compute_A(*symbols: T.List[sf.Symbol]) -> sf.Matrix: # By default, Eigen will not allocate more than 128KB on the stack # https://eigen.tuxfamily.org/dox/TopicPreprocessorDirectives.html - EIGEN_STACK_ALLOCATION_LIMIT_BYTES = 128 * 2 ** 10 + EIGEN_STACK_ALLOCATION_LIMIT_BYTES = 128 * 2**10 cant_allocate_on_stack = ( matrix.shape[0] * matrix.shape[1] * 8 > EIGEN_STACK_ALLOCATION_LIMIT_BYTES diff --git a/symforce/benchmarks/notebooks/jax_inverse_compose.ipynb b/symforce/benchmarks/notebooks/jax_inverse_compose.ipynb index e0e23c759..0ea8d1fde 100644 --- a/symforce/benchmarks/notebooks/jax_inverse_compose.ipynb +++ b/symforce/benchmarks/notebooks/jax_inverse_compose.ipynb @@ -17,11 +17,12 @@ "metadata": {}, "outputs": [], "source": [ - "import numpy as onp\n", - "import jaxlie\n", - "from jax import numpy as np\n", + "import time\n", + "\n", "import jax\n", - "import time" + "import jaxlie\n", + "import numpy as onp\n", + "from jax import numpy as np" ] }, { diff --git a/symforce/benchmarks/notebooks/jax_matmul.ipynb b/symforce/benchmarks/notebooks/jax_matmul.ipynb index 0fbaed95d..9906005bd 100644 --- a/symforce/benchmarks/notebooks/jax_matmul.ipynb +++ b/symforce/benchmarks/notebooks/jax_matmul.ipynb @@ -19,10 +19,11 @@ "metadata": {}, "outputs": [], "source": [ - "import numpy as onp\n", - "from jax import numpy as np\n", + "import time\n", + "\n", "import jax\n", - "import time" + "import numpy as onp\n", + "from jax import numpy as np" ] }, { diff --git a/symforce/benchmarks/notebooks/jax_robot_localization.ipynb b/symforce/benchmarks/notebooks/jax_robot_localization.ipynb index c0809ef97..ae03fa120 100644 --- a/symforce/benchmarks/notebooks/jax_robot_localization.ipynb +++ b/symforce/benchmarks/notebooks/jax_robot_localization.ipynb @@ -19,12 +19,13 @@ "metadata": {}, "outputs": [], "source": [ - "import numpy as onp\n", "import itertools\n", - "import jaxlie\n", - "from jax import numpy as np\n", + "import time\n", + "\n", "import jax\n", - "import time" + "import jaxlie\n", + "import numpy as onp\n", + "from jax import numpy as np" ] }, { diff --git a/symforce/benchmarks/notebooks/matmul_plots.ipynb b/symforce/benchmarks/notebooks/matmul_plots.ipynb index 4c0ced19d..943c5203a 100644 --- a/symforce/benchmarks/notebooks/matmul_plots.ipynb +++ b/symforce/benchmarks/notebooks/matmul_plots.ipynb @@ -16,13 +16,14 @@ "outputs": [], "source": [ "import dataclasses\n", + "import pickle\n", + "from pathlib import Path\n", + "\n", "import matplotlib.pyplot as plt\n", "import numpy as np\n", "import pandas as pd\n", - "from pathlib import Path\n", - "import pickle\n", - "from plotly import express as ex\n", - "import scipy.io" + "import scipy.io\n", + "from plotly import express as ex" ] }, { diff --git a/symforce/benchmarks/run_benchmarks.py b/symforce/benchmarks/run_benchmarks.py index 8ee5fce7f..e3573a9ed 100644 --- a/symforce/benchmarks/run_benchmarks.py +++ b/symforce/benchmarks/run_benchmarks.py @@ -171,7 +171,7 @@ def run_matmul_benchmark( # Parse n_runs_multiplier out of the log, and divide results by number of runs # to give all metrics per-run gain = float(output.splitlines()[1].split()[-1][:-1]) - scale = (10 ** 2) * (gain ** 2) + scale = (10**2) * (gain**2) matrix_results = [float(l.split(",")[0]) for l in output.splitlines()[-3:]] matrix_results = [x / scale for x in matrix_results] diff --git a/symforce/cam/atan_camera_cal.py b/symforce/cam/atan_camera_cal.py index 0cda6b67a..e30b22d67 100644 --- a/symforce/cam/atan_camera_cal.py +++ b/symforce/cam/atan_camera_cal.py @@ -58,7 +58,6 @@ def storage_order(cls) -> T.Tuple[T.Tuple[str, int], ...]: def pixel_from_camera_point( self, point: geo.V3, epsilon: T.Scalar = sf.epsilon() ) -> T.Tuple[geo.V2, T.Scalar]: - # Compute undistorted point in unit depth image plane linear_camera_cal = LinearCameraCal( self.focal_length.to_flat_list(), self.principal_point.to_flat_list() @@ -80,7 +79,6 @@ def pixel_from_camera_point( def camera_ray_from_pixel( self, pixel: geo.V2, epsilon: T.Scalar = sf.epsilon() ) -> T.Tuple[geo.V3, T.Scalar]: - # Compute distorted unit depth coords linear_camera_cal = LinearCameraCal( self.focal_length.to_flat_list(), self.principal_point.to_flat_list() diff --git a/symforce/cam/double_sphere_camera_cal.py b/symforce/cam/double_sphere_camera_cal.py index 763b4bf09..f425ae20c 100644 --- a/symforce/cam/double_sphere_camera_cal.py +++ b/symforce/cam/double_sphere_camera_cal.py @@ -93,8 +93,8 @@ def pixel_from_camera_point( # Follows equations (40) to (45) - d1 = sf.sqrt(x ** 2 + y ** 2 + z ** 2 + epsilon ** 2) - d2 = sf.sqrt(x ** 2 + y ** 2 + (xi * d1 + z) ** 2 + epsilon ** 2) + d1 = sf.sqrt(x**2 + y**2 + z**2 + epsilon**2) + d2 = sf.sqrt(x**2 + y**2 + (xi * d1 + z) ** 2 + epsilon**2) z_effective = alpha_safe * d2 + (1 - alpha_safe) * (xi * d1 + z) @@ -112,8 +112,8 @@ def pixel_from_camera_point( # NOTE(aaron): w2 here is NOT equal to the w2 in the paper - we're pretty confident this # one is correct though (for all domains, including the domain in the paper) - w2_discriminant = w1 ** 2 * xi ** 2 - xi ** 2 + 1 - w2 = w1 ** 2 * xi - w1 * sf.sqrt(sf.Max(w2_discriminant, sf.sqrt(epsilon))) - xi + w2_discriminant = w1**2 * xi**2 - xi**2 + 1 + w2 = w1**2 * xi - w1 * sf.sqrt(sf.Max(w2_discriminant, sf.sqrt(epsilon))) - xi need_linear_constraint = sf.is_nonnegative(w2_discriminant) @@ -156,15 +156,15 @@ def camera_ray_from_pixel( # https://www.wolframalpha.com/input/?i=Plot%5Balpha+*+Sqrt%5B1+-+%282+*+alpha+-+1%29+*+r%5E2%5D+%2B+1+-+alpha%2C+%7Balpha%2C+-2%2C+1%7D%2C+%7Br%2C+0%2C+10%7D%5D m_z_denominator = alpha * sf.sqrt(sf.Max(m_z_discriminant, epsilon)) + 1 - alpha m_z_denominator_safe = m_z_denominator + sf.sign_no_zero(m_z_denominator) * epsilon - m_z = (1 - alpha ** 2 * r2) / m_z_denominator_safe + m_z = (1 - alpha**2 * r2) / m_z_denominator_safe # Compute the scalar multiplier on m (from eq 46) - m_scale_denominator = m_z ** 2 + r2 + m_scale_denominator = m_z**2 + r2 m_scale_denominator_safe = ( m_scale_denominator + sf.sign_no_zero(m_scale_denominator) * epsilon ) - m_scale_discriminant = m_z ** 2 + (1 - xi ** 2) * r2 + m_scale_discriminant = m_z**2 + (1 - xi**2) * r2 # NOTE(aaron): This additional check is always satisfied when xi is strictly between -1 and # 1, but we allow xi > 1, where this becomes necessary. The xi > 1 domain better fits some diff --git a/symforce/cam/polynomial_camera_cal.py b/symforce/cam/polynomial_camera_cal.py index 8b5d9ca4d..ca7a395a1 100644 --- a/symforce/cam/polynomial_camera_cal.py +++ b/symforce/cam/polynomial_camera_cal.py @@ -110,7 +110,7 @@ def _distortion_weight(self, undistorted_radius: T.Scalar) -> T.Scalar: total = 1.0 radius_term = 1.0 for coef in self.distortion_coeffs.to_flat_list(): - radius_term *= undistorted_radius ** 2 + radius_term *= undistorted_radius**2 total += radius_term * coef return total diff --git a/symforce/cam/spherical_camera_cal.py b/symforce/cam/spherical_camera_cal.py index 5c085a0b0..1b7a74786 100644 --- a/symforce/cam/spherical_camera_cal.py +++ b/symforce/cam/spherical_camera_cal.py @@ -182,7 +182,7 @@ def _radial_distortion(self, theta: sf.Symbol) -> sf.Symbol: acc = theta for coef in self.distortion_coeffs.to_flat_list(): - theta_term *= theta ** 2 + theta_term *= theta**2 acc += coef * theta_term return acc @@ -190,7 +190,6 @@ def _radial_distortion(self, theta: sf.Symbol) -> sf.Symbol: def pixel_from_camera_point( self, point: geo.Matrix31, epsilon: T.Scalar = sf.epsilon() ) -> T.Tuple[geo.Matrix21, T.Scalar]: - # compute theta xy_norm = point[:2, :].norm(epsilon) theta = sf.atan2(xy_norm, point[2], epsilon=0) diff --git a/symforce/codegen/backends/cpp/cpp_code_printer.py b/symforce/codegen/backends/cpp/cpp_code_printer.py index ac88e60fd..c13137f00 100644 --- a/symforce/codegen/backends/cpp/cpp_code_printer.py +++ b/symforce/codegen/backends/cpp/cpp_code_printer.py @@ -28,7 +28,7 @@ def __init__( super().__init__(settings) self.override_methods = override_methods or {} - for (expr, name) in self.override_methods.items(): + for expr, name in self.override_methods.items(): self._set_override_methods(expr, name) def _set_override_methods(self, expr: sympy.Function, name: str) -> None: diff --git a/symforce/codegen/backends/cuda/cuda_code_printer.py b/symforce/codegen/backends/cuda/cuda_code_printer.py index a4e66a4ea..52165a676 100644 --- a/symforce/codegen/backends/cuda/cuda_code_printer.py +++ b/symforce/codegen/backends/cuda/cuda_code_printer.py @@ -33,7 +33,7 @@ def __init__( super().__init__(dict(settings or {}, type_aliases={real: scalar_type.value})) self.override_methods = override_methods or {} - for (expr, name) in self.override_methods.items(): + for expr, name in self.override_methods.items(): self._set_override_methods(expr, name) def _set_override_methods(self, expr: sympy.Function, name: str) -> None: diff --git a/symforce/codegen/backends/pytorch/pytorch_code_printer.py b/symforce/codegen/backends/pytorch/pytorch_code_printer.py index 8c04c7537..940dcdad0 100644 --- a/symforce/codegen/backends/pytorch/pytorch_code_printer.py +++ b/symforce/codegen/backends/pytorch/pytorch_code_printer.py @@ -95,9 +95,7 @@ def _print_Mod(self, expr: sympy.Mod) -> str: def _print_sign(self, expr: sympy.sign) -> str: return f"torch.sign({self._print(expr.args[0])})" - def _print_Pow( - self, expr: sympy.Pow, rational: bool = False - ) -> str: # pylint: disable=unused-argument + def _print_Pow(self, expr: sympy.Pow, rational: bool = False) -> str: # pylint: disable=unused-argument # TODO(aaron): Optimize this? return f"torch.pow({self._print(expr.base)}, {self._print(expr.exp)})" diff --git a/symforce/codegen/codegen_config.py b/symforce/codegen/codegen_config.py index 66f627771..c84833b8a 100644 --- a/symforce/codegen/codegen_config.py +++ b/symforce/codegen/codegen_config.py @@ -37,7 +37,8 @@ class RenderTemplateConfig: Arguments to template_util.render_template Args: - autoformat: Run a code formatter on the generated code + autoformat: Run a code formatter on the generated code. [This option is deprecated - future + versions of SymForce will always autoformat generated code] custom_preamble: An optional string to be prepended on the front of the rendered template """ diff --git a/symforce/codegen/format_util.py b/symforce/codegen/format_util.py index 0def97c06..55660e5d2 100644 --- a/symforce/codegen/format_util.py +++ b/symforce/codegen/format_util.py @@ -3,29 +3,27 @@ # This source code is under the Apache 2.0 license found in the LICENSE file. # ---------------------------------------------------------------------------- -import copy import os +import shutil +import subprocess from pathlib import Path -import black +from ruff.__main__ import find_ruff_bin from symforce import python_util from symforce import typing as T -# TODO(aaron): Put this in a pyproject.toml and fetch from there -BLACK_FILE_MODE = black.FileMode(line_length=100) - def format_cpp(file_contents: str, filename: str) -> str: """ Autoformat a given C++ file using clang-format Args: - file_contents (str): The unformatted contents of the file - filename (str): A name that this file might have on disk; this does not have to be a real - path, it's only used for clang-format to find the correct style file (by traversing - upwards from this location) and to decide if an include is the corresponding .h file - for a .cc file that's being formatted (this affects the include order) + file_contents: The unformatted contents of the file + filename: A name that this file might have on disk; this does not have to be a real path, + it's only used for clang-format to find the correct style file (by traversing upwards + from this location) and to decide if an include is the corresponding .h file for a .cc + file that's being formatted (this affects the include order) Returns: formatted_file_contents (str): The contents of the file after formatting @@ -48,32 +46,68 @@ def format_cpp(file_contents: str, filename: str) -> str: return formatted_file_contents -def format_py(file_contents: str) -> str: +_ruff_path: T.Optional[Path] = None + + +def _find_ruff() -> Path: """ - Autoformat a given Python file using black + Find the ruff binary + + `find_ruff_bin` does not work in all environments, for example it does not work on debian when + things are installed in `/usr/local/bin` and `sysconfig` only returns `/usr/bin`. Adding + `shutil.which` should cover most cases, but not all, the better solution would require `ruff` + putting the binary in `data` like `clang-format` does """ - return black.format_str(file_contents, mode=BLACK_FILE_MODE) + global _ruff_path # pylint: disable=global-statement + + if _ruff_path is not None: + return _ruff_path + + try: + ruff = find_ruff_bin() + except FileNotFoundError as ex: + ruff = shutil.which("ruff") + if ruff is None: + raise FileNotFoundError("Could not find ruff") from ex + _ruff_path = ruff -def format_pyi(file_contents: str) -> str: + return ruff + + +def format_py(file_contents: str, filename: str) -> str: """ - Autoformat a given Python interface file using black + Autoformat a given Python file using ruff + + Args: + filename: A name that this file might have on disk; this does not have to be a real path, + it's only used for ruff to find the correct style file (by traversing upwards from this + location) """ - mode = copy.copy(BLACK_FILE_MODE) - mode.is_pyi = True - return black.format_str(file_contents, mode=mode) + result = subprocess.run( + [_find_ruff(), "format", f"--stdin-filename={filename}", "-"], + input=file_contents, + stdout=subprocess.PIPE, + check=True, + # Disable the ruff cache. This is important for running in a hermetic context like a bazel + # test, and shouldn't really hurt other use cases. If it does, we should work around this + # differently. + env=dict(os.environ, RUFF_NO_CACHE="true"), + text=True, + ) + return result.stdout def format_py_dir(dirname: T.Openable) -> None: """ Autoformat python files in a directory (recursively) in-place """ - for root, _, files in os.walk(dirname): - for filename in files: - if filename.endswith(".py"): - black.format_file_in_place( - Path(dirname) / root / filename, - fast=True, - mode=BLACK_FILE_MODE, - write_back=black.WriteBack.YES, - ) + subprocess.run( + [_find_ruff(), "format", dirname], + check=True, + # Disable the ruff cache. This is important for running in a hermetic context like a bazel + # test, and shouldn't really hurt other use cases. If it does, we should work around this + # differently. + env=dict(os.environ, RUFF_NO_CACHE="true"), + text=True, + ) diff --git a/symforce/codegen/geo_factors_codegen.py b/symforce/codegen/geo_factors_codegen.py index deea6fafd..ab44607bb 100644 --- a/symforce/codegen/geo_factors_codegen.py +++ b/symforce/codegen/geo_factors_codegen.py @@ -29,9 +29,7 @@ def get_between_factor_docstring(between_argument_name: str) -> str: sqrt_info: Square root information matrix to whiten residual. This can be computed from a covariance matrix as the cholesky decomposition of the inverse. In the case of a diagonal it will contain 1/sigma values. Must match the tangent dim. - """.format( - a_T_b=between_argument_name - ) + """.format(a_T_b=between_argument_name) def get_prior_docstring() -> str: diff --git a/symforce/codegen/slam_factors_codegen.py b/symforce/codegen/slam_factors_codegen.py index c259fc732..43a6cc43f 100644 --- a/symforce/codegen/slam_factors_codegen.py +++ b/symforce/codegen/slam_factors_codegen.py @@ -209,7 +209,7 @@ def inverse_range_landmark_gnc_residual( """ noise_model = BarronNoiseModel( alpha=BarronNoiseModel.compute_alpha_from_mu(gnc_mu, epsilon), - scalar_information=1 / gnc_scale ** 2, + scalar_information=1 / gnc_scale**2, x_epsilon=epsilon, ) @@ -390,7 +390,7 @@ def inverse_range_landmark_ray_gnc_residual( noise_model = BarronNoiseModel( alpha=BarronNoiseModel.compute_alpha_from_mu(mu=gnc_mu, epsilon=epsilon), - scalar_information=1 / gnc_scale ** 2, + scalar_information=1 / gnc_scale**2, x_epsilon=epsilon, ) @@ -447,9 +447,7 @@ def generate(output_dir: Path, config: codegen.CodegenConfig = None) -> None: config=config, ).with_linearization( which_args=["source_pose", "target_pose", "source_inverse_range"] - ).generate_function( - output_dir=factors_dir, skip_directory_nesting=True - ) + ).generate_function(output_dir=factors_dir, skip_directory_nesting=True) codegen.Codegen.function( func=specialize_cam(reprojection_delta), @@ -466,9 +464,7 @@ def generate(output_dir: Path, config: codegen.CodegenConfig = None) -> None: config=config, ).with_linearization( which_args=["source_pose", "target_pose", "source_inverse_range"] - ).generate_function( - output_dir=factors_dir, skip_directory_nesting=True - ) + ).generate_function(output_dir=factors_dir, skip_directory_nesting=True) codegen.Codegen.function( func=specialize_cam(ray_reprojection_delta), diff --git a/symforce/codegen/template_util.py b/symforce/codegen/template_util.py index ac4d3ca8f..ce9df3c98 100644 --- a/symforce/codegen/template_util.py +++ b/symforce/codegen/template_util.py @@ -10,6 +10,7 @@ import functools import os import textwrap +import warnings from pathlib import Path import jinja2 @@ -78,25 +79,23 @@ def autoformat( """ Format code of this file type. """ + # Come up with a fake filename to give to the formatter just for formatting purposes, even + # if this isn't being written to disk + if output_path is not None: + format_filename = os.path.basename(output_path) + else: + format_filename = str(template_name).replace(".jinja", "") + # TODO(hayk): Move up to language-specific config or printer. This is quite an awkward # place for auto-format logic, but I thought it was better centralized here than down below # hidden in a function. We might want to somehow pass the config through to render a # template so we can move things into the backend code. (tag=centralize-language-diffs) if self in (FileType.CPP, FileType.CUDA): - # Come up with a fake filename to give to the formatter just for formatting purposes, - # even if this isn't being written to disk - if output_path is not None: - format_cpp_filename = os.path.basename(output_path) - else: - format_cpp_filename = os.fspath(template_name).replace(".jinja", "") - return format_util.format_cpp( - file_contents, filename=str(CURRENT_DIR / format_cpp_filename) + file_contents, filename=str(CURRENT_DIR / format_filename) ) - elif self == FileType.PYTHON: - return format_util.format_py(file_contents) - elif self == FileType.PYTHON_INTERFACE: - return format_util.format_pyi(file_contents) + elif self in (FileType.PYTHON, FileType.PYTHON_INTERFACE): + return format_util.format_py(file_contents, filename=str(CURRENT_DIR / format_filename)) elif self == FileType.LCM: return file_contents else: @@ -202,6 +201,11 @@ def render_template( template_name=template_path, output_path=output_path, ) + else: + warnings.warn( + "Config.autoformat == False is deprecated, this option will be removed in a future release", + DeprecationWarning, + ) if output_path: output_path = Path(output_path) diff --git a/symforce/codegen/types_package_codegen.py b/symforce/codegen/types_package_codegen.py index 624bbfe3f..cf6bebb90 100644 --- a/symforce/codegen/types_package_codegen.py +++ b/symforce/codegen/types_package_codegen.py @@ -236,7 +236,7 @@ def typename_from_key(key: str, shared_types: T.Mapping[str, str]) -> str: def get_subvalues_from_list_index( - list_index: T.Dict[str, IndexEntry] + list_index: T.Dict[str, IndexEntry], ) -> T.Optional[T.Dict[str, IndexEntry]]: """ Returns index of :class:`Values ` object if base element of list is a diff --git a/symforce/geo/complex.py b/symforce/geo/complex.py index 2b18e290a..5999f9c52 100644 --- a/symforce/geo/complex.py +++ b/symforce/geo/complex.py @@ -109,7 +109,7 @@ def squared_norm(self) -> T.Scalar: Returns: Scalar: real**2 + imag**2 """ - return self.real ** 2 + self.imag ** 2 + return self.real**2 + self.imag**2 def __mul__(self, right: Complex) -> Complex: """ diff --git a/symforce/geo/matrix.py b/symforce/geo/matrix.py index f93a821d1..f085b5577 100644 --- a/symforce/geo/matrix.py +++ b/symforce/geo/matrix.py @@ -598,7 +598,7 @@ def clamp_norm( ) squared_norm = self.squared_norm() + epsilon - max_squared_norm = max_norm ** 2 + max_squared_norm = max_norm**2 # This sqrt can be near 0, if max_norm can be exactly 0 return self * sf.Min(1, sf.sqrt(max_squared_norm / squared_norm)) @@ -854,7 +854,7 @@ def are_parallel(a: Vector3, b: Vector3, tolerance: _T.Scalar) -> _T.Scalar: """ Returns 1 if a and b are parallel within tolerance, and 0 otherwise. """ - return (1 - sf.sign(a.cross(b).squared_norm() - tolerance ** 2)) / 2 + return (1 - sf.sign(a.cross(b).squared_norm() - tolerance**2)) / 2 @staticmethod def skew_symmetric(a: Vector3) -> Matrix33: diff --git a/symforce/geo/quaternion.py b/symforce/geo/quaternion.py index a72ec91e1..82507c24f 100644 --- a/symforce/geo/quaternion.py +++ b/symforce/geo/quaternion.py @@ -159,7 +159,7 @@ def squared_norm(self) -> T.Scalar: Returns: Scalar: """ - return self.xyz.dot(self.xyz) + self.w ** 2 + return self.xyz.dot(self.xyz) + self.w**2 def conj(self) -> Quaternion: """ diff --git a/symforce/geo/rot3.py b/symforce/geo/rot3.py index be59e096b..fccb9dffa 100644 --- a/symforce/geo/rot3.py +++ b/symforce/geo/rot3.py @@ -82,7 +82,7 @@ def tangent_dim(cls) -> int: def from_tangent(cls, v: T.Sequence[T.Scalar], epsilon: T.Scalar = sf.epsilon()) -> Rot3: vm = Matrix(v) theta_sq = vm.squared_norm() - theta = sf.sqrt(theta_sq + epsilon ** 2) + theta = sf.sqrt(theta_sq + epsilon**2) assert theta != 0, "Trying to divide by zero, provide epsilon!" return cls(Quaternion(xyz=sf.sin(theta / 2) / theta * vm, w=sf.cos(theta / 2))) @@ -95,7 +95,7 @@ def to_tangent(self, epsilon: T.Scalar = sf.epsilon()) -> T.List[T.Scalar]: w_positive = sf.Abs(self.q.w) w_safe = sf.Min(1 - epsilon, w_positive) xyz_w_positive = self.q.xyz * sf.sign_no_zero(self.q.w) - norm = sf.sqrt(1 - w_safe ** 2) + norm = sf.sqrt(1 - w_safe**2) tangent = 2 * xyz_w_positive / norm * sf.acos(w_safe) return tangent.to_storage() @@ -156,19 +156,19 @@ def to_rotation_matrix(self) -> Matrix33: return Matrix33( [ [ - 1 - 2 * self.q.y ** 2 - 2 * self.q.z ** 2, + 1 - 2 * self.q.y**2 - 2 * self.q.z**2, 2 * self.q.x * self.q.y - 2 * self.q.z * self.q.w, 2 * self.q.x * self.q.z + 2 * self.q.y * self.q.w, ], [ 2 * self.q.x * self.q.y + 2 * self.q.z * self.q.w, - 1 - 2 * self.q.x ** 2 - 2 * self.q.z ** 2, + 1 - 2 * self.q.x**2 - 2 * self.q.z**2, 2 * self.q.y * self.q.z - 2 * self.q.x * self.q.w, ], [ 2 * self.q.x * self.q.z - 2 * self.q.y * self.q.w, 2 * self.q.y * self.q.z + 2 * self.q.x * self.q.w, - 1 - 2 * self.q.x ** 2 - 2 * self.q.y ** 2, + 1 - 2 * self.q.x**2 - 2 * self.q.y**2, ], ] ) diff --git a/symforce/geo/unsupported/pose3_se3.py b/symforce/geo/unsupported/pose3_se3.py index f573264e7..436cd3b94 100644 --- a/symforce/geo/unsupported/pose3_se3.py +++ b/symforce/geo/unsupported/pose3_se3.py @@ -49,12 +49,12 @@ def from_tangent(cls, v: T.Sequence[T.Scalar], epsilon: T.Scalar = sf.epsilon()) R_hat = Rot3.hat(R_tangent) R_hat_sq = R_hat * R_hat R_tangent_vector = Vector3(R_tangent) - theta = sf.sqrt(R_tangent_vector.squared_norm() + epsilon ** 2) + theta = sf.sqrt(R_tangent_vector.squared_norm() + epsilon**2) V = ( Matrix.eye(3) - + (1 - sf.cos(theta)) / (theta ** 2) * R_hat - + (theta - sf.sin(theta)) / (theta ** 3) * R_hat_sq + + (1 - sf.cos(theta)) / (theta**2) * R_hat + + (theta - sf.sin(theta)) / (theta**3) * R_hat_sq ) return cls(R, V * t_tangent_vector) diff --git a/symforce/internal/symbolic.py b/symforce/internal/symbolic.py index 54c01a8a7..88af56365 100644 --- a/symforce/internal/symbolic.py +++ b/symforce/internal/symbolic.py @@ -573,7 +573,10 @@ def simplify(*args: T.Any, **kwargs: T.Any) -> Scalar: import sympy as _sympy_py def limit( - e: T.Any, z: T.Any, z0: T.Any, dir: str = "+" # pylint: disable=redefined-builtin + e: T.Any, + z: T.Any, + z0: T.Any, + dir: str = "+", # pylint: disable=redefined-builtin ) -> Scalar: logger.warning("Converting to sympy to use .limit") return sympy.S(_sympy_py.limit(_sympy_py.S(e), _sympy_py.S(z), _sympy_py.S(z0), dir=dir)) @@ -659,7 +662,7 @@ def mod_derivative(self: T.Any, x: T.Any) -> T.Any: def _flatten_storage_type_subs( - subs_pairs: T.Sequence[T.Tuple[T.Any, T.Any]] + subs_pairs: T.Sequence[T.Tuple[T.Any, T.Any]], ) -> T.Dict[T.Any, T.Any]: """ Replace storage types with their scalar counterparts diff --git a/symforce/opt/factor.py b/symforce/opt/factor.py index b71e5a6fc..2a2dccd7b 100644 --- a/symforce/opt/factor.py +++ b/symforce/opt/factor.py @@ -37,8 +37,7 @@ class Factor: residual: The residual function for the factor. When passed symbolic inputs, this should return a symbolic expression for the residual. config: The language the numeric factor will be generated in. Defaults to Python, which - does not require any compilation. Also does not autoformat by default in order to - speed up code generation. + does not require any compilation. custom_jacobian_func: A functor that computes the jacobian, typically unnecessary unless you want to override the jacobian computed by SymForce, e.g. to stop derivatives with respect to certain variables or directions, or because the jacobian can be @@ -59,12 +58,9 @@ def default_codegen_config() -> PythonConfig: The default codegen config used by the Factor class This is a PythonConfig with settings appropriate for converting to a - :class:`.numeric_factor.NumericFactor` (no autoformat, return 2d vectors). + :class:`.numeric_factor.NumericFactor` (returns 2d vectors). """ - return PythonConfig( - render_template_config=codegen_config.RenderTemplateConfig(autoformat=False), - return_2d_vectors=True, - ) + return PythonConfig(return_2d_vectors=True) def __init__( self, @@ -110,8 +106,7 @@ def from_inputs_and_residual( inputs: The inputs Values for the factor. residual: An expression representing the residual of the factor. config: The language the numeric factor will be generated in. Defaults to Python, which - does not require any compilation. Also does not autoformat by default in order to - speed up code generation. + does not require any compilation. custom_jacobian_func: A functor that computes the jacobian, typically unnecessary unless you want to override the jacobian computed by SymForce, e.g. to stop derivatives with respect to certain variables or directions, or because the jacobian can be diff --git a/symforce/opt/noise_models.py b/symforce/opt/noise_models.py index f6e9f1933..9a161e02d 100644 --- a/symforce/opt/noise_models.py +++ b/symforce/opt/noise_models.py @@ -295,7 +295,7 @@ def pseudo_huber_error(self, x: sf.Scalar) -> sf.Scalar: Args: x: argument to return the cost for. """ - return self.delta ** 2 * (sf.sqrt(1 + self.scalar_information * (x / self.delta) ** 2) - 1) + return self.delta**2 * (sf.sqrt(1 + self.scalar_information * (x / self.delta) ** 2) - 1) def whiten_scalar(self, x: sf.Scalar, bounded_away_from_zero: bool = False) -> sf.Scalar: """ @@ -408,7 +408,7 @@ def barron_error(self, x: sf.Scalar) -> sf.Scalar: b = sf.Abs(self.alpha - 2) + self.alpha_epsilon d = self.alpha + (sf.sign_no_zero(self.alpha) * self.alpha_epsilon) return ( - self.delta ** 2 + self.delta**2 * (b / d) * (((self.scalar_information * (x / self.delta) ** 2) / b + 1) ** (d / 2) - 1) ) diff --git a/symforce/opt/optimizer.py b/symforce/opt/optimizer.py index 9daebc3c5..9ee314c27 100644 --- a/symforce/opt/optimizer.py +++ b/symforce/opt/optimizer.py @@ -217,7 +217,6 @@ def __init__( debug_stats: bool = False, include_jacobians: bool = False, ): - if optimized_keys is None: # This will be filled with the optimized keys of the numeric factors self.optimized_keys = [] diff --git a/symforce/pybind/cc_sym.pyi b/symforce/pybind/cc_sym.pyi index 90cc12b94..37acf2635 100644 --- a/symforce/pybind/cc_sym.pyi +++ b/symforce/pybind/cc_sym.pyi @@ -56,7 +56,6 @@ class Factor: Created from a function and a set of Keys that act as inputs. Given a Values as an evaluation point, generates a linear approximation to the residual function. """ - @typing.overload def __init__( self, @@ -169,7 +168,6 @@ class Key: """ Key type for Values. Contains a letter plus an integral subscript and superscript. Can construct with a letter, a letter + sub, or a letter + sub + super, but not a letter + super. """ - def __eq__(self, arg0: object) -> bool: ... def __getstate__(self) -> tuple: ... def __hash__(self) -> int: ... @@ -228,7 +226,6 @@ class Linearization: """ Class for storing a problem linearization evaluated at a Values (i.e. a residual, jacobian, hessian, and rhs). """ - def __getstate__(self) -> tuple: ... def __init__(self) -> None: ... def __setstate__(self, arg0: tuple) -> None: ... @@ -281,7 +278,6 @@ class OptimizationStats: """ Debug stats for a full optimization run. """ - def __getstate__(self) -> tuple: ... def __init__(self) -> None: ... def __setstate__(self, arg0: tuple) -> None: ... @@ -384,7 +380,6 @@ class Optimizer: """ Class for optimizing a nonlinear least-squares problem specified as a list of Factors. For efficient use, create once and call Optimize() multiple times with different initial guesses, as long as the factors remain constant and the structure of the Values is identical. """ - def __init__( self, params: optimizer_params_t, @@ -526,7 +521,6 @@ class Values: Compatible types are given by the type_t enum. All types implement the StorageOps and LieGroupOps concepts, which are the core operating mechanisms in this class. """ - def __getstate__(self) -> bytes: ... @typing.overload def __init__(self) -> None: diff --git a/symforce/slam/imu_preintegration/generate.py b/symforce/slam/imu_preintegration/generate.py index a0ef7b65f..92c5f52fe 100644 --- a/symforce/slam/imu_preintegration/generate.py +++ b/symforce/slam/imu_preintegration/generate.py @@ -131,9 +131,7 @@ def generate_manifold_imu_preintegration( "gyro_bias_i", "gravity", ] - ).generate_function( - output_dir=output_dir, skip_directory_nesting=True - ) + ).generate_function(output_dir=output_dir, skip_directory_nesting=True) codegen.Codegen.function(internal_imu_unit_gravity_residual, config=config).with_linearization( which_args=[ diff --git a/symforce/slam/imu_preintegration/manifold_symbolic.py b/symforce/slam/imu_preintegration/manifold_symbolic.py index bc3898138..439e07549 100644 --- a/symforce/slam/imu_preintegration/manifold_symbolic.py +++ b/symforce/slam/imu_preintegration/manifold_symbolic.py @@ -90,7 +90,7 @@ def internal_imu_residual( res_R = (corrected_DR.inverse() * pose_i.R.inverse() * pose_j.R).to_tangent(epsilon) res_v = pose_i.R.inverse() * (vel_j - vel_i - gravity * dt) - corrected_Dv res_p = ( - pose_i.R.inverse() * (pose_j.t - pose_i.t - vel_i * dt - sf.S(1) / 2 * gravity * dt ** 2) + pose_i.R.inverse() * (pose_j.t - pose_i.t - vel_i * dt - sf.S(1) / 2 * gravity * dt**2) - corrected_Dp ) @@ -111,8 +111,8 @@ def _right_jacobian(tangent: sf.V3, epsilon: T.Scalar) -> sf.M33: norm = tangent.norm(sf.sqrt(epsilon)) tangent_hat = sf.Matrix.skew_symmetric(tangent) out = sf.M33.eye() - out -= ((1 - sf.cos(norm)) / (norm ** 2)) * tangent_hat - out += ((norm - sf.sin(norm)) / (norm ** 3)) * (tangent_hat * tangent_hat) + out -= ((1 - sf.cos(norm)) / (norm**2)) * tangent_hat + out += ((norm - sf.sin(norm)) / (norm**3)) * (tangent_hat * tangent_hat) return out @@ -344,6 +344,6 @@ def integrate_state( """ new_DR = DR * sf.Rot3.from_tangent(gyro * dt, epsilon) new_Dv = Dv + DR * accel * dt - new_Dp = Dp + Dv * dt + DR * accel * dt ** 2 / 2 + new_Dp = Dp + Dv * dt + DR * accel * dt**2 / 2 return new_DR, new_Dv, new_Dp diff --git a/symforce/test_util/backend_coverage_expressions.py b/symforce/test_util/backend_coverage_expressions.py index 36365dbf0..ccb97ea3d 100644 --- a/symforce/test_util/backend_coverage_expressions.py +++ b/symforce/test_util/backend_coverage_expressions.py @@ -68,11 +68,11 @@ def backend_test_function(x: sf.Scalar, y: sf.Scalar) -> T.Tuple[sf.Scalar, ...] lambda x: sf.Mod(x, 5.5), lambda x: x + 1, lambda x: 2 * x, - lambda x: x ** 2, - lambda x: x ** 3, - lambda x: x ** 4, - lambda x: x ** 5, - lambda x: x ** sf.S.Half, + lambda x: x**2, + lambda x: x**3, + lambda x: x**4, + lambda x: x**5, + lambda x: x**sf.S.Half, lambda x: x ** sf.Rational(3, 2), lambda x: sf.Max(0, x).diff(x), # The heaviside function ) @@ -84,7 +84,7 @@ def backend_test_function(x: sf.Scalar, y: sf.Scalar) -> T.Tuple[sf.Scalar, ...] sf.Mod, lambda x, y: x + y, lambda x, y: x * y, - lambda x, y: x ** y, + lambda x, y: x**y, lambda x, y: (x + y) ** 2, lambda x, y: (x + y) ** 3, ) diff --git a/symforce/test_util/random_expressions/op_probabilities.py b/symforce/test_util/random_expressions/op_probabilities.py index 256b4e285..4cfd97cad 100644 --- a/symforce/test_util/random_expressions/op_probabilities.py +++ b/symforce/test_util/random_expressions/op_probabilities.py @@ -41,8 +41,8 @@ def arity(self) -> int: OpProbability("sin", sf.sin, 0.5), OpProbability("cos", sf.cos, 0.5), OpProbability("tan", sf.tan, 0.3), - OpProbability("pow2", lambda x: x ** 2, 3), - OpProbability("pow3", lambda x: x ** 3, 1), + OpProbability("pow2", lambda x: x**2, 3), + OpProbability("pow3", lambda x: x**3, 1), OpProbability("asin", sf.asin_safe, 0.2), OpProbability("acos", sf.acos_safe, 0.2), OpProbability("atan", sf.atan, 0.1), @@ -53,7 +53,7 @@ def arity(self) -> int: OpProbability("sub", lambda x, y: x - y, 2), OpProbability("mul", lambda x, y: x * y, 5), OpProbability("div", lambda x, y: x / y, 1), - OpProbability("pow", lambda x, y: x ** y, 0.5), + OpProbability("pow", lambda x, y: x**y, 0.5), OpProbability("atan2", sf.atan2, 0.2), ) diff --git a/symforce/test_util/random_expressions/unary_binary_expression_gen.py b/symforce/test_util/random_expressions/unary_binary_expression_gen.py index 2cdbfbb28..fd357ddd2 100644 --- a/symforce/test_util/random_expressions/unary_binary_expression_gen.py +++ b/symforce/test_util/random_expressions/unary_binary_expression_gen.py @@ -101,7 +101,7 @@ def generate_D( # enumerate possible trees # first generate the tranposed version of D, then transpose it - D = [np.array([0] + ([num_leaves ** e for e in range(1, 2 * max_ops + 1)]))] + D = [np.array([0] + ([num_leaves**e for e in range(1, 2 * max_ops + 1)]))] for n in range(1, max_ops + 1): # number of operators D.append(UnaryBinaryExpressionGen._next_row_of_D(num_leaves, max_ops, n, D[-1], p1, p2)) @@ -127,9 +127,9 @@ def sample_next_pos( probs: T.List[float] = [] for i in range(nb_empty): - probs.append((num_leaves ** i) * p1 * self.D[nb_empty - i][nb_ops - 1]) + probs.append((num_leaves**i) * p1 * self.D[nb_empty - i][nb_ops - 1]) for i in range(nb_empty): - probs.append((num_leaves ** i) * p2 * self.D[nb_empty - i + 1][nb_ops - 1]) + probs.append((num_leaves**i) * p2 * self.D[nb_empty - i + 1][nb_ops - 1]) np_probs = np.array([p / self.D[nb_empty][nb_ops] for p in probs], dtype=np.float64) @@ -191,7 +191,7 @@ def seq_to_expr(self, seq: T.Sequence[T.Union[str, sf.Scalar]]) -> sf.Expr: """ def _seq_to_expr( - seq: T.Sequence[T.Union[str, sf.Scalar]] + seq: T.Sequence[T.Union[str, sf.Scalar]], ) -> T.Tuple[sf.Scalar, T.Sequence[T.Union[str, sf.Scalar]]]: assert len(seq) > 0 t = seq[0] diff --git a/symforce/test_util/test_case.py b/symforce/test_util/test_case.py index 661996614..cefef25c0 100644 --- a/symforce/test_util/test_case.py +++ b/symforce/test_util/test_case.py @@ -25,7 +25,6 @@ class TestCase(SymforceTestCaseMixin): @staticmethod def should_run_slow_tests() -> bool: - # NOTE(aaron): This needs to be accessible before main() is called, so we do it here # instead. This should also be called from main to make sure it runs at least once if "--run_slow_tests" in sys.argv: diff --git a/symforce/values/values.py b/symforce/values/values.py index 59fa0ff19..dca833ec4 100644 --- a/symforce/values/values.py +++ b/symforce/values/values.py @@ -146,7 +146,6 @@ def get_index_from_items(items: T.Iterable[T.Tuple[str, T.Any]]) -> T.Dict[str, offset = 0 index_dict = collections.OrderedDict() for name, value in items: - entry_helper = lambda datatype=type( value ), shape=None, item_index=None, curr_offset=offset, curr_value=value: IndexEntry( diff --git a/test/cam_double_sphere_test.py b/test/cam_double_sphere_test.py index 6b089303c..450f583d4 100644 --- a/test/cam_double_sphere_test.py +++ b/test/cam_double_sphere_test.py @@ -120,7 +120,7 @@ def pixel_from_radius(radius: float) -> sf.V2: Generate a pixel a given radius away from the principal point, at a random angle """ return ( - (sf.Rot2.from_tangent([np.random.uniform(0, 2 * np.pi)]) * sf.V2(radius, 0)) + sf.Rot2.from_tangent([np.random.uniform(0, 2 * np.pi)]) * sf.V2(radius, 0) ) + sf.V2(400, 400) def check_backward_is_valid_on_boundary(xi: float, alpha: float, radius: float) -> None: diff --git a/test/cam_package_python_test.py b/test/cam_package_python_test.py index a7df886be..c69b93c0f 100644 --- a/test/cam_package_python_test.py +++ b/test/cam_package_python_test.py @@ -43,7 +43,7 @@ def cam_cal_from_points(cam_cls, focal_length, principal_point): return cam_cls( focal_length=focal_length, principal_point=principal_point, - **CamPackageTest._DISTORTION_COEFF_VALS.get(cam_cls.__name__, {}) + **CamPackageTest._DISTORTION_COEFF_VALS.get(cam_cls.__name__, {}), ) def test_getters_ATANCameraCal(self): diff --git a/test/count_ops_test.py b/test/count_ops_test.py index 2fbcb56ed..b2def298d 100644 --- a/test/count_ops_test.py +++ b/test/count_ops_test.py @@ -52,8 +52,8 @@ def test_division(self) -> None: self.assertEqual(2, sf.count_ops(1 / (x * y))) with self.subTest(msg=f"{sf.__name__} handles exponents properly"): - self.assertEqual(1, sf.count_ops(x * y ** 1)) - self.assertEqual(2, sf.count_ops(x * y ** 2)) + self.assertEqual(1, sf.count_ops(x * y**1)) + self.assertEqual(2, sf.count_ops(x * y**2)) self.assertEqual(2, sf.count_ops(x * y ** (-2))) def test_constants(self) -> None: diff --git a/test/geo_matrix_test.py b/test/geo_matrix_test.py index c27692d26..e28f2d0f5 100644 --- a/test/geo_matrix_test.py +++ b/test/geo_matrix_test.py @@ -172,7 +172,7 @@ def test_symbolic_operations(self) -> None: ) x = sf.Symbol("x") - unsimple_matrix = sf.Matrix([x ** 2 - x, 0]) + unsimple_matrix = sf.Matrix([x**2 - x, 0]) simple_matrix = sf.Matrix([x * (x - 1), 0]) self.assertEqual(unsimple_matrix.simplify(), simple_matrix) diff --git a/test/geo_scalar_test.py b/test/geo_scalar_test.py index bd0e340d0..2d5dfe2e3 100644 --- a/test/geo_scalar_test.py +++ b/test/geo_scalar_test.py @@ -25,7 +25,7 @@ def test_construction_by_type(self) -> None: Check that we get correct types out from scalar expressions of various forms. """ x, y = sf.symbols("x y") - scalars = (12, -1.3, sf.S(4), sf.S(12.5), np.double(5.5), x, x ** 2 + y) + scalars = (12, -1.3, sf.S(4), sf.S(12.5), np.double(5.5), x, x**2 + y) for scalar in scalars: scalar_type = type(scalar) from_storage = ops.StorageOps.from_storage(scalar_type, [scalar]) diff --git a/test/symforce_cc_sym_test.py b/test/symforce_cc_sym_test.py index 51df67fb6..48f6cd746 100644 --- a/test/symforce_cc_sym_test.py +++ b/test/symforce_cc_sym_test.py @@ -439,7 +439,7 @@ def pi_residual( # Output terms res = [cos] jacobian = [-sin_2] - hessian = [(1.0 / 4.0) * sin ** 2] + hessian = [(1.0 / 4.0) * sin**2] rhs = [-cos * sin_2] return res, jacobian, hessian, rhs @@ -604,7 +604,6 @@ def compare_linearizations(lin1: cc_sym.Linearization, lin2: cc_sym.Linearizatio def compare_optimization_stats( stats1: cc_sym.OptimizationStats, stats2: cc_sym.OptimizationStats ) -> bool: - TVar = T.TypeVar("TVar") # NOTE(brad): Exists to make mypy happy @@ -658,7 +657,6 @@ def test_optimization_stats(self) -> None: self.assertIsInstance(stats.get_lcm_type(), optimization_stats_t) with self.subTest(msg="Can pickle cc_sym.OptimizationStats"): - stats = cc_sym.OptimizationStats() stats.iterations = [optimization_iteration_t(iteration=i) for i in range(4)] stats.best_index = 1 @@ -809,7 +807,6 @@ def test_optimizer(self) -> None: lin.linear_error(np.array([0.01])) with self.subTest(msg="cc_sym.Linearization is pickleable"): - linearization = cc_sym.Linearization() linearization.residual = np.array([1, 2, 3]) linearization.jacobian = sparse.csc_matrix([[1, 2], [3, 4], [5, 6]]) diff --git a/test/symforce_codegen_test.py b/test/symforce_codegen_test.py index 0c20dc41e..e7f55bf68 100644 --- a/test/symforce_codegen_test.py +++ b/test/symforce_codegen_test.py @@ -36,6 +36,7 @@ / symforce.get_symbolic_api() ) + # Test function def az_el_from_point( nav_T_cam: sf.Pose3, nav_t_point: sf.Vector3, epsilon: sf.Scalar = 0 @@ -117,8 +118,8 @@ def build_values() -> T.Tuple[Values, Values]: # inputs.add(sf.Symbol('q(0)')) outputs = Values() - outputs["foo"] = x ** 2 + inputs["rot"].q.w - outputs["bar"] = inputs.attr.constants.epsilon + sf.sin(inputs.attr.y) + x ** 2 + outputs["foo"] = x**2 + inputs["rot"].q.w + outputs["bar"] = inputs.attr.constants.epsilon + sf.sin(inputs.attr.y) + x**2 # Test outputing lists of objects, scalars, and Values outputs["scalar_vec_out"] = ops.GroupOps.compose(inputs["scalar_vec"], inputs["scalar_vec"]) outputs["values_vec_out"] = ops.GroupOps.compose(inputs["values_vec"], inputs["values_vec"]) @@ -209,8 +210,8 @@ def test_codegen_python(self) -> None: big_matrix, states, ) - self.assertStorageNear(foo, x ** 2 + rot.data[3]) - self.assertStorageNear(bar, constants.epsilon + sf.sin(y) + x ** 2) + self.assertStorageNear(foo, x**2 + rot.data[3]) + self.assertStorageNear(bar, constants.epsilon + sf.sin(y) + x**2) def test_matrix_order_python(self) -> None: """ @@ -927,7 +928,7 @@ def test_with_jacobians_values(self) -> None: outputs = Values( a_out=inputs.attr.a * sf.V3(0, 0, inputs.attr.b), - b_out=inputs.attr.c.norm(epsilon=0) + inputs.attr.b ** 2, + b_out=inputs.attr.c.norm(epsilon=0) + inputs.attr.b**2, c_out=(inputs.attr.d.x * sf.V2(1, 1) + inputs.attr.d.y).T * sf.M22(((1, 2), (3, 4))), d_out=Values(x=3, y=inputs.attr.a.q.w + inputs.attr.b), ) diff --git a/test/symforce_cpp_code_printer_codegen_test.py b/test/symforce_cpp_code_printer_codegen_test.py index 70e8df2ca..fa96fa627 100644 --- a/test/symforce_cpp_code_printer_codegen_test.py +++ b/test/symforce_cpp_code_printer_codegen_test.py @@ -34,13 +34,13 @@ def test_max_min(self) -> None: a = sf.Symbol("a") b = sf.Symbol("b") - expr: sf.Expr = sf.Max(a ** 2, b ** 2) + expr: sf.Expr = sf.Max(a**2, b**2) self.assertEqual( printer.doprint(expr), "std::max(std::pow(a, Scalar(2)), std::pow(b, Scalar(2)))", ) - expr = sf.Min(a ** 2, b ** 2) + expr = sf.Min(a**2, b**2) self.assertEqual( printer.doprint(expr), "std::min(std::pow(a, Scalar(2)), std::pow(b, Scalar(2)))", diff --git a/test/symforce_function_codegen_test_data/symengine/az_el_from_point.py b/test/symforce_function_codegen_test_data/symengine/az_el_from_point.py index f9cb1d2bc..d5a8d98df 100644 --- a/test/symforce_function_codegen_test_data/symengine/az_el_from_point.py +++ b/test/symforce_function_codegen_test_data/symengine/az_el_from_point.py @@ -94,7 +94,7 @@ def az_el_from_point(nav_T_cam, nav_t_point, epsilon): _tmp11, _tmp18 + epsilon * ((0.0 if _tmp18 == 0 else math.copysign(1, _tmp18)) + 0.5) ) _res[1] = ( - -math.acos(_tmp22 / math.sqrt(_tmp11 ** 2 + _tmp18 ** 2 + _tmp22 ** 2 + epsilon)) + -math.acos(_tmp22 / math.sqrt(_tmp11**2 + _tmp18**2 + _tmp22**2 + epsilon)) + (1.0 / 2.0) * math.pi ) return _res diff --git a/test/symforce_function_codegen_test_data/symengine/codegen_python_test_data/python/symforce/codegen_python_test/python_function.py b/test/symforce_function_codegen_test_data/symengine/codegen_python_test_data/python/symforce/codegen_python_test/python_function.py index 7d939d771..bccd0e914 100644 --- a/test/symforce_function_codegen_test_data/symengine/codegen_python_test_data/python/symforce/codegen_python_test/python_function.py +++ b/test/symforce_function_codegen_test_data/symengine/codegen_python_test_data/python/symforce/codegen_python_test/python_function.py @@ -58,7 +58,7 @@ def python_function( _rot = rot.data # Intermediate terms (66) - _tmp0 = x ** 2 + _tmp0 = x**2 _tmp1 = 2 * values_vec[0].rot.data[3] _tmp2 = 2 * values_vec[0].rot_vec[0].data[3] _tmp3 = 2 * values_vec[0].rot_vec[1].data[3] @@ -139,7 +139,7 @@ def python_function( _values_vec_out[3] = _tmp1 * values_vec[0].rot.data[1] _values_vec_out[4] = _tmp1 * values_vec[0].rot.data[2] _values_vec_out[5] = ( - -values_vec[0].rot.data[0] ** 2 + -(values_vec[0].rot.data[0] ** 2) - values_vec[0].rot.data[1] ** 2 - values_vec[0].rot.data[2] ** 2 + values_vec[0].rot.data[3] ** 2 @@ -148,7 +148,7 @@ def python_function( _values_vec_out[7] = _tmp2 * values_vec[0].rot_vec[0].data[1] _values_vec_out[8] = _tmp2 * values_vec[0].rot_vec[0].data[2] _values_vec_out[9] = ( - -values_vec[0].rot_vec[0].data[0] ** 2 + -(values_vec[0].rot_vec[0].data[0] ** 2) - values_vec[0].rot_vec[0].data[1] ** 2 - values_vec[0].rot_vec[0].data[2] ** 2 + values_vec[0].rot_vec[0].data[3] ** 2 @@ -157,7 +157,7 @@ def python_function( _values_vec_out[11] = _tmp3 * values_vec[0].rot_vec[1].data[1] _values_vec_out[12] = _tmp3 * values_vec[0].rot_vec[1].data[2] _values_vec_out[13] = ( - -values_vec[0].rot_vec[1].data[0] ** 2 + -(values_vec[0].rot_vec[1].data[0] ** 2) - values_vec[0].rot_vec[1].data[1] ** 2 - values_vec[0].rot_vec[1].data[2] ** 2 + values_vec[0].rot_vec[1].data[3] ** 2 @@ -166,7 +166,7 @@ def python_function( _values_vec_out[15] = _tmp4 * values_vec[0].rot_vec[2].data[1] _values_vec_out[16] = _tmp4 * values_vec[0].rot_vec[2].data[2] _values_vec_out[17] = ( - -values_vec[0].rot_vec[2].data[0] ** 2 + -(values_vec[0].rot_vec[2].data[0] ** 2) - values_vec[0].rot_vec[2].data[1] ** 2 - values_vec[0].rot_vec[2].data[2] ** 2 + values_vec[0].rot_vec[2].data[3] ** 2 @@ -178,7 +178,7 @@ def python_function( _values_vec_out[22] = _tmp5 * values_vec[0].list_of_lists[0][0].data[1] _values_vec_out[23] = _tmp5 * values_vec[0].list_of_lists[0][0].data[2] _values_vec_out[24] = ( - -values_vec[0].list_of_lists[0][0].data[0] ** 2 + -(values_vec[0].list_of_lists[0][0].data[0] ** 2) - values_vec[0].list_of_lists[0][0].data[1] ** 2 - values_vec[0].list_of_lists[0][0].data[2] ** 2 + values_vec[0].list_of_lists[0][0].data[3] ** 2 @@ -187,7 +187,7 @@ def python_function( _values_vec_out[26] = _tmp6 * values_vec[0].list_of_lists[0][1].data[1] _values_vec_out[27] = _tmp6 * values_vec[0].list_of_lists[0][1].data[2] _values_vec_out[28] = ( - -values_vec[0].list_of_lists[0][1].data[0] ** 2 + -(values_vec[0].list_of_lists[0][1].data[0] ** 2) - values_vec[0].list_of_lists[0][1].data[1] ** 2 - values_vec[0].list_of_lists[0][1].data[2] ** 2 + values_vec[0].list_of_lists[0][1].data[3] ** 2 @@ -196,7 +196,7 @@ def python_function( _values_vec_out[30] = _tmp7 * values_vec[0].list_of_lists[0][2].data[1] _values_vec_out[31] = _tmp7 * values_vec[0].list_of_lists[0][2].data[2] _values_vec_out[32] = ( - -values_vec[0].list_of_lists[0][2].data[0] ** 2 + -(values_vec[0].list_of_lists[0][2].data[0] ** 2) - values_vec[0].list_of_lists[0][2].data[1] ** 2 - values_vec[0].list_of_lists[0][2].data[2] ** 2 + values_vec[0].list_of_lists[0][2].data[3] ** 2 @@ -205,7 +205,7 @@ def python_function( _values_vec_out[34] = _tmp8 * values_vec[0].list_of_lists[1][0].data[1] _values_vec_out[35] = _tmp8 * values_vec[0].list_of_lists[1][0].data[2] _values_vec_out[36] = ( - -values_vec[0].list_of_lists[1][0].data[0] ** 2 + -(values_vec[0].list_of_lists[1][0].data[0] ** 2) - values_vec[0].list_of_lists[1][0].data[1] ** 2 - values_vec[0].list_of_lists[1][0].data[2] ** 2 + values_vec[0].list_of_lists[1][0].data[3] ** 2 @@ -214,7 +214,7 @@ def python_function( _values_vec_out[38] = _tmp9 * values_vec[0].list_of_lists[1][1].data[1] _values_vec_out[39] = _tmp9 * values_vec[0].list_of_lists[1][1].data[2] _values_vec_out[40] = ( - -values_vec[0].list_of_lists[1][1].data[0] ** 2 + -(values_vec[0].list_of_lists[1][1].data[0] ** 2) - values_vec[0].list_of_lists[1][1].data[1] ** 2 - values_vec[0].list_of_lists[1][1].data[2] ** 2 + values_vec[0].list_of_lists[1][1].data[3] ** 2 @@ -223,7 +223,7 @@ def python_function( _values_vec_out[42] = _tmp10 * values_vec[0].list_of_lists[1][2].data[1] _values_vec_out[43] = _tmp10 * values_vec[0].list_of_lists[1][2].data[2] _values_vec_out[44] = ( - -values_vec[0].list_of_lists[1][2].data[0] ** 2 + -(values_vec[0].list_of_lists[1][2].data[0] ** 2) - values_vec[0].list_of_lists[1][2].data[1] ** 2 - values_vec[0].list_of_lists[1][2].data[2] ** 2 + values_vec[0].list_of_lists[1][2].data[3] ** 2 @@ -232,7 +232,7 @@ def python_function( _values_vec_out[46] = _tmp11 * values_vec[0].list_of_lists[2][0].data[1] _values_vec_out[47] = _tmp11 * values_vec[0].list_of_lists[2][0].data[2] _values_vec_out[48] = ( - -values_vec[0].list_of_lists[2][0].data[0] ** 2 + -(values_vec[0].list_of_lists[2][0].data[0] ** 2) - values_vec[0].list_of_lists[2][0].data[1] ** 2 - values_vec[0].list_of_lists[2][0].data[2] ** 2 + values_vec[0].list_of_lists[2][0].data[3] ** 2 @@ -241,7 +241,7 @@ def python_function( _values_vec_out[50] = _tmp12 * values_vec[0].list_of_lists[2][1].data[1] _values_vec_out[51] = _tmp12 * values_vec[0].list_of_lists[2][1].data[2] _values_vec_out[52] = ( - -values_vec[0].list_of_lists[2][1].data[0] ** 2 + -(values_vec[0].list_of_lists[2][1].data[0] ** 2) - values_vec[0].list_of_lists[2][1].data[1] ** 2 - values_vec[0].list_of_lists[2][1].data[2] ** 2 + values_vec[0].list_of_lists[2][1].data[3] ** 2 @@ -250,7 +250,7 @@ def python_function( _values_vec_out[54] = _tmp13 * values_vec[0].list_of_lists[2][2].data[1] _values_vec_out[55] = _tmp13 * values_vec[0].list_of_lists[2][2].data[2] _values_vec_out[56] = ( - -values_vec[0].list_of_lists[2][2].data[0] ** 2 + -(values_vec[0].list_of_lists[2][2].data[0] ** 2) - values_vec[0].list_of_lists[2][2].data[1] ** 2 - values_vec[0].list_of_lists[2][2].data[2] ** 2 + values_vec[0].list_of_lists[2][2].data[3] ** 2 @@ -261,7 +261,7 @@ def python_function( _values_vec_out[60] = _tmp14 * values_vec[1].rot.data[1] _values_vec_out[61] = _tmp14 * values_vec[1].rot.data[2] _values_vec_out[62] = ( - -values_vec[1].rot.data[0] ** 2 + -(values_vec[1].rot.data[0] ** 2) - values_vec[1].rot.data[1] ** 2 - values_vec[1].rot.data[2] ** 2 + values_vec[1].rot.data[3] ** 2 @@ -270,7 +270,7 @@ def python_function( _values_vec_out[64] = _tmp15 * values_vec[1].rot_vec[0].data[1] _values_vec_out[65] = _tmp15 * values_vec[1].rot_vec[0].data[2] _values_vec_out[66] = ( - -values_vec[1].rot_vec[0].data[0] ** 2 + -(values_vec[1].rot_vec[0].data[0] ** 2) - values_vec[1].rot_vec[0].data[1] ** 2 - values_vec[1].rot_vec[0].data[2] ** 2 + values_vec[1].rot_vec[0].data[3] ** 2 @@ -279,7 +279,7 @@ def python_function( _values_vec_out[68] = _tmp16 * values_vec[1].rot_vec[1].data[1] _values_vec_out[69] = _tmp16 * values_vec[1].rot_vec[1].data[2] _values_vec_out[70] = ( - -values_vec[1].rot_vec[1].data[0] ** 2 + -(values_vec[1].rot_vec[1].data[0] ** 2) - values_vec[1].rot_vec[1].data[1] ** 2 - values_vec[1].rot_vec[1].data[2] ** 2 + values_vec[1].rot_vec[1].data[3] ** 2 @@ -288,7 +288,7 @@ def python_function( _values_vec_out[72] = _tmp17 * values_vec[1].rot_vec[2].data[1] _values_vec_out[73] = _tmp17 * values_vec[1].rot_vec[2].data[2] _values_vec_out[74] = ( - -values_vec[1].rot_vec[2].data[0] ** 2 + -(values_vec[1].rot_vec[2].data[0] ** 2) - values_vec[1].rot_vec[2].data[1] ** 2 - values_vec[1].rot_vec[2].data[2] ** 2 + values_vec[1].rot_vec[2].data[3] ** 2 @@ -300,7 +300,7 @@ def python_function( _values_vec_out[79] = _tmp18 * values_vec[1].list_of_lists[0][0].data[1] _values_vec_out[80] = _tmp18 * values_vec[1].list_of_lists[0][0].data[2] _values_vec_out[81] = ( - -values_vec[1].list_of_lists[0][0].data[0] ** 2 + -(values_vec[1].list_of_lists[0][0].data[0] ** 2) - values_vec[1].list_of_lists[0][0].data[1] ** 2 - values_vec[1].list_of_lists[0][0].data[2] ** 2 + values_vec[1].list_of_lists[0][0].data[3] ** 2 @@ -309,7 +309,7 @@ def python_function( _values_vec_out[83] = _tmp19 * values_vec[1].list_of_lists[0][1].data[1] _values_vec_out[84] = _tmp19 * values_vec[1].list_of_lists[0][1].data[2] _values_vec_out[85] = ( - -values_vec[1].list_of_lists[0][1].data[0] ** 2 + -(values_vec[1].list_of_lists[0][1].data[0] ** 2) - values_vec[1].list_of_lists[0][1].data[1] ** 2 - values_vec[1].list_of_lists[0][1].data[2] ** 2 + values_vec[1].list_of_lists[0][1].data[3] ** 2 @@ -318,7 +318,7 @@ def python_function( _values_vec_out[87] = _tmp20 * values_vec[1].list_of_lists[0][2].data[1] _values_vec_out[88] = _tmp20 * values_vec[1].list_of_lists[0][2].data[2] _values_vec_out[89] = ( - -values_vec[1].list_of_lists[0][2].data[0] ** 2 + -(values_vec[1].list_of_lists[0][2].data[0] ** 2) - values_vec[1].list_of_lists[0][2].data[1] ** 2 - values_vec[1].list_of_lists[0][2].data[2] ** 2 + values_vec[1].list_of_lists[0][2].data[3] ** 2 @@ -327,7 +327,7 @@ def python_function( _values_vec_out[91] = _tmp21 * values_vec[1].list_of_lists[1][0].data[1] _values_vec_out[92] = _tmp21 * values_vec[1].list_of_lists[1][0].data[2] _values_vec_out[93] = ( - -values_vec[1].list_of_lists[1][0].data[0] ** 2 + -(values_vec[1].list_of_lists[1][0].data[0] ** 2) - values_vec[1].list_of_lists[1][0].data[1] ** 2 - values_vec[1].list_of_lists[1][0].data[2] ** 2 + values_vec[1].list_of_lists[1][0].data[3] ** 2 @@ -336,7 +336,7 @@ def python_function( _values_vec_out[95] = _tmp22 * values_vec[1].list_of_lists[1][1].data[1] _values_vec_out[96] = _tmp22 * values_vec[1].list_of_lists[1][1].data[2] _values_vec_out[97] = ( - -values_vec[1].list_of_lists[1][1].data[0] ** 2 + -(values_vec[1].list_of_lists[1][1].data[0] ** 2) - values_vec[1].list_of_lists[1][1].data[1] ** 2 - values_vec[1].list_of_lists[1][1].data[2] ** 2 + values_vec[1].list_of_lists[1][1].data[3] ** 2 @@ -345,7 +345,7 @@ def python_function( _values_vec_out[99] = _tmp23 * values_vec[1].list_of_lists[1][2].data[1] _values_vec_out[100] = _tmp23 * values_vec[1].list_of_lists[1][2].data[2] _values_vec_out[101] = ( - -values_vec[1].list_of_lists[1][2].data[0] ** 2 + -(values_vec[1].list_of_lists[1][2].data[0] ** 2) - values_vec[1].list_of_lists[1][2].data[1] ** 2 - values_vec[1].list_of_lists[1][2].data[2] ** 2 + values_vec[1].list_of_lists[1][2].data[3] ** 2 @@ -354,7 +354,7 @@ def python_function( _values_vec_out[103] = _tmp24 * values_vec[1].list_of_lists[2][0].data[1] _values_vec_out[104] = _tmp24 * values_vec[1].list_of_lists[2][0].data[2] _values_vec_out[105] = ( - -values_vec[1].list_of_lists[2][0].data[0] ** 2 + -(values_vec[1].list_of_lists[2][0].data[0] ** 2) - values_vec[1].list_of_lists[2][0].data[1] ** 2 - values_vec[1].list_of_lists[2][0].data[2] ** 2 + values_vec[1].list_of_lists[2][0].data[3] ** 2 @@ -363,7 +363,7 @@ def python_function( _values_vec_out[107] = _tmp25 * values_vec[1].list_of_lists[2][1].data[1] _values_vec_out[108] = _tmp25 * values_vec[1].list_of_lists[2][1].data[2] _values_vec_out[109] = ( - -values_vec[1].list_of_lists[2][1].data[0] ** 2 + -(values_vec[1].list_of_lists[2][1].data[0] ** 2) - values_vec[1].list_of_lists[2][1].data[1] ** 2 - values_vec[1].list_of_lists[2][1].data[2] ** 2 + values_vec[1].list_of_lists[2][1].data[3] ** 2 @@ -372,7 +372,7 @@ def python_function( _values_vec_out[111] = _tmp26 * values_vec[1].list_of_lists[2][2].data[1] _values_vec_out[112] = _tmp26 * values_vec[1].list_of_lists[2][2].data[2] _values_vec_out[113] = ( - -values_vec[1].list_of_lists[2][2].data[0] ** 2 + -(values_vec[1].list_of_lists[2][2].data[0] ** 2) - values_vec[1].list_of_lists[2][2].data[1] ** 2 - values_vec[1].list_of_lists[2][2].data[2] ** 2 + values_vec[1].list_of_lists[2][2].data[3] ** 2 @@ -383,7 +383,7 @@ def python_function( _values_vec_out[117] = _tmp27 * values_vec[2].rot.data[1] _values_vec_out[118] = _tmp27 * values_vec[2].rot.data[2] _values_vec_out[119] = ( - -values_vec[2].rot.data[0] ** 2 + -(values_vec[2].rot.data[0] ** 2) - values_vec[2].rot.data[1] ** 2 - values_vec[2].rot.data[2] ** 2 + values_vec[2].rot.data[3] ** 2 @@ -392,7 +392,7 @@ def python_function( _values_vec_out[121] = _tmp28 * values_vec[2].rot_vec[0].data[1] _values_vec_out[122] = _tmp28 * values_vec[2].rot_vec[0].data[2] _values_vec_out[123] = ( - -values_vec[2].rot_vec[0].data[0] ** 2 + -(values_vec[2].rot_vec[0].data[0] ** 2) - values_vec[2].rot_vec[0].data[1] ** 2 - values_vec[2].rot_vec[0].data[2] ** 2 + values_vec[2].rot_vec[0].data[3] ** 2 @@ -401,7 +401,7 @@ def python_function( _values_vec_out[125] = _tmp29 * values_vec[2].rot_vec[1].data[1] _values_vec_out[126] = _tmp29 * values_vec[2].rot_vec[1].data[2] _values_vec_out[127] = ( - -values_vec[2].rot_vec[1].data[0] ** 2 + -(values_vec[2].rot_vec[1].data[0] ** 2) - values_vec[2].rot_vec[1].data[1] ** 2 - values_vec[2].rot_vec[1].data[2] ** 2 + values_vec[2].rot_vec[1].data[3] ** 2 @@ -410,7 +410,7 @@ def python_function( _values_vec_out[129] = _tmp30 * values_vec[2].rot_vec[2].data[1] _values_vec_out[130] = _tmp30 * values_vec[2].rot_vec[2].data[2] _values_vec_out[131] = ( - -values_vec[2].rot_vec[2].data[0] ** 2 + -(values_vec[2].rot_vec[2].data[0] ** 2) - values_vec[2].rot_vec[2].data[1] ** 2 - values_vec[2].rot_vec[2].data[2] ** 2 + values_vec[2].rot_vec[2].data[3] ** 2 @@ -422,7 +422,7 @@ def python_function( _values_vec_out[136] = _tmp31 * values_vec[2].list_of_lists[0][0].data[1] _values_vec_out[137] = _tmp31 * values_vec[2].list_of_lists[0][0].data[2] _values_vec_out[138] = ( - -values_vec[2].list_of_lists[0][0].data[0] ** 2 + -(values_vec[2].list_of_lists[0][0].data[0] ** 2) - values_vec[2].list_of_lists[0][0].data[1] ** 2 - values_vec[2].list_of_lists[0][0].data[2] ** 2 + values_vec[2].list_of_lists[0][0].data[3] ** 2 @@ -431,7 +431,7 @@ def python_function( _values_vec_out[140] = _tmp32 * values_vec[2].list_of_lists[0][1].data[1] _values_vec_out[141] = _tmp32 * values_vec[2].list_of_lists[0][1].data[2] _values_vec_out[142] = ( - -values_vec[2].list_of_lists[0][1].data[0] ** 2 + -(values_vec[2].list_of_lists[0][1].data[0] ** 2) - values_vec[2].list_of_lists[0][1].data[1] ** 2 - values_vec[2].list_of_lists[0][1].data[2] ** 2 + values_vec[2].list_of_lists[0][1].data[3] ** 2 @@ -440,7 +440,7 @@ def python_function( _values_vec_out[144] = _tmp33 * values_vec[2].list_of_lists[0][2].data[1] _values_vec_out[145] = _tmp33 * values_vec[2].list_of_lists[0][2].data[2] _values_vec_out[146] = ( - -values_vec[2].list_of_lists[0][2].data[0] ** 2 + -(values_vec[2].list_of_lists[0][2].data[0] ** 2) - values_vec[2].list_of_lists[0][2].data[1] ** 2 - values_vec[2].list_of_lists[0][2].data[2] ** 2 + values_vec[2].list_of_lists[0][2].data[3] ** 2 @@ -449,7 +449,7 @@ def python_function( _values_vec_out[148] = _tmp34 * values_vec[2].list_of_lists[1][0].data[1] _values_vec_out[149] = _tmp34 * values_vec[2].list_of_lists[1][0].data[2] _values_vec_out[150] = ( - -values_vec[2].list_of_lists[1][0].data[0] ** 2 + -(values_vec[2].list_of_lists[1][0].data[0] ** 2) - values_vec[2].list_of_lists[1][0].data[1] ** 2 - values_vec[2].list_of_lists[1][0].data[2] ** 2 + values_vec[2].list_of_lists[1][0].data[3] ** 2 @@ -458,7 +458,7 @@ def python_function( _values_vec_out[152] = _tmp35 * values_vec[2].list_of_lists[1][1].data[1] _values_vec_out[153] = _tmp35 * values_vec[2].list_of_lists[1][1].data[2] _values_vec_out[154] = ( - -values_vec[2].list_of_lists[1][1].data[0] ** 2 + -(values_vec[2].list_of_lists[1][1].data[0] ** 2) - values_vec[2].list_of_lists[1][1].data[1] ** 2 - values_vec[2].list_of_lists[1][1].data[2] ** 2 + values_vec[2].list_of_lists[1][1].data[3] ** 2 @@ -467,7 +467,7 @@ def python_function( _values_vec_out[156] = _tmp36 * values_vec[2].list_of_lists[1][2].data[1] _values_vec_out[157] = _tmp36 * values_vec[2].list_of_lists[1][2].data[2] _values_vec_out[158] = ( - -values_vec[2].list_of_lists[1][2].data[0] ** 2 + -(values_vec[2].list_of_lists[1][2].data[0] ** 2) - values_vec[2].list_of_lists[1][2].data[1] ** 2 - values_vec[2].list_of_lists[1][2].data[2] ** 2 + values_vec[2].list_of_lists[1][2].data[3] ** 2 @@ -476,7 +476,7 @@ def python_function( _values_vec_out[160] = _tmp37 * values_vec[2].list_of_lists[2][0].data[1] _values_vec_out[161] = _tmp37 * values_vec[2].list_of_lists[2][0].data[2] _values_vec_out[162] = ( - -values_vec[2].list_of_lists[2][0].data[0] ** 2 + -(values_vec[2].list_of_lists[2][0].data[0] ** 2) - values_vec[2].list_of_lists[2][0].data[1] ** 2 - values_vec[2].list_of_lists[2][0].data[2] ** 2 + values_vec[2].list_of_lists[2][0].data[3] ** 2 @@ -485,7 +485,7 @@ def python_function( _values_vec_out[164] = _tmp38 * values_vec[2].list_of_lists[2][1].data[1] _values_vec_out[165] = _tmp38 * values_vec[2].list_of_lists[2][1].data[2] _values_vec_out[166] = ( - -values_vec[2].list_of_lists[2][1].data[0] ** 2 + -(values_vec[2].list_of_lists[2][1].data[0] ** 2) - values_vec[2].list_of_lists[2][1].data[1] ** 2 - values_vec[2].list_of_lists[2][1].data[2] ** 2 + values_vec[2].list_of_lists[2][1].data[3] ** 2 @@ -494,7 +494,7 @@ def python_function( _values_vec_out[168] = _tmp39 * values_vec[2].list_of_lists[2][2].data[1] _values_vec_out[169] = _tmp39 * values_vec[2].list_of_lists[2][2].data[2] _values_vec_out[170] = ( - -values_vec[2].list_of_lists[2][2].data[0] ** 2 + -(values_vec[2].list_of_lists[2][2].data[0] ** 2) - values_vec[2].list_of_lists[2][2].data[1] ** 2 - values_vec[2].list_of_lists[2][2].data[2] ** 2 + values_vec[2].list_of_lists[2][2].data[3] ** 2 @@ -506,7 +506,7 @@ def python_function( _values_vec_2D_out[3] = _tmp40 * values_vec_2D[0][0].rot.data[1] _values_vec_2D_out[4] = _tmp40 * values_vec_2D[0][0].rot.data[2] _values_vec_2D_out[5] = ( - -values_vec_2D[0][0].rot.data[0] ** 2 + -(values_vec_2D[0][0].rot.data[0] ** 2) - values_vec_2D[0][0].rot.data[1] ** 2 - values_vec_2D[0][0].rot.data[2] ** 2 + values_vec_2D[0][0].rot.data[3] ** 2 @@ -515,7 +515,7 @@ def python_function( _values_vec_2D_out[7] = _tmp41 * values_vec_2D[0][0].rot_vec[0].data[1] _values_vec_2D_out[8] = _tmp41 * values_vec_2D[0][0].rot_vec[0].data[2] _values_vec_2D_out[9] = ( - -values_vec_2D[0][0].rot_vec[0].data[0] ** 2 + -(values_vec_2D[0][0].rot_vec[0].data[0] ** 2) - values_vec_2D[0][0].rot_vec[0].data[1] ** 2 - values_vec_2D[0][0].rot_vec[0].data[2] ** 2 + values_vec_2D[0][0].rot_vec[0].data[3] ** 2 @@ -524,7 +524,7 @@ def python_function( _values_vec_2D_out[11] = _tmp42 * values_vec_2D[0][0].rot_vec[1].data[1] _values_vec_2D_out[12] = _tmp42 * values_vec_2D[0][0].rot_vec[1].data[2] _values_vec_2D_out[13] = ( - -values_vec_2D[0][0].rot_vec[1].data[0] ** 2 + -(values_vec_2D[0][0].rot_vec[1].data[0] ** 2) - values_vec_2D[0][0].rot_vec[1].data[1] ** 2 - values_vec_2D[0][0].rot_vec[1].data[2] ** 2 + values_vec_2D[0][0].rot_vec[1].data[3] ** 2 @@ -533,7 +533,7 @@ def python_function( _values_vec_2D_out[15] = _tmp43 * values_vec_2D[0][0].rot_vec[2].data[1] _values_vec_2D_out[16] = _tmp43 * values_vec_2D[0][0].rot_vec[2].data[2] _values_vec_2D_out[17] = ( - -values_vec_2D[0][0].rot_vec[2].data[0] ** 2 + -(values_vec_2D[0][0].rot_vec[2].data[0] ** 2) - values_vec_2D[0][0].rot_vec[2].data[1] ** 2 - values_vec_2D[0][0].rot_vec[2].data[2] ** 2 + values_vec_2D[0][0].rot_vec[2].data[3] ** 2 @@ -545,7 +545,7 @@ def python_function( _values_vec_2D_out[22] = _tmp44 * values_vec_2D[0][0].list_of_lists[0][0].data[1] _values_vec_2D_out[23] = _tmp44 * values_vec_2D[0][0].list_of_lists[0][0].data[2] _values_vec_2D_out[24] = ( - -values_vec_2D[0][0].list_of_lists[0][0].data[0] ** 2 + -(values_vec_2D[0][0].list_of_lists[0][0].data[0] ** 2) - values_vec_2D[0][0].list_of_lists[0][0].data[1] ** 2 - values_vec_2D[0][0].list_of_lists[0][0].data[2] ** 2 + values_vec_2D[0][0].list_of_lists[0][0].data[3] ** 2 @@ -554,7 +554,7 @@ def python_function( _values_vec_2D_out[26] = _tmp45 * values_vec_2D[0][0].list_of_lists[0][1].data[1] _values_vec_2D_out[27] = _tmp45 * values_vec_2D[0][0].list_of_lists[0][1].data[2] _values_vec_2D_out[28] = ( - -values_vec_2D[0][0].list_of_lists[0][1].data[0] ** 2 + -(values_vec_2D[0][0].list_of_lists[0][1].data[0] ** 2) - values_vec_2D[0][0].list_of_lists[0][1].data[1] ** 2 - values_vec_2D[0][0].list_of_lists[0][1].data[2] ** 2 + values_vec_2D[0][0].list_of_lists[0][1].data[3] ** 2 @@ -563,7 +563,7 @@ def python_function( _values_vec_2D_out[30] = _tmp46 * values_vec_2D[0][0].list_of_lists[0][2].data[1] _values_vec_2D_out[31] = _tmp46 * values_vec_2D[0][0].list_of_lists[0][2].data[2] _values_vec_2D_out[32] = ( - -values_vec_2D[0][0].list_of_lists[0][2].data[0] ** 2 + -(values_vec_2D[0][0].list_of_lists[0][2].data[0] ** 2) - values_vec_2D[0][0].list_of_lists[0][2].data[1] ** 2 - values_vec_2D[0][0].list_of_lists[0][2].data[2] ** 2 + values_vec_2D[0][0].list_of_lists[0][2].data[3] ** 2 @@ -572,7 +572,7 @@ def python_function( _values_vec_2D_out[34] = _tmp47 * values_vec_2D[0][0].list_of_lists[1][0].data[1] _values_vec_2D_out[35] = _tmp47 * values_vec_2D[0][0].list_of_lists[1][0].data[2] _values_vec_2D_out[36] = ( - -values_vec_2D[0][0].list_of_lists[1][0].data[0] ** 2 + -(values_vec_2D[0][0].list_of_lists[1][0].data[0] ** 2) - values_vec_2D[0][0].list_of_lists[1][0].data[1] ** 2 - values_vec_2D[0][0].list_of_lists[1][0].data[2] ** 2 + values_vec_2D[0][0].list_of_lists[1][0].data[3] ** 2 @@ -581,7 +581,7 @@ def python_function( _values_vec_2D_out[38] = _tmp48 * values_vec_2D[0][0].list_of_lists[1][1].data[1] _values_vec_2D_out[39] = _tmp48 * values_vec_2D[0][0].list_of_lists[1][1].data[2] _values_vec_2D_out[40] = ( - -values_vec_2D[0][0].list_of_lists[1][1].data[0] ** 2 + -(values_vec_2D[0][0].list_of_lists[1][1].data[0] ** 2) - values_vec_2D[0][0].list_of_lists[1][1].data[1] ** 2 - values_vec_2D[0][0].list_of_lists[1][1].data[2] ** 2 + values_vec_2D[0][0].list_of_lists[1][1].data[3] ** 2 @@ -590,7 +590,7 @@ def python_function( _values_vec_2D_out[42] = _tmp49 * values_vec_2D[0][0].list_of_lists[1][2].data[1] _values_vec_2D_out[43] = _tmp49 * values_vec_2D[0][0].list_of_lists[1][2].data[2] _values_vec_2D_out[44] = ( - -values_vec_2D[0][0].list_of_lists[1][2].data[0] ** 2 + -(values_vec_2D[0][0].list_of_lists[1][2].data[0] ** 2) - values_vec_2D[0][0].list_of_lists[1][2].data[1] ** 2 - values_vec_2D[0][0].list_of_lists[1][2].data[2] ** 2 + values_vec_2D[0][0].list_of_lists[1][2].data[3] ** 2 @@ -599,7 +599,7 @@ def python_function( _values_vec_2D_out[46] = _tmp50 * values_vec_2D[0][0].list_of_lists[2][0].data[1] _values_vec_2D_out[47] = _tmp50 * values_vec_2D[0][0].list_of_lists[2][0].data[2] _values_vec_2D_out[48] = ( - -values_vec_2D[0][0].list_of_lists[2][0].data[0] ** 2 + -(values_vec_2D[0][0].list_of_lists[2][0].data[0] ** 2) - values_vec_2D[0][0].list_of_lists[2][0].data[1] ** 2 - values_vec_2D[0][0].list_of_lists[2][0].data[2] ** 2 + values_vec_2D[0][0].list_of_lists[2][0].data[3] ** 2 @@ -608,7 +608,7 @@ def python_function( _values_vec_2D_out[50] = _tmp51 * values_vec_2D[0][0].list_of_lists[2][1].data[1] _values_vec_2D_out[51] = _tmp51 * values_vec_2D[0][0].list_of_lists[2][1].data[2] _values_vec_2D_out[52] = ( - -values_vec_2D[0][0].list_of_lists[2][1].data[0] ** 2 + -(values_vec_2D[0][0].list_of_lists[2][1].data[0] ** 2) - values_vec_2D[0][0].list_of_lists[2][1].data[1] ** 2 - values_vec_2D[0][0].list_of_lists[2][1].data[2] ** 2 + values_vec_2D[0][0].list_of_lists[2][1].data[3] ** 2 @@ -617,7 +617,7 @@ def python_function( _values_vec_2D_out[54] = _tmp52 * values_vec_2D[0][0].list_of_lists[2][2].data[1] _values_vec_2D_out[55] = _tmp52 * values_vec_2D[0][0].list_of_lists[2][2].data[2] _values_vec_2D_out[56] = ( - -values_vec_2D[0][0].list_of_lists[2][2].data[0] ** 2 + -(values_vec_2D[0][0].list_of_lists[2][2].data[0] ** 2) - values_vec_2D[0][0].list_of_lists[2][2].data[1] ** 2 - values_vec_2D[0][0].list_of_lists[2][2].data[2] ** 2 + values_vec_2D[0][0].list_of_lists[2][2].data[3] ** 2 @@ -628,7 +628,7 @@ def python_function( _values_vec_2D_out[60] = _tmp53 * values_vec_2D[1][0].rot.data[1] _values_vec_2D_out[61] = _tmp53 * values_vec_2D[1][0].rot.data[2] _values_vec_2D_out[62] = ( - -values_vec_2D[1][0].rot.data[0] ** 2 + -(values_vec_2D[1][0].rot.data[0] ** 2) - values_vec_2D[1][0].rot.data[1] ** 2 - values_vec_2D[1][0].rot.data[2] ** 2 + values_vec_2D[1][0].rot.data[3] ** 2 @@ -637,7 +637,7 @@ def python_function( _values_vec_2D_out[64] = _tmp54 * values_vec_2D[1][0].rot_vec[0].data[1] _values_vec_2D_out[65] = _tmp54 * values_vec_2D[1][0].rot_vec[0].data[2] _values_vec_2D_out[66] = ( - -values_vec_2D[1][0].rot_vec[0].data[0] ** 2 + -(values_vec_2D[1][0].rot_vec[0].data[0] ** 2) - values_vec_2D[1][0].rot_vec[0].data[1] ** 2 - values_vec_2D[1][0].rot_vec[0].data[2] ** 2 + values_vec_2D[1][0].rot_vec[0].data[3] ** 2 @@ -646,7 +646,7 @@ def python_function( _values_vec_2D_out[68] = _tmp55 * values_vec_2D[1][0].rot_vec[1].data[1] _values_vec_2D_out[69] = _tmp55 * values_vec_2D[1][0].rot_vec[1].data[2] _values_vec_2D_out[70] = ( - -values_vec_2D[1][0].rot_vec[1].data[0] ** 2 + -(values_vec_2D[1][0].rot_vec[1].data[0] ** 2) - values_vec_2D[1][0].rot_vec[1].data[1] ** 2 - values_vec_2D[1][0].rot_vec[1].data[2] ** 2 + values_vec_2D[1][0].rot_vec[1].data[3] ** 2 @@ -655,7 +655,7 @@ def python_function( _values_vec_2D_out[72] = _tmp56 * values_vec_2D[1][0].rot_vec[2].data[1] _values_vec_2D_out[73] = _tmp56 * values_vec_2D[1][0].rot_vec[2].data[2] _values_vec_2D_out[74] = ( - -values_vec_2D[1][0].rot_vec[2].data[0] ** 2 + -(values_vec_2D[1][0].rot_vec[2].data[0] ** 2) - values_vec_2D[1][0].rot_vec[2].data[1] ** 2 - values_vec_2D[1][0].rot_vec[2].data[2] ** 2 + values_vec_2D[1][0].rot_vec[2].data[3] ** 2 @@ -667,7 +667,7 @@ def python_function( _values_vec_2D_out[79] = _tmp57 * values_vec_2D[1][0].list_of_lists[0][0].data[1] _values_vec_2D_out[80] = _tmp57 * values_vec_2D[1][0].list_of_lists[0][0].data[2] _values_vec_2D_out[81] = ( - -values_vec_2D[1][0].list_of_lists[0][0].data[0] ** 2 + -(values_vec_2D[1][0].list_of_lists[0][0].data[0] ** 2) - values_vec_2D[1][0].list_of_lists[0][0].data[1] ** 2 - values_vec_2D[1][0].list_of_lists[0][0].data[2] ** 2 + values_vec_2D[1][0].list_of_lists[0][0].data[3] ** 2 @@ -676,7 +676,7 @@ def python_function( _values_vec_2D_out[83] = _tmp58 * values_vec_2D[1][0].list_of_lists[0][1].data[1] _values_vec_2D_out[84] = _tmp58 * values_vec_2D[1][0].list_of_lists[0][1].data[2] _values_vec_2D_out[85] = ( - -values_vec_2D[1][0].list_of_lists[0][1].data[0] ** 2 + -(values_vec_2D[1][0].list_of_lists[0][1].data[0] ** 2) - values_vec_2D[1][0].list_of_lists[0][1].data[1] ** 2 - values_vec_2D[1][0].list_of_lists[0][1].data[2] ** 2 + values_vec_2D[1][0].list_of_lists[0][1].data[3] ** 2 @@ -685,7 +685,7 @@ def python_function( _values_vec_2D_out[87] = _tmp59 * values_vec_2D[1][0].list_of_lists[0][2].data[1] _values_vec_2D_out[88] = _tmp59 * values_vec_2D[1][0].list_of_lists[0][2].data[2] _values_vec_2D_out[89] = ( - -values_vec_2D[1][0].list_of_lists[0][2].data[0] ** 2 + -(values_vec_2D[1][0].list_of_lists[0][2].data[0] ** 2) - values_vec_2D[1][0].list_of_lists[0][2].data[1] ** 2 - values_vec_2D[1][0].list_of_lists[0][2].data[2] ** 2 + values_vec_2D[1][0].list_of_lists[0][2].data[3] ** 2 @@ -694,7 +694,7 @@ def python_function( _values_vec_2D_out[91] = _tmp60 * values_vec_2D[1][0].list_of_lists[1][0].data[1] _values_vec_2D_out[92] = _tmp60 * values_vec_2D[1][0].list_of_lists[1][0].data[2] _values_vec_2D_out[93] = ( - -values_vec_2D[1][0].list_of_lists[1][0].data[0] ** 2 + -(values_vec_2D[1][0].list_of_lists[1][0].data[0] ** 2) - values_vec_2D[1][0].list_of_lists[1][0].data[1] ** 2 - values_vec_2D[1][0].list_of_lists[1][0].data[2] ** 2 + values_vec_2D[1][0].list_of_lists[1][0].data[3] ** 2 @@ -703,7 +703,7 @@ def python_function( _values_vec_2D_out[95] = _tmp61 * values_vec_2D[1][0].list_of_lists[1][1].data[1] _values_vec_2D_out[96] = _tmp61 * values_vec_2D[1][0].list_of_lists[1][1].data[2] _values_vec_2D_out[97] = ( - -values_vec_2D[1][0].list_of_lists[1][1].data[0] ** 2 + -(values_vec_2D[1][0].list_of_lists[1][1].data[0] ** 2) - values_vec_2D[1][0].list_of_lists[1][1].data[1] ** 2 - values_vec_2D[1][0].list_of_lists[1][1].data[2] ** 2 + values_vec_2D[1][0].list_of_lists[1][1].data[3] ** 2 @@ -712,7 +712,7 @@ def python_function( _values_vec_2D_out[99] = _tmp62 * values_vec_2D[1][0].list_of_lists[1][2].data[1] _values_vec_2D_out[100] = _tmp62 * values_vec_2D[1][0].list_of_lists[1][2].data[2] _values_vec_2D_out[101] = ( - -values_vec_2D[1][0].list_of_lists[1][2].data[0] ** 2 + -(values_vec_2D[1][0].list_of_lists[1][2].data[0] ** 2) - values_vec_2D[1][0].list_of_lists[1][2].data[1] ** 2 - values_vec_2D[1][0].list_of_lists[1][2].data[2] ** 2 + values_vec_2D[1][0].list_of_lists[1][2].data[3] ** 2 @@ -721,7 +721,7 @@ def python_function( _values_vec_2D_out[103] = _tmp63 * values_vec_2D[1][0].list_of_lists[2][0].data[1] _values_vec_2D_out[104] = _tmp63 * values_vec_2D[1][0].list_of_lists[2][0].data[2] _values_vec_2D_out[105] = ( - -values_vec_2D[1][0].list_of_lists[2][0].data[0] ** 2 + -(values_vec_2D[1][0].list_of_lists[2][0].data[0] ** 2) - values_vec_2D[1][0].list_of_lists[2][0].data[1] ** 2 - values_vec_2D[1][0].list_of_lists[2][0].data[2] ** 2 + values_vec_2D[1][0].list_of_lists[2][0].data[3] ** 2 @@ -730,7 +730,7 @@ def python_function( _values_vec_2D_out[107] = _tmp64 * values_vec_2D[1][0].list_of_lists[2][1].data[1] _values_vec_2D_out[108] = _tmp64 * values_vec_2D[1][0].list_of_lists[2][1].data[2] _values_vec_2D_out[109] = ( - -values_vec_2D[1][0].list_of_lists[2][1].data[0] ** 2 + -(values_vec_2D[1][0].list_of_lists[2][1].data[0] ** 2) - values_vec_2D[1][0].list_of_lists[2][1].data[1] ** 2 - values_vec_2D[1][0].list_of_lists[2][1].data[2] ** 2 + values_vec_2D[1][0].list_of_lists[2][1].data[3] ** 2 @@ -739,7 +739,7 @@ def python_function( _values_vec_2D_out[111] = _tmp65 * values_vec_2D[1][0].list_of_lists[2][2].data[1] _values_vec_2D_out[112] = _tmp65 * values_vec_2D[1][0].list_of_lists[2][2].data[2] _values_vec_2D_out[113] = ( - -values_vec_2D[1][0].list_of_lists[2][2].data[0] ** 2 + -(values_vec_2D[1][0].list_of_lists[2][2].data[0] ** 2) - values_vec_2D[1][0].list_of_lists[2][2].data[1] ** 2 - values_vec_2D[1][0].list_of_lists[2][2].data[2] ** 2 + values_vec_2D[1][0].list_of_lists[2][2].data[3] ** 2 diff --git a/test/symforce_function_codegen_test_data/symengine/databuffer_codegen_test_data/python/symforce/buffer_test/buffer_func.py b/test/symforce_function_codegen_test_data/symengine/databuffer_codegen_test_data/python/symforce/buffer_test/buffer_func.py index f1c437e05..4c8bcbec8 100644 --- a/test/symforce_function_codegen_test_data/symengine/databuffer_codegen_test_data/python/symforce/buffer_test/buffer_func.py +++ b/test/symforce_function_codegen_test_data/symengine/databuffer_codegen_test_data/python/symforce/buffer_test/buffer_func.py @@ -36,5 +36,5 @@ def buffer_func(buffer, a, b): _tmp0 = a + b # Output terms - _result = _tmp0 + buffer[int(_tmp0 * (-a + b))] + buffer[int(-(a ** 2) + b ** 2)] + _result = _tmp0 + buffer[int(_tmp0 * (-a + b))] + buffer[int(-(a**2) + b**2)] return _result diff --git a/test/symforce_function_codegen_test_data/sympy/az_el_from_point.py b/test/symforce_function_codegen_test_data/sympy/az_el_from_point.py index d19ad0011..f7c027efb 100644 --- a/test/symforce_function_codegen_test_data/sympy/az_el_from_point.py +++ b/test/symforce_function_codegen_test_data/sympy/az_el_from_point.py @@ -101,7 +101,7 @@ def az_el_from_point(nav_T_cam, nav_t_point, epsilon): + epsilon * ((0.0 if _tmp18 == 0 else math.copysign(1, _tmp18)) + 0.5), ) _res[1] = ( - -math.acos(_tmp22 / math.sqrt(_tmp18 ** 2 + _tmp22 ** 2 + _tmp9 ** 2 + epsilon)) + -math.acos(_tmp22 / math.sqrt(_tmp18**2 + _tmp22**2 + _tmp9**2 + epsilon)) + (1.0 / 2.0) * math.pi ) return _res diff --git a/test/symforce_function_codegen_test_data/sympy/codegen_python_test_data/python/symforce/codegen_python_test/python_function.py b/test/symforce_function_codegen_test_data/sympy/codegen_python_test_data/python/symforce/codegen_python_test/python_function.py index 7d939d771..bccd0e914 100644 --- a/test/symforce_function_codegen_test_data/sympy/codegen_python_test_data/python/symforce/codegen_python_test/python_function.py +++ b/test/symforce_function_codegen_test_data/sympy/codegen_python_test_data/python/symforce/codegen_python_test/python_function.py @@ -58,7 +58,7 @@ def python_function( _rot = rot.data # Intermediate terms (66) - _tmp0 = x ** 2 + _tmp0 = x**2 _tmp1 = 2 * values_vec[0].rot.data[3] _tmp2 = 2 * values_vec[0].rot_vec[0].data[3] _tmp3 = 2 * values_vec[0].rot_vec[1].data[3] @@ -139,7 +139,7 @@ def python_function( _values_vec_out[3] = _tmp1 * values_vec[0].rot.data[1] _values_vec_out[4] = _tmp1 * values_vec[0].rot.data[2] _values_vec_out[5] = ( - -values_vec[0].rot.data[0] ** 2 + -(values_vec[0].rot.data[0] ** 2) - values_vec[0].rot.data[1] ** 2 - values_vec[0].rot.data[2] ** 2 + values_vec[0].rot.data[3] ** 2 @@ -148,7 +148,7 @@ def python_function( _values_vec_out[7] = _tmp2 * values_vec[0].rot_vec[0].data[1] _values_vec_out[8] = _tmp2 * values_vec[0].rot_vec[0].data[2] _values_vec_out[9] = ( - -values_vec[0].rot_vec[0].data[0] ** 2 + -(values_vec[0].rot_vec[0].data[0] ** 2) - values_vec[0].rot_vec[0].data[1] ** 2 - values_vec[0].rot_vec[0].data[2] ** 2 + values_vec[0].rot_vec[0].data[3] ** 2 @@ -157,7 +157,7 @@ def python_function( _values_vec_out[11] = _tmp3 * values_vec[0].rot_vec[1].data[1] _values_vec_out[12] = _tmp3 * values_vec[0].rot_vec[1].data[2] _values_vec_out[13] = ( - -values_vec[0].rot_vec[1].data[0] ** 2 + -(values_vec[0].rot_vec[1].data[0] ** 2) - values_vec[0].rot_vec[1].data[1] ** 2 - values_vec[0].rot_vec[1].data[2] ** 2 + values_vec[0].rot_vec[1].data[3] ** 2 @@ -166,7 +166,7 @@ def python_function( _values_vec_out[15] = _tmp4 * values_vec[0].rot_vec[2].data[1] _values_vec_out[16] = _tmp4 * values_vec[0].rot_vec[2].data[2] _values_vec_out[17] = ( - -values_vec[0].rot_vec[2].data[0] ** 2 + -(values_vec[0].rot_vec[2].data[0] ** 2) - values_vec[0].rot_vec[2].data[1] ** 2 - values_vec[0].rot_vec[2].data[2] ** 2 + values_vec[0].rot_vec[2].data[3] ** 2 @@ -178,7 +178,7 @@ def python_function( _values_vec_out[22] = _tmp5 * values_vec[0].list_of_lists[0][0].data[1] _values_vec_out[23] = _tmp5 * values_vec[0].list_of_lists[0][0].data[2] _values_vec_out[24] = ( - -values_vec[0].list_of_lists[0][0].data[0] ** 2 + -(values_vec[0].list_of_lists[0][0].data[0] ** 2) - values_vec[0].list_of_lists[0][0].data[1] ** 2 - values_vec[0].list_of_lists[0][0].data[2] ** 2 + values_vec[0].list_of_lists[0][0].data[3] ** 2 @@ -187,7 +187,7 @@ def python_function( _values_vec_out[26] = _tmp6 * values_vec[0].list_of_lists[0][1].data[1] _values_vec_out[27] = _tmp6 * values_vec[0].list_of_lists[0][1].data[2] _values_vec_out[28] = ( - -values_vec[0].list_of_lists[0][1].data[0] ** 2 + -(values_vec[0].list_of_lists[0][1].data[0] ** 2) - values_vec[0].list_of_lists[0][1].data[1] ** 2 - values_vec[0].list_of_lists[0][1].data[2] ** 2 + values_vec[0].list_of_lists[0][1].data[3] ** 2 @@ -196,7 +196,7 @@ def python_function( _values_vec_out[30] = _tmp7 * values_vec[0].list_of_lists[0][2].data[1] _values_vec_out[31] = _tmp7 * values_vec[0].list_of_lists[0][2].data[2] _values_vec_out[32] = ( - -values_vec[0].list_of_lists[0][2].data[0] ** 2 + -(values_vec[0].list_of_lists[0][2].data[0] ** 2) - values_vec[0].list_of_lists[0][2].data[1] ** 2 - values_vec[0].list_of_lists[0][2].data[2] ** 2 + values_vec[0].list_of_lists[0][2].data[3] ** 2 @@ -205,7 +205,7 @@ def python_function( _values_vec_out[34] = _tmp8 * values_vec[0].list_of_lists[1][0].data[1] _values_vec_out[35] = _tmp8 * values_vec[0].list_of_lists[1][0].data[2] _values_vec_out[36] = ( - -values_vec[0].list_of_lists[1][0].data[0] ** 2 + -(values_vec[0].list_of_lists[1][0].data[0] ** 2) - values_vec[0].list_of_lists[1][0].data[1] ** 2 - values_vec[0].list_of_lists[1][0].data[2] ** 2 + values_vec[0].list_of_lists[1][0].data[3] ** 2 @@ -214,7 +214,7 @@ def python_function( _values_vec_out[38] = _tmp9 * values_vec[0].list_of_lists[1][1].data[1] _values_vec_out[39] = _tmp9 * values_vec[0].list_of_lists[1][1].data[2] _values_vec_out[40] = ( - -values_vec[0].list_of_lists[1][1].data[0] ** 2 + -(values_vec[0].list_of_lists[1][1].data[0] ** 2) - values_vec[0].list_of_lists[1][1].data[1] ** 2 - values_vec[0].list_of_lists[1][1].data[2] ** 2 + values_vec[0].list_of_lists[1][1].data[3] ** 2 @@ -223,7 +223,7 @@ def python_function( _values_vec_out[42] = _tmp10 * values_vec[0].list_of_lists[1][2].data[1] _values_vec_out[43] = _tmp10 * values_vec[0].list_of_lists[1][2].data[2] _values_vec_out[44] = ( - -values_vec[0].list_of_lists[1][2].data[0] ** 2 + -(values_vec[0].list_of_lists[1][2].data[0] ** 2) - values_vec[0].list_of_lists[1][2].data[1] ** 2 - values_vec[0].list_of_lists[1][2].data[2] ** 2 + values_vec[0].list_of_lists[1][2].data[3] ** 2 @@ -232,7 +232,7 @@ def python_function( _values_vec_out[46] = _tmp11 * values_vec[0].list_of_lists[2][0].data[1] _values_vec_out[47] = _tmp11 * values_vec[0].list_of_lists[2][0].data[2] _values_vec_out[48] = ( - -values_vec[0].list_of_lists[2][0].data[0] ** 2 + -(values_vec[0].list_of_lists[2][0].data[0] ** 2) - values_vec[0].list_of_lists[2][0].data[1] ** 2 - values_vec[0].list_of_lists[2][0].data[2] ** 2 + values_vec[0].list_of_lists[2][0].data[3] ** 2 @@ -241,7 +241,7 @@ def python_function( _values_vec_out[50] = _tmp12 * values_vec[0].list_of_lists[2][1].data[1] _values_vec_out[51] = _tmp12 * values_vec[0].list_of_lists[2][1].data[2] _values_vec_out[52] = ( - -values_vec[0].list_of_lists[2][1].data[0] ** 2 + -(values_vec[0].list_of_lists[2][1].data[0] ** 2) - values_vec[0].list_of_lists[2][1].data[1] ** 2 - values_vec[0].list_of_lists[2][1].data[2] ** 2 + values_vec[0].list_of_lists[2][1].data[3] ** 2 @@ -250,7 +250,7 @@ def python_function( _values_vec_out[54] = _tmp13 * values_vec[0].list_of_lists[2][2].data[1] _values_vec_out[55] = _tmp13 * values_vec[0].list_of_lists[2][2].data[2] _values_vec_out[56] = ( - -values_vec[0].list_of_lists[2][2].data[0] ** 2 + -(values_vec[0].list_of_lists[2][2].data[0] ** 2) - values_vec[0].list_of_lists[2][2].data[1] ** 2 - values_vec[0].list_of_lists[2][2].data[2] ** 2 + values_vec[0].list_of_lists[2][2].data[3] ** 2 @@ -261,7 +261,7 @@ def python_function( _values_vec_out[60] = _tmp14 * values_vec[1].rot.data[1] _values_vec_out[61] = _tmp14 * values_vec[1].rot.data[2] _values_vec_out[62] = ( - -values_vec[1].rot.data[0] ** 2 + -(values_vec[1].rot.data[0] ** 2) - values_vec[1].rot.data[1] ** 2 - values_vec[1].rot.data[2] ** 2 + values_vec[1].rot.data[3] ** 2 @@ -270,7 +270,7 @@ def python_function( _values_vec_out[64] = _tmp15 * values_vec[1].rot_vec[0].data[1] _values_vec_out[65] = _tmp15 * values_vec[1].rot_vec[0].data[2] _values_vec_out[66] = ( - -values_vec[1].rot_vec[0].data[0] ** 2 + -(values_vec[1].rot_vec[0].data[0] ** 2) - values_vec[1].rot_vec[0].data[1] ** 2 - values_vec[1].rot_vec[0].data[2] ** 2 + values_vec[1].rot_vec[0].data[3] ** 2 @@ -279,7 +279,7 @@ def python_function( _values_vec_out[68] = _tmp16 * values_vec[1].rot_vec[1].data[1] _values_vec_out[69] = _tmp16 * values_vec[1].rot_vec[1].data[2] _values_vec_out[70] = ( - -values_vec[1].rot_vec[1].data[0] ** 2 + -(values_vec[1].rot_vec[1].data[0] ** 2) - values_vec[1].rot_vec[1].data[1] ** 2 - values_vec[1].rot_vec[1].data[2] ** 2 + values_vec[1].rot_vec[1].data[3] ** 2 @@ -288,7 +288,7 @@ def python_function( _values_vec_out[72] = _tmp17 * values_vec[1].rot_vec[2].data[1] _values_vec_out[73] = _tmp17 * values_vec[1].rot_vec[2].data[2] _values_vec_out[74] = ( - -values_vec[1].rot_vec[2].data[0] ** 2 + -(values_vec[1].rot_vec[2].data[0] ** 2) - values_vec[1].rot_vec[2].data[1] ** 2 - values_vec[1].rot_vec[2].data[2] ** 2 + values_vec[1].rot_vec[2].data[3] ** 2 @@ -300,7 +300,7 @@ def python_function( _values_vec_out[79] = _tmp18 * values_vec[1].list_of_lists[0][0].data[1] _values_vec_out[80] = _tmp18 * values_vec[1].list_of_lists[0][0].data[2] _values_vec_out[81] = ( - -values_vec[1].list_of_lists[0][0].data[0] ** 2 + -(values_vec[1].list_of_lists[0][0].data[0] ** 2) - values_vec[1].list_of_lists[0][0].data[1] ** 2 - values_vec[1].list_of_lists[0][0].data[2] ** 2 + values_vec[1].list_of_lists[0][0].data[3] ** 2 @@ -309,7 +309,7 @@ def python_function( _values_vec_out[83] = _tmp19 * values_vec[1].list_of_lists[0][1].data[1] _values_vec_out[84] = _tmp19 * values_vec[1].list_of_lists[0][1].data[2] _values_vec_out[85] = ( - -values_vec[1].list_of_lists[0][1].data[0] ** 2 + -(values_vec[1].list_of_lists[0][1].data[0] ** 2) - values_vec[1].list_of_lists[0][1].data[1] ** 2 - values_vec[1].list_of_lists[0][1].data[2] ** 2 + values_vec[1].list_of_lists[0][1].data[3] ** 2 @@ -318,7 +318,7 @@ def python_function( _values_vec_out[87] = _tmp20 * values_vec[1].list_of_lists[0][2].data[1] _values_vec_out[88] = _tmp20 * values_vec[1].list_of_lists[0][2].data[2] _values_vec_out[89] = ( - -values_vec[1].list_of_lists[0][2].data[0] ** 2 + -(values_vec[1].list_of_lists[0][2].data[0] ** 2) - values_vec[1].list_of_lists[0][2].data[1] ** 2 - values_vec[1].list_of_lists[0][2].data[2] ** 2 + values_vec[1].list_of_lists[0][2].data[3] ** 2 @@ -327,7 +327,7 @@ def python_function( _values_vec_out[91] = _tmp21 * values_vec[1].list_of_lists[1][0].data[1] _values_vec_out[92] = _tmp21 * values_vec[1].list_of_lists[1][0].data[2] _values_vec_out[93] = ( - -values_vec[1].list_of_lists[1][0].data[0] ** 2 + -(values_vec[1].list_of_lists[1][0].data[0] ** 2) - values_vec[1].list_of_lists[1][0].data[1] ** 2 - values_vec[1].list_of_lists[1][0].data[2] ** 2 + values_vec[1].list_of_lists[1][0].data[3] ** 2 @@ -336,7 +336,7 @@ def python_function( _values_vec_out[95] = _tmp22 * values_vec[1].list_of_lists[1][1].data[1] _values_vec_out[96] = _tmp22 * values_vec[1].list_of_lists[1][1].data[2] _values_vec_out[97] = ( - -values_vec[1].list_of_lists[1][1].data[0] ** 2 + -(values_vec[1].list_of_lists[1][1].data[0] ** 2) - values_vec[1].list_of_lists[1][1].data[1] ** 2 - values_vec[1].list_of_lists[1][1].data[2] ** 2 + values_vec[1].list_of_lists[1][1].data[3] ** 2 @@ -345,7 +345,7 @@ def python_function( _values_vec_out[99] = _tmp23 * values_vec[1].list_of_lists[1][2].data[1] _values_vec_out[100] = _tmp23 * values_vec[1].list_of_lists[1][2].data[2] _values_vec_out[101] = ( - -values_vec[1].list_of_lists[1][2].data[0] ** 2 + -(values_vec[1].list_of_lists[1][2].data[0] ** 2) - values_vec[1].list_of_lists[1][2].data[1] ** 2 - values_vec[1].list_of_lists[1][2].data[2] ** 2 + values_vec[1].list_of_lists[1][2].data[3] ** 2 @@ -354,7 +354,7 @@ def python_function( _values_vec_out[103] = _tmp24 * values_vec[1].list_of_lists[2][0].data[1] _values_vec_out[104] = _tmp24 * values_vec[1].list_of_lists[2][0].data[2] _values_vec_out[105] = ( - -values_vec[1].list_of_lists[2][0].data[0] ** 2 + -(values_vec[1].list_of_lists[2][0].data[0] ** 2) - values_vec[1].list_of_lists[2][0].data[1] ** 2 - values_vec[1].list_of_lists[2][0].data[2] ** 2 + values_vec[1].list_of_lists[2][0].data[3] ** 2 @@ -363,7 +363,7 @@ def python_function( _values_vec_out[107] = _tmp25 * values_vec[1].list_of_lists[2][1].data[1] _values_vec_out[108] = _tmp25 * values_vec[1].list_of_lists[2][1].data[2] _values_vec_out[109] = ( - -values_vec[1].list_of_lists[2][1].data[0] ** 2 + -(values_vec[1].list_of_lists[2][1].data[0] ** 2) - values_vec[1].list_of_lists[2][1].data[1] ** 2 - values_vec[1].list_of_lists[2][1].data[2] ** 2 + values_vec[1].list_of_lists[2][1].data[3] ** 2 @@ -372,7 +372,7 @@ def python_function( _values_vec_out[111] = _tmp26 * values_vec[1].list_of_lists[2][2].data[1] _values_vec_out[112] = _tmp26 * values_vec[1].list_of_lists[2][2].data[2] _values_vec_out[113] = ( - -values_vec[1].list_of_lists[2][2].data[0] ** 2 + -(values_vec[1].list_of_lists[2][2].data[0] ** 2) - values_vec[1].list_of_lists[2][2].data[1] ** 2 - values_vec[1].list_of_lists[2][2].data[2] ** 2 + values_vec[1].list_of_lists[2][2].data[3] ** 2 @@ -383,7 +383,7 @@ def python_function( _values_vec_out[117] = _tmp27 * values_vec[2].rot.data[1] _values_vec_out[118] = _tmp27 * values_vec[2].rot.data[2] _values_vec_out[119] = ( - -values_vec[2].rot.data[0] ** 2 + -(values_vec[2].rot.data[0] ** 2) - values_vec[2].rot.data[1] ** 2 - values_vec[2].rot.data[2] ** 2 + values_vec[2].rot.data[3] ** 2 @@ -392,7 +392,7 @@ def python_function( _values_vec_out[121] = _tmp28 * values_vec[2].rot_vec[0].data[1] _values_vec_out[122] = _tmp28 * values_vec[2].rot_vec[0].data[2] _values_vec_out[123] = ( - -values_vec[2].rot_vec[0].data[0] ** 2 + -(values_vec[2].rot_vec[0].data[0] ** 2) - values_vec[2].rot_vec[0].data[1] ** 2 - values_vec[2].rot_vec[0].data[2] ** 2 + values_vec[2].rot_vec[0].data[3] ** 2 @@ -401,7 +401,7 @@ def python_function( _values_vec_out[125] = _tmp29 * values_vec[2].rot_vec[1].data[1] _values_vec_out[126] = _tmp29 * values_vec[2].rot_vec[1].data[2] _values_vec_out[127] = ( - -values_vec[2].rot_vec[1].data[0] ** 2 + -(values_vec[2].rot_vec[1].data[0] ** 2) - values_vec[2].rot_vec[1].data[1] ** 2 - values_vec[2].rot_vec[1].data[2] ** 2 + values_vec[2].rot_vec[1].data[3] ** 2 @@ -410,7 +410,7 @@ def python_function( _values_vec_out[129] = _tmp30 * values_vec[2].rot_vec[2].data[1] _values_vec_out[130] = _tmp30 * values_vec[2].rot_vec[2].data[2] _values_vec_out[131] = ( - -values_vec[2].rot_vec[2].data[0] ** 2 + -(values_vec[2].rot_vec[2].data[0] ** 2) - values_vec[2].rot_vec[2].data[1] ** 2 - values_vec[2].rot_vec[2].data[2] ** 2 + values_vec[2].rot_vec[2].data[3] ** 2 @@ -422,7 +422,7 @@ def python_function( _values_vec_out[136] = _tmp31 * values_vec[2].list_of_lists[0][0].data[1] _values_vec_out[137] = _tmp31 * values_vec[2].list_of_lists[0][0].data[2] _values_vec_out[138] = ( - -values_vec[2].list_of_lists[0][0].data[0] ** 2 + -(values_vec[2].list_of_lists[0][0].data[0] ** 2) - values_vec[2].list_of_lists[0][0].data[1] ** 2 - values_vec[2].list_of_lists[0][0].data[2] ** 2 + values_vec[2].list_of_lists[0][0].data[3] ** 2 @@ -431,7 +431,7 @@ def python_function( _values_vec_out[140] = _tmp32 * values_vec[2].list_of_lists[0][1].data[1] _values_vec_out[141] = _tmp32 * values_vec[2].list_of_lists[0][1].data[2] _values_vec_out[142] = ( - -values_vec[2].list_of_lists[0][1].data[0] ** 2 + -(values_vec[2].list_of_lists[0][1].data[0] ** 2) - values_vec[2].list_of_lists[0][1].data[1] ** 2 - values_vec[2].list_of_lists[0][1].data[2] ** 2 + values_vec[2].list_of_lists[0][1].data[3] ** 2 @@ -440,7 +440,7 @@ def python_function( _values_vec_out[144] = _tmp33 * values_vec[2].list_of_lists[0][2].data[1] _values_vec_out[145] = _tmp33 * values_vec[2].list_of_lists[0][2].data[2] _values_vec_out[146] = ( - -values_vec[2].list_of_lists[0][2].data[0] ** 2 + -(values_vec[2].list_of_lists[0][2].data[0] ** 2) - values_vec[2].list_of_lists[0][2].data[1] ** 2 - values_vec[2].list_of_lists[0][2].data[2] ** 2 + values_vec[2].list_of_lists[0][2].data[3] ** 2 @@ -449,7 +449,7 @@ def python_function( _values_vec_out[148] = _tmp34 * values_vec[2].list_of_lists[1][0].data[1] _values_vec_out[149] = _tmp34 * values_vec[2].list_of_lists[1][0].data[2] _values_vec_out[150] = ( - -values_vec[2].list_of_lists[1][0].data[0] ** 2 + -(values_vec[2].list_of_lists[1][0].data[0] ** 2) - values_vec[2].list_of_lists[1][0].data[1] ** 2 - values_vec[2].list_of_lists[1][0].data[2] ** 2 + values_vec[2].list_of_lists[1][0].data[3] ** 2 @@ -458,7 +458,7 @@ def python_function( _values_vec_out[152] = _tmp35 * values_vec[2].list_of_lists[1][1].data[1] _values_vec_out[153] = _tmp35 * values_vec[2].list_of_lists[1][1].data[2] _values_vec_out[154] = ( - -values_vec[2].list_of_lists[1][1].data[0] ** 2 + -(values_vec[2].list_of_lists[1][1].data[0] ** 2) - values_vec[2].list_of_lists[1][1].data[1] ** 2 - values_vec[2].list_of_lists[1][1].data[2] ** 2 + values_vec[2].list_of_lists[1][1].data[3] ** 2 @@ -467,7 +467,7 @@ def python_function( _values_vec_out[156] = _tmp36 * values_vec[2].list_of_lists[1][2].data[1] _values_vec_out[157] = _tmp36 * values_vec[2].list_of_lists[1][2].data[2] _values_vec_out[158] = ( - -values_vec[2].list_of_lists[1][2].data[0] ** 2 + -(values_vec[2].list_of_lists[1][2].data[0] ** 2) - values_vec[2].list_of_lists[1][2].data[1] ** 2 - values_vec[2].list_of_lists[1][2].data[2] ** 2 + values_vec[2].list_of_lists[1][2].data[3] ** 2 @@ -476,7 +476,7 @@ def python_function( _values_vec_out[160] = _tmp37 * values_vec[2].list_of_lists[2][0].data[1] _values_vec_out[161] = _tmp37 * values_vec[2].list_of_lists[2][0].data[2] _values_vec_out[162] = ( - -values_vec[2].list_of_lists[2][0].data[0] ** 2 + -(values_vec[2].list_of_lists[2][0].data[0] ** 2) - values_vec[2].list_of_lists[2][0].data[1] ** 2 - values_vec[2].list_of_lists[2][0].data[2] ** 2 + values_vec[2].list_of_lists[2][0].data[3] ** 2 @@ -485,7 +485,7 @@ def python_function( _values_vec_out[164] = _tmp38 * values_vec[2].list_of_lists[2][1].data[1] _values_vec_out[165] = _tmp38 * values_vec[2].list_of_lists[2][1].data[2] _values_vec_out[166] = ( - -values_vec[2].list_of_lists[2][1].data[0] ** 2 + -(values_vec[2].list_of_lists[2][1].data[0] ** 2) - values_vec[2].list_of_lists[2][1].data[1] ** 2 - values_vec[2].list_of_lists[2][1].data[2] ** 2 + values_vec[2].list_of_lists[2][1].data[3] ** 2 @@ -494,7 +494,7 @@ def python_function( _values_vec_out[168] = _tmp39 * values_vec[2].list_of_lists[2][2].data[1] _values_vec_out[169] = _tmp39 * values_vec[2].list_of_lists[2][2].data[2] _values_vec_out[170] = ( - -values_vec[2].list_of_lists[2][2].data[0] ** 2 + -(values_vec[2].list_of_lists[2][2].data[0] ** 2) - values_vec[2].list_of_lists[2][2].data[1] ** 2 - values_vec[2].list_of_lists[2][2].data[2] ** 2 + values_vec[2].list_of_lists[2][2].data[3] ** 2 @@ -506,7 +506,7 @@ def python_function( _values_vec_2D_out[3] = _tmp40 * values_vec_2D[0][0].rot.data[1] _values_vec_2D_out[4] = _tmp40 * values_vec_2D[0][0].rot.data[2] _values_vec_2D_out[5] = ( - -values_vec_2D[0][0].rot.data[0] ** 2 + -(values_vec_2D[0][0].rot.data[0] ** 2) - values_vec_2D[0][0].rot.data[1] ** 2 - values_vec_2D[0][0].rot.data[2] ** 2 + values_vec_2D[0][0].rot.data[3] ** 2 @@ -515,7 +515,7 @@ def python_function( _values_vec_2D_out[7] = _tmp41 * values_vec_2D[0][0].rot_vec[0].data[1] _values_vec_2D_out[8] = _tmp41 * values_vec_2D[0][0].rot_vec[0].data[2] _values_vec_2D_out[9] = ( - -values_vec_2D[0][0].rot_vec[0].data[0] ** 2 + -(values_vec_2D[0][0].rot_vec[0].data[0] ** 2) - values_vec_2D[0][0].rot_vec[0].data[1] ** 2 - values_vec_2D[0][0].rot_vec[0].data[2] ** 2 + values_vec_2D[0][0].rot_vec[0].data[3] ** 2 @@ -524,7 +524,7 @@ def python_function( _values_vec_2D_out[11] = _tmp42 * values_vec_2D[0][0].rot_vec[1].data[1] _values_vec_2D_out[12] = _tmp42 * values_vec_2D[0][0].rot_vec[1].data[2] _values_vec_2D_out[13] = ( - -values_vec_2D[0][0].rot_vec[1].data[0] ** 2 + -(values_vec_2D[0][0].rot_vec[1].data[0] ** 2) - values_vec_2D[0][0].rot_vec[1].data[1] ** 2 - values_vec_2D[0][0].rot_vec[1].data[2] ** 2 + values_vec_2D[0][0].rot_vec[1].data[3] ** 2 @@ -533,7 +533,7 @@ def python_function( _values_vec_2D_out[15] = _tmp43 * values_vec_2D[0][0].rot_vec[2].data[1] _values_vec_2D_out[16] = _tmp43 * values_vec_2D[0][0].rot_vec[2].data[2] _values_vec_2D_out[17] = ( - -values_vec_2D[0][0].rot_vec[2].data[0] ** 2 + -(values_vec_2D[0][0].rot_vec[2].data[0] ** 2) - values_vec_2D[0][0].rot_vec[2].data[1] ** 2 - values_vec_2D[0][0].rot_vec[2].data[2] ** 2 + values_vec_2D[0][0].rot_vec[2].data[3] ** 2 @@ -545,7 +545,7 @@ def python_function( _values_vec_2D_out[22] = _tmp44 * values_vec_2D[0][0].list_of_lists[0][0].data[1] _values_vec_2D_out[23] = _tmp44 * values_vec_2D[0][0].list_of_lists[0][0].data[2] _values_vec_2D_out[24] = ( - -values_vec_2D[0][0].list_of_lists[0][0].data[0] ** 2 + -(values_vec_2D[0][0].list_of_lists[0][0].data[0] ** 2) - values_vec_2D[0][0].list_of_lists[0][0].data[1] ** 2 - values_vec_2D[0][0].list_of_lists[0][0].data[2] ** 2 + values_vec_2D[0][0].list_of_lists[0][0].data[3] ** 2 @@ -554,7 +554,7 @@ def python_function( _values_vec_2D_out[26] = _tmp45 * values_vec_2D[0][0].list_of_lists[0][1].data[1] _values_vec_2D_out[27] = _tmp45 * values_vec_2D[0][0].list_of_lists[0][1].data[2] _values_vec_2D_out[28] = ( - -values_vec_2D[0][0].list_of_lists[0][1].data[0] ** 2 + -(values_vec_2D[0][0].list_of_lists[0][1].data[0] ** 2) - values_vec_2D[0][0].list_of_lists[0][1].data[1] ** 2 - values_vec_2D[0][0].list_of_lists[0][1].data[2] ** 2 + values_vec_2D[0][0].list_of_lists[0][1].data[3] ** 2 @@ -563,7 +563,7 @@ def python_function( _values_vec_2D_out[30] = _tmp46 * values_vec_2D[0][0].list_of_lists[0][2].data[1] _values_vec_2D_out[31] = _tmp46 * values_vec_2D[0][0].list_of_lists[0][2].data[2] _values_vec_2D_out[32] = ( - -values_vec_2D[0][0].list_of_lists[0][2].data[0] ** 2 + -(values_vec_2D[0][0].list_of_lists[0][2].data[0] ** 2) - values_vec_2D[0][0].list_of_lists[0][2].data[1] ** 2 - values_vec_2D[0][0].list_of_lists[0][2].data[2] ** 2 + values_vec_2D[0][0].list_of_lists[0][2].data[3] ** 2 @@ -572,7 +572,7 @@ def python_function( _values_vec_2D_out[34] = _tmp47 * values_vec_2D[0][0].list_of_lists[1][0].data[1] _values_vec_2D_out[35] = _tmp47 * values_vec_2D[0][0].list_of_lists[1][0].data[2] _values_vec_2D_out[36] = ( - -values_vec_2D[0][0].list_of_lists[1][0].data[0] ** 2 + -(values_vec_2D[0][0].list_of_lists[1][0].data[0] ** 2) - values_vec_2D[0][0].list_of_lists[1][0].data[1] ** 2 - values_vec_2D[0][0].list_of_lists[1][0].data[2] ** 2 + values_vec_2D[0][0].list_of_lists[1][0].data[3] ** 2 @@ -581,7 +581,7 @@ def python_function( _values_vec_2D_out[38] = _tmp48 * values_vec_2D[0][0].list_of_lists[1][1].data[1] _values_vec_2D_out[39] = _tmp48 * values_vec_2D[0][0].list_of_lists[1][1].data[2] _values_vec_2D_out[40] = ( - -values_vec_2D[0][0].list_of_lists[1][1].data[0] ** 2 + -(values_vec_2D[0][0].list_of_lists[1][1].data[0] ** 2) - values_vec_2D[0][0].list_of_lists[1][1].data[1] ** 2 - values_vec_2D[0][0].list_of_lists[1][1].data[2] ** 2 + values_vec_2D[0][0].list_of_lists[1][1].data[3] ** 2 @@ -590,7 +590,7 @@ def python_function( _values_vec_2D_out[42] = _tmp49 * values_vec_2D[0][0].list_of_lists[1][2].data[1] _values_vec_2D_out[43] = _tmp49 * values_vec_2D[0][0].list_of_lists[1][2].data[2] _values_vec_2D_out[44] = ( - -values_vec_2D[0][0].list_of_lists[1][2].data[0] ** 2 + -(values_vec_2D[0][0].list_of_lists[1][2].data[0] ** 2) - values_vec_2D[0][0].list_of_lists[1][2].data[1] ** 2 - values_vec_2D[0][0].list_of_lists[1][2].data[2] ** 2 + values_vec_2D[0][0].list_of_lists[1][2].data[3] ** 2 @@ -599,7 +599,7 @@ def python_function( _values_vec_2D_out[46] = _tmp50 * values_vec_2D[0][0].list_of_lists[2][0].data[1] _values_vec_2D_out[47] = _tmp50 * values_vec_2D[0][0].list_of_lists[2][0].data[2] _values_vec_2D_out[48] = ( - -values_vec_2D[0][0].list_of_lists[2][0].data[0] ** 2 + -(values_vec_2D[0][0].list_of_lists[2][0].data[0] ** 2) - values_vec_2D[0][0].list_of_lists[2][0].data[1] ** 2 - values_vec_2D[0][0].list_of_lists[2][0].data[2] ** 2 + values_vec_2D[0][0].list_of_lists[2][0].data[3] ** 2 @@ -608,7 +608,7 @@ def python_function( _values_vec_2D_out[50] = _tmp51 * values_vec_2D[0][0].list_of_lists[2][1].data[1] _values_vec_2D_out[51] = _tmp51 * values_vec_2D[0][0].list_of_lists[2][1].data[2] _values_vec_2D_out[52] = ( - -values_vec_2D[0][0].list_of_lists[2][1].data[0] ** 2 + -(values_vec_2D[0][0].list_of_lists[2][1].data[0] ** 2) - values_vec_2D[0][0].list_of_lists[2][1].data[1] ** 2 - values_vec_2D[0][0].list_of_lists[2][1].data[2] ** 2 + values_vec_2D[0][0].list_of_lists[2][1].data[3] ** 2 @@ -617,7 +617,7 @@ def python_function( _values_vec_2D_out[54] = _tmp52 * values_vec_2D[0][0].list_of_lists[2][2].data[1] _values_vec_2D_out[55] = _tmp52 * values_vec_2D[0][0].list_of_lists[2][2].data[2] _values_vec_2D_out[56] = ( - -values_vec_2D[0][0].list_of_lists[2][2].data[0] ** 2 + -(values_vec_2D[0][0].list_of_lists[2][2].data[0] ** 2) - values_vec_2D[0][0].list_of_lists[2][2].data[1] ** 2 - values_vec_2D[0][0].list_of_lists[2][2].data[2] ** 2 + values_vec_2D[0][0].list_of_lists[2][2].data[3] ** 2 @@ -628,7 +628,7 @@ def python_function( _values_vec_2D_out[60] = _tmp53 * values_vec_2D[1][0].rot.data[1] _values_vec_2D_out[61] = _tmp53 * values_vec_2D[1][0].rot.data[2] _values_vec_2D_out[62] = ( - -values_vec_2D[1][0].rot.data[0] ** 2 + -(values_vec_2D[1][0].rot.data[0] ** 2) - values_vec_2D[1][0].rot.data[1] ** 2 - values_vec_2D[1][0].rot.data[2] ** 2 + values_vec_2D[1][0].rot.data[3] ** 2 @@ -637,7 +637,7 @@ def python_function( _values_vec_2D_out[64] = _tmp54 * values_vec_2D[1][0].rot_vec[0].data[1] _values_vec_2D_out[65] = _tmp54 * values_vec_2D[1][0].rot_vec[0].data[2] _values_vec_2D_out[66] = ( - -values_vec_2D[1][0].rot_vec[0].data[0] ** 2 + -(values_vec_2D[1][0].rot_vec[0].data[0] ** 2) - values_vec_2D[1][0].rot_vec[0].data[1] ** 2 - values_vec_2D[1][0].rot_vec[0].data[2] ** 2 + values_vec_2D[1][0].rot_vec[0].data[3] ** 2 @@ -646,7 +646,7 @@ def python_function( _values_vec_2D_out[68] = _tmp55 * values_vec_2D[1][0].rot_vec[1].data[1] _values_vec_2D_out[69] = _tmp55 * values_vec_2D[1][0].rot_vec[1].data[2] _values_vec_2D_out[70] = ( - -values_vec_2D[1][0].rot_vec[1].data[0] ** 2 + -(values_vec_2D[1][0].rot_vec[1].data[0] ** 2) - values_vec_2D[1][0].rot_vec[1].data[1] ** 2 - values_vec_2D[1][0].rot_vec[1].data[2] ** 2 + values_vec_2D[1][0].rot_vec[1].data[3] ** 2 @@ -655,7 +655,7 @@ def python_function( _values_vec_2D_out[72] = _tmp56 * values_vec_2D[1][0].rot_vec[2].data[1] _values_vec_2D_out[73] = _tmp56 * values_vec_2D[1][0].rot_vec[2].data[2] _values_vec_2D_out[74] = ( - -values_vec_2D[1][0].rot_vec[2].data[0] ** 2 + -(values_vec_2D[1][0].rot_vec[2].data[0] ** 2) - values_vec_2D[1][0].rot_vec[2].data[1] ** 2 - values_vec_2D[1][0].rot_vec[2].data[2] ** 2 + values_vec_2D[1][0].rot_vec[2].data[3] ** 2 @@ -667,7 +667,7 @@ def python_function( _values_vec_2D_out[79] = _tmp57 * values_vec_2D[1][0].list_of_lists[0][0].data[1] _values_vec_2D_out[80] = _tmp57 * values_vec_2D[1][0].list_of_lists[0][0].data[2] _values_vec_2D_out[81] = ( - -values_vec_2D[1][0].list_of_lists[0][0].data[0] ** 2 + -(values_vec_2D[1][0].list_of_lists[0][0].data[0] ** 2) - values_vec_2D[1][0].list_of_lists[0][0].data[1] ** 2 - values_vec_2D[1][0].list_of_lists[0][0].data[2] ** 2 + values_vec_2D[1][0].list_of_lists[0][0].data[3] ** 2 @@ -676,7 +676,7 @@ def python_function( _values_vec_2D_out[83] = _tmp58 * values_vec_2D[1][0].list_of_lists[0][1].data[1] _values_vec_2D_out[84] = _tmp58 * values_vec_2D[1][0].list_of_lists[0][1].data[2] _values_vec_2D_out[85] = ( - -values_vec_2D[1][0].list_of_lists[0][1].data[0] ** 2 + -(values_vec_2D[1][0].list_of_lists[0][1].data[0] ** 2) - values_vec_2D[1][0].list_of_lists[0][1].data[1] ** 2 - values_vec_2D[1][0].list_of_lists[0][1].data[2] ** 2 + values_vec_2D[1][0].list_of_lists[0][1].data[3] ** 2 @@ -685,7 +685,7 @@ def python_function( _values_vec_2D_out[87] = _tmp59 * values_vec_2D[1][0].list_of_lists[0][2].data[1] _values_vec_2D_out[88] = _tmp59 * values_vec_2D[1][0].list_of_lists[0][2].data[2] _values_vec_2D_out[89] = ( - -values_vec_2D[1][0].list_of_lists[0][2].data[0] ** 2 + -(values_vec_2D[1][0].list_of_lists[0][2].data[0] ** 2) - values_vec_2D[1][0].list_of_lists[0][2].data[1] ** 2 - values_vec_2D[1][0].list_of_lists[0][2].data[2] ** 2 + values_vec_2D[1][0].list_of_lists[0][2].data[3] ** 2 @@ -694,7 +694,7 @@ def python_function( _values_vec_2D_out[91] = _tmp60 * values_vec_2D[1][0].list_of_lists[1][0].data[1] _values_vec_2D_out[92] = _tmp60 * values_vec_2D[1][0].list_of_lists[1][0].data[2] _values_vec_2D_out[93] = ( - -values_vec_2D[1][0].list_of_lists[1][0].data[0] ** 2 + -(values_vec_2D[1][0].list_of_lists[1][0].data[0] ** 2) - values_vec_2D[1][0].list_of_lists[1][0].data[1] ** 2 - values_vec_2D[1][0].list_of_lists[1][0].data[2] ** 2 + values_vec_2D[1][0].list_of_lists[1][0].data[3] ** 2 @@ -703,7 +703,7 @@ def python_function( _values_vec_2D_out[95] = _tmp61 * values_vec_2D[1][0].list_of_lists[1][1].data[1] _values_vec_2D_out[96] = _tmp61 * values_vec_2D[1][0].list_of_lists[1][1].data[2] _values_vec_2D_out[97] = ( - -values_vec_2D[1][0].list_of_lists[1][1].data[0] ** 2 + -(values_vec_2D[1][0].list_of_lists[1][1].data[0] ** 2) - values_vec_2D[1][0].list_of_lists[1][1].data[1] ** 2 - values_vec_2D[1][0].list_of_lists[1][1].data[2] ** 2 + values_vec_2D[1][0].list_of_lists[1][1].data[3] ** 2 @@ -712,7 +712,7 @@ def python_function( _values_vec_2D_out[99] = _tmp62 * values_vec_2D[1][0].list_of_lists[1][2].data[1] _values_vec_2D_out[100] = _tmp62 * values_vec_2D[1][0].list_of_lists[1][2].data[2] _values_vec_2D_out[101] = ( - -values_vec_2D[1][0].list_of_lists[1][2].data[0] ** 2 + -(values_vec_2D[1][0].list_of_lists[1][2].data[0] ** 2) - values_vec_2D[1][0].list_of_lists[1][2].data[1] ** 2 - values_vec_2D[1][0].list_of_lists[1][2].data[2] ** 2 + values_vec_2D[1][0].list_of_lists[1][2].data[3] ** 2 @@ -721,7 +721,7 @@ def python_function( _values_vec_2D_out[103] = _tmp63 * values_vec_2D[1][0].list_of_lists[2][0].data[1] _values_vec_2D_out[104] = _tmp63 * values_vec_2D[1][0].list_of_lists[2][0].data[2] _values_vec_2D_out[105] = ( - -values_vec_2D[1][0].list_of_lists[2][0].data[0] ** 2 + -(values_vec_2D[1][0].list_of_lists[2][0].data[0] ** 2) - values_vec_2D[1][0].list_of_lists[2][0].data[1] ** 2 - values_vec_2D[1][0].list_of_lists[2][0].data[2] ** 2 + values_vec_2D[1][0].list_of_lists[2][0].data[3] ** 2 @@ -730,7 +730,7 @@ def python_function( _values_vec_2D_out[107] = _tmp64 * values_vec_2D[1][0].list_of_lists[2][1].data[1] _values_vec_2D_out[108] = _tmp64 * values_vec_2D[1][0].list_of_lists[2][1].data[2] _values_vec_2D_out[109] = ( - -values_vec_2D[1][0].list_of_lists[2][1].data[0] ** 2 + -(values_vec_2D[1][0].list_of_lists[2][1].data[0] ** 2) - values_vec_2D[1][0].list_of_lists[2][1].data[1] ** 2 - values_vec_2D[1][0].list_of_lists[2][1].data[2] ** 2 + values_vec_2D[1][0].list_of_lists[2][1].data[3] ** 2 @@ -739,7 +739,7 @@ def python_function( _values_vec_2D_out[111] = _tmp65 * values_vec_2D[1][0].list_of_lists[2][2].data[1] _values_vec_2D_out[112] = _tmp65 * values_vec_2D[1][0].list_of_lists[2][2].data[2] _values_vec_2D_out[113] = ( - -values_vec_2D[1][0].list_of_lists[2][2].data[0] ** 2 + -(values_vec_2D[1][0].list_of_lists[2][2].data[0] ** 2) - values_vec_2D[1][0].list_of_lists[2][2].data[1] ** 2 - values_vec_2D[1][0].list_of_lists[2][2].data[2] ** 2 + values_vec_2D[1][0].list_of_lists[2][2].data[3] ** 2 diff --git a/test/symforce_function_codegen_test_data/sympy/databuffer_codegen_test_data/python/symforce/buffer_test/buffer_func.py b/test/symforce_function_codegen_test_data/sympy/databuffer_codegen_test_data/python/symforce/buffer_test/buffer_func.py index e9252e489..14c23d51d 100644 --- a/test/symforce_function_codegen_test_data/sympy/databuffer_codegen_test_data/python/symforce/buffer_test/buffer_func.py +++ b/test/symforce_function_codegen_test_data/sympy/databuffer_codegen_test_data/python/symforce/buffer_test/buffer_func.py @@ -35,5 +35,5 @@ def buffer_func(buffer, a, b): # Intermediate terms (0) # Output terms - _result = a + b + buffer[int((-a + b) * (a + b))] + buffer[int(-(a ** 2) + b ** 2)] + _result = a + b + buffer[int((-a + b) * (a + b))] + buffer[int(-(a**2) + b**2)] return _result diff --git a/test/symforce_generated_residual_cache_test.py b/test/symforce_generated_residual_cache_test.py index e6fb54536..40710d670 100644 --- a/test/symforce_generated_residual_cache_test.py +++ b/test/symforce_generated_residual_cache_test.py @@ -19,9 +19,9 @@ class GeneratedResidualCacheTest(TestCase): """ @staticmethod - def example_index_keys_and_residual() -> T.Tuple[ - SimilarityIndex, T.Set[str], T.Dict[str, T.Any], T.Callable - ]: + def example_index_keys_and_residual() -> ( + T.Tuple[SimilarityIndex, T.Set[str], T.Dict[str, T.Any], T.Callable] + ): index = SimilarityIndex( inputs=Values(rot=sf.Rot3.symbolic("a")), outputs=Values(out=sf.Rot3.symbolic("a").inverse()), diff --git a/test/symforce_noise_model_test.py b/test/symforce_noise_model_test.py index 973dd7afa..91a9ed26b 100644 --- a/test/symforce_noise_model_test.py +++ b/test/symforce_noise_model_test.py @@ -189,7 +189,7 @@ def test_barron_noise_model(self) -> None: jac = error.jacobian(x_matrix) test3a = error.subs(x, 1000.0).evalf() - self.assertStorageNear(test3a, delta ** 2, places=2) + self.assertStorageNear(test3a, delta**2, places=2) test3b = jac.subs(x, 1000.0).evalf() self.assertStorageNear(test3b, 0.0) diff --git a/test/symforce_py_optimizer_test.py b/test/symforce_py_optimizer_test.py index 80fd01790..36bb568ba 100644 --- a/test/symforce_py_optimizer_test.py +++ b/test/symforce_py_optimizer_test.py @@ -104,7 +104,8 @@ def prior_residual(x: sf.Rot3, epsilon: sf.Scalar, x_prior: sf.Rot3) -> sf.V3: # Check that the factor cache has the expected number of entries self.assertEqual( - len(Factor._generated_residual_cache), 2 # pylint: disable=protected-access + len(Factor._generated_residual_cache), # pylint: disable=protected-access + 2, ) index_entry2 = optimizer.linearization_index_entry("x1") @@ -161,7 +162,8 @@ def between(x: T.Scalar, y: T.Scalar, b: T.Scalar) -> sf.V1: # Check that the factor cache has the expected number of entries self.assertEqual( - len(Factor._generated_residual_cache), 2 # pylint: disable=protected-access + len(Factor._generated_residual_cache), # pylint: disable=protected-access + 2, ) diff --git a/test/symforce_sympy_overrides_test.py b/test/symforce_sympy_overrides_test.py index 3b88e09ca..916977ffd 100644 --- a/test/symforce_sympy_overrides_test.py +++ b/test/symforce_sympy_overrides_test.py @@ -40,10 +40,10 @@ def test_derivatives(self) -> None: x, y = sf.symbols("x y") self.assertEqual(sf.floor(x).diff(x), 0) - self.assertEqual(sf.floor(x ** 2).diff(x), 0) + self.assertEqual(sf.floor(x**2).diff(x), 0) self.assertEqual(sf.sign(x).diff(x), 0) - self.assertEqual(sf.sign(x ** 2).diff(x), 0) + self.assertEqual(sf.sign(x**2).diff(x), 0) def numerical_derivative( f: T.Callable[[sf.Scalar], sf.Scalar], x: sf.Scalar, delta: float = 1e-8 diff --git a/test/symforce_types_codegen_test.py b/test/symforce_types_codegen_test.py index 28a30b9fb..0961ce4dd 100644 --- a/test/symforce_types_codegen_test.py +++ b/test/symforce_types_codegen_test.py @@ -46,8 +46,8 @@ def build_values() -> T.Tuple[Values, Values]: inputs["p"] = sf.V2.symbolic("p") outputs = Values() - outputs["foo"] = x ** 2 + inputs["rot"].q.w - outputs["bar"] = inputs.attr.constants.epsilon + sf.sin(inputs.attr.y) + x ** 2 + outputs["foo"] = x**2 + inputs["rot"].q.w + outputs["bar"] = inputs.attr.constants.epsilon + sf.sin(inputs.attr.y) + x**2 return inputs, outputs diff --git a/test/symforce_values_test.py b/test/symforce_values_test.py index 6a17ed6ae..207eb6553 100644 --- a/test/symforce_values_test.py +++ b/test/symforce_values_test.py @@ -510,7 +510,7 @@ def test_to_from_storage_with_tuples(self) -> None: self.assertEqual(v_tuple["pair"], v_after["pair"]) x = sf.Symbol("x") - v_tuple["pair"] = (x, x ** 2) + v_tuple["pair"] = (x, x**2) v_after = Values.from_storage_index(v_tuple.to_storage(), v_tuple.index()) self.assertEqual(v_tuple["pair"], v_after["pair"])