You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are various circular dependencies in the sympy.physics.vector module. This was also pointed out in #26384, where a new circular import will be added.
The aim of this issue is to see whether it might be possible to reduce the number of circular.
As an overview, I've made a (mostly) complete list of all circular imports.
vector.py:
No import from physics.vector at the start of the module.
Vector.dot: from .dyadic import Dyadic, _check_dyadic both used for the same type check (Dyadic could be removed)
Vector.outer: from .dyadic import Dyadic uses Dyadic(...)
Vector._pretty: from sympy.printing.pretty.stringpict import prettyForm
Vector.cross: from .dyadic import Dyadic, _check_dyadic both used for the same type check and uses Dyadic(0)
Vector.diff: from sympy.physics.vector.frame import _check_frame
Vector.express: from .functions import express used as forward call
Vector.dt: from .functions import time_derivative used as forward call
Vector.free_dynamicsymbols: from sympy.physics.mechanics.functions import find_dynamicsymbols
dyadic.py:
No import from physics.vector at the start of the module.
Dyadic.dot: from .vector import Vector, _check_vector used for type checking and creation of Vector(0)
Dyadic.cross: from .vector import _check_vector used for type checking
Dyadic.express: from .functions import express used as forward call
Dyadic.dt: from .functions import time_derivative used as forward call
frame.py:
from .vector import Vector, _check_vector at the top of the module. Utilized abundantly.
ReferenceFrame._w_diff_dcm: from .functions import dynamicsymbols utilized to get the time symbol
ReferenceFrame.orient_axis: from .functions import dynamicsymbols utilized to get the time symbol
ReferenceFrame.orient_body_fixed: from .functions import dynamicsymbols utilized to get the time symbol
ReferenceFrame.orient_space_fixed: from .functions import dynamicsymbols utilized to get the time symbol
ReferenceFrame.orient_quaternion: from .functions import dynamicsymbols utilized to get the time symbol
_check_frame: from .vector import VectorTypeError to raise an exception (this one could be moved to the top of the module)
express uses _check_frame, CoordinateSym, Dyadic, and Vector for type checking. Vector(...), Vector.simp, and Dyadic(0) are used.
time_derivative uses _check_frame, Vector, and Dyadic for type checking. Vector(...) and Dyadic(0) are used.
outer uses Vector for type checking
kinematic_equations uses none
get_motion_params uses _check_vector, _check_frame, and Vector(0)
partial_velocity uses Vector(0)
dynamicsymbols uses none (even no other functions from functions.py)
Some preliminary conclusions:
Vector and Dyadic form the basis of the module on which everything depends. ReferenceFrame is next, followed by Point. functions should be a gathering place of overarching functions.
Several of the above could be resolved if we would move _check_... to a separate module without them using any isinstance checks.
We could/should move dynamicsymbols and find_dynamicsymbols also to a separate module.
The text was updated successfully, but these errors were encountered:
Vector and Dyadic form the basis of the module on which everything depends. ReferenceFrame is next, followed by Point. functions should be a gathering place of overarching functions.
As function.py should be seen as a gathering place of overarching functions, I would also suggest having the type-specific implementation of express and time_derivative to Vector and Dyadic.
Yes, we should just be able to make express and dt methods in Vector and Dyadic and they be the primary implementations. Then the express and time_derivative in functions.py are just wrappers around the methods.
There are various circular dependencies in the
sympy.physics.vector
module. This was also pointed out in #26384, where a new circular import will be added.The aim of this issue is to see whether it might be possible to reduce the number of circular.
As an overview, I've made a (mostly) complete list of all circular imports.
vector.py
:physics.vector
at the start of the module.Vector.dot
:from .dyadic import Dyadic, _check_dyadic
both used for the same type check (Dyadic
could be removed)Vector.outer
:from .dyadic import Dyadic
usesDyadic(...)
Vector._pretty
:from sympy.printing.pretty.stringpict import prettyForm
Vector.cross
:from .dyadic import Dyadic, _check_dyadic
both used for the same type check and usesDyadic(0)
Vector.diff
:from sympy.physics.vector.frame import _check_frame
Vector.express
:from .functions import express
used as forward callVector.dt
:from .functions import time_derivative
used as forward callVector.free_dynamicsymbols
:from sympy.physics.mechanics.functions import find_dynamicsymbols
dyadic.py
:physics.vector
at the start of the module.Dyadic.dot
:from .vector import Vector, _check_vector
used for type checking and creation ofVector(0)
Dyadic.cross
:from .vector import _check_vector
used for type checkingDyadic.express
:from .functions import express
used as forward callDyadic.dt
:from .functions import time_derivative
used as forward callframe.py
:from .vector import Vector, _check_vector
at the top of the module. Utilized abundantly.ReferenceFrame._w_diff_dcm
:from .functions import dynamicsymbols
utilized to get the time symbolReferenceFrame.orient_axis
:from .functions import dynamicsymbols
utilized to get the time symbolReferenceFrame.orient_body_fixed
:from .functions import dynamicsymbols
utilized to get the time symbolReferenceFrame.orient_space_fixed
:from .functions import dynamicsymbols
utilized to get the time symbolReferenceFrame.orient_quaternion
:from .functions import dynamicsymbols
utilized to get the time symbol_check_frame
:from .vector import VectorTypeError
to raise an exception (this one could be moved to the top of the module)ReferenceFrame.partial_velocity
:from .functions import partial_velocity
(will be introduced in physics/vector: Improved speed of Point/Frame partial_velocity methods #26384)point.py
:from .vector import Vector, _check_vector
used for type checking and creation ofVector(0)
from .frame import _check_frame
Point.partial_velocity
:from .functions import partial_velocity
(will be introduced in physics/vector: Improved speed of Point/Frame partial_velocity methods #26384)functions.py
:from .vector import Vector, _check_vector
from .frame import CoordinateSym, _check_frame
from .dyadic import Dyadic
cross
usesVector
andDyadic
for type checkingdot
usesVector
andDyadic
for type checkingexpress
uses_check_frame
,CoordinateSym
,Dyadic
, andVector
for type checking.Vector(...)
,Vector.simp
, andDyadic(0)
are used.time_derivative
uses_check_frame
,Vector
, andDyadic
for type checking.Vector(...)
andDyadic(0)
are used.outer
usesVector
for type checkingkinematic_equations
uses noneget_motion_params
uses_check_vector
,_check_frame
, andVector(0)
partial_velocity
usesVector(0)
dynamicsymbols
uses none (even no other functions from functions.py)Some preliminary conclusions:
Vector
andDyadic
form the basis of the module on which everything depends.ReferenceFrame
is next, followed byPoint
.functions
should be a gathering place of overarching functions._check_...
to a separate module without them using anyisinstance
checks.dynamicsymbols
andfind_dynamicsymbols
also to a separate module.The text was updated successfully, but these errors were encountered: