Skip to content

Defer optional SymPy imports until symbolic operations need them - #264

Open
RoboX2020 wants to merge 7 commits into
rai-opensource:masterfrom
RoboX2020:perf/lazy-sympy
Open

RoboX2020 wants to merge 7 commits into
rai-opensource:masterfrom
RoboX2020:perf/lazy-sympy

Conversation

@RoboX2020

Copy link
Copy Markdown

Part of #234, covering the SymPy half only. The SciPy work remains separate in #244.

import spatialmath no longer loads SymPy just to check scalar types. issymbol() checks the already-loaded module, and scalar/vector checks use it dynamically so importing SymPy after SpatialMath works too.

The other eager SymPy imports in vector norms, object-matrix determinants and 2D pose extraction are deferred. Explicit symbolic helpers load the optional dependency when called; explicit access to Symbol and symtype remains available.

Added nine isolated-process test cases covering numeric imports and operations, both import orders, symbolic arithmetic and transforms, explicit helpers and legacy aliases, and numeric use with SymPy blocked.

Validation: Python 3.10/Linux, MPLBACKEND=Agg python -m pytest tests/ -p no:xvfb -q: 389 passed, 3 skipped, 18 subtests passed. No timing claim is made here. Other Python versions and platforms were not tested.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant