Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make physics.mechanics.wrapping_geometry public #25510

Merged
merged 23 commits into from Aug 15, 2023

Conversation

moorepants
Copy link
Member

@moorepants moorepants commented Aug 14, 2023

References to other Issues or PRs

Original PR: #25068

Brief description of what is fixed or changed

Makes sympy.physics.mechanics.wrapping_geometry public and improves documentation.

Other comments

Release Notes

  • physics.mechanics
    • Wrapping geometry module with a Sphere and Cylinder added for facilitating eventual force actuator wrapping needs.

@sympy-bot
Copy link

sympy-bot commented Aug 14, 2023

Hi, I am the SymPy bot (v170). I'm here to help you write a release notes entry. Please read the guide on how to write release notes.

Your release notes are in good order.

Here is what the release notes will look like:

  • physics.mechanics
    • Wrapping geometry module with a Sphere and Cylinder added for facilitating eventual force actuator wrapping needs. (#25510 by @brocksam and @moorepants)

This will be added to https://github.com/sympy/sympy/wiki/Release-Notes-for-1.13.

Click here to see the pull request description that was parsed.
<!-- Your title above should be a short description of what
was changed. Do not include the issue number in the title. -->

#### References to other Issues or PRs
<!-- If this pull request fixes an issue, write "Fixes #NNNN" in that exact
format, e.g. "Fixes #1234" (see
https://tinyurl.com/auto-closing for more information). Also, please
write a comment on that issue linking back to this pull request once it is
open. -->

Original PR: https://github.com/sympy/sympy/pull/25068

#### Brief description of what is fixed or changed

Makes `sympy.physics.mechanics.wrapping_geometry` public and improves documentation.

#### Other comments


#### Release Notes

<!-- Write the release notes for this release below between the BEGIN and END
statements. The basic format is a bulleted list with the name of the subpackage
and the release note for this PR. For example:

* solvers
  * Added a new solver for logarithmic equations.

* functions
  * Fixed a bug with log of integers. Formerly, `log(-x)` incorrectly gave `-log(x)`.

* physics.units
  * Corrected a semantical error in the conversion between volt and statvolt which
    reported the volt as being larger than the statvolt.

or if no release note(s) should be included use:

NO ENTRY

See https://github.com/sympy/sympy/wiki/Writing-Release-Notes for more
information on how to write release notes. The bot will check your release
notes automatically to see if they are formatted correctly. -->

<!-- BEGIN RELEASE NOTES -->

* physics.mechanics
  * Wrapping geometry module with a Sphere and Cylinder added for facilitating eventual force actuator wrapping needs.

<!-- END RELEASE NOTES -->

Update

The release notes on the wiki have been updated.

@moorepants moorepants added CZI: Codegen/Biomech Sam Brockie's CZI-funded postdoc work on codegen and biomechanics physics.mechanics labels Aug 14, 2023
@moorepants
Copy link
Member Author

GeometryBase should also be made public so that users can import and build their own geometries. Right?

@moorepants
Copy link
Member Author

moorepants commented Aug 14, 2023

What do you think of renaming the module to wrapping_geometry? geometry is quite general and there could certainly be other geometry needs in the future. If we name it wrapping_geometry it also may better belong in biomechanics.

The decision behind calling it just geometry was to try and keep module names short. But I see that wrapping_geometry is clearer. Happy to rename it.

I think it still belongs in physics.mechanics. Nothing about this is biomechanics-specific, someone could still use this with springs and dampers.

@sympy-bot
Copy link

sympy-bot commented Aug 14, 2023

🟠

Hi, I am the SymPy bot (v170). I've noticed that some of your commits add or delete files. Since this is sometimes done unintentionally, I wanted to alert you about it.

This is an experimental feature of SymPy Bot. If you have any feedback on it, please comment at sympy/sympy-bot#75.

The following commits add new files:

  • 5df0e3d:
    • doc/src/modules/physics/mechanics/api/geometry.rst

If these files were added/deleted on purpose, you can ignore this message.

@moorepants moorepants marked this pull request as ready for review August 14, 2023 13:08
@moorepants moorepants changed the title Make _geometry public in docstrings and minor docstring edits. Make _geometry public Aug 14, 2023
@moorepants moorepants changed the title Make _geometry public Make physics.mechanics._geometry public Aug 14, 2023
@brocksam
Copy link
Contributor

GeometryBase should also be made public so that users can import and build their own geometries. Right?

Yes, I agree that the base classes should be public and in the main module namespace.

@moorepants
Copy link
Member Author

moorepants commented Aug 14, 2023

Getting these new docs errors:

home/moorepants/src/sympy/sympy/physics/mechanics/geometry.py:docstring of sympy.physics.mechanics.geometry.Cylinder:1: WARNING: more than one target found for cross-reference 'Point': sympy.diffgeom.Point, sympy.diffgeom.diffgeom.Point, sympy.geometry.point.Point, sympy.physics.vector.point.Point

Need to make explicit references to these points.

EDIT : Seems that this is tied to the type annotations that use Point. Sphinx selects the diffgeom point instead of the correct one. This is odd, given that the type annotation is a real Python object, not just a string (like in a docstring).

@moorepants
Copy link
Member Author

Similar issue about the warning: sphinx-doc/sphinx#10400

@moorepants
Copy link
Member Author

May also be related: sphinx-doc/sphinx#4961

@moorepants
Copy link
Member Author

I tried something like:

from sympy.physics.vector import point as point_module

and then in type annotation use point : point_module.Point but that didn't work.

@moorepants
Copy link
Member Author

The type annotations cause these types of warnings when using autodoc and numpydoc with Sphinx:

/home/moorepants/src/sympy/sympy/physics/mechanics/geometry.py:docstring of sympy.physics.mechanics.geometry.Cylinder:1: WARNING: more than one target found for cross-reference 'Point': sympy.diffgeom.Point, sympy.diffgeom.diffgeom.Point, sympy.geometry.point.Point, sympy.physics.vector.point.Point
/home/moorepants/src/sympy/sympy/physics/mechanics/geometry.py:docstring of sympy.physics.mechanics.geometry.Cylinder:1: WARNING: more than one target found for cross-reference 'Vector': sympy.physics.vector.vector.Vector, sympy.vector.vector.Vector
/home/moorepants/src/sympy/sympy/physics/mechanics/geometry.py:docstring of sympy.physics.mechanics.geometry.Cylinder.geodesic_length:1: WARNING: more than one target found for cross-reference 'Point': sympy.diffgeom.Point, sympy.diffgeom.diffgeom.Point, sympy.geometry.point.Point, sympy.physics.vector.point.Point
/home/moorepants/src/sympy/sympy/physics/mechanics/geometry.py:docstring of sympy.physics.mechanics.geometry.Cylinder.geodesic_length:1: WARNING: more than one target found for cross-reference 'Point': sympy.diffgeom.Point, sympy.diffgeom.diffgeom.Point, sympy.geometry.point.Point, sympy.physics.vector.point.Point
/home/moorepants/src/sympy/sympy/physics/mechanics/geometry.py:docstring of sympy.physics.mechanics.geometry.Cylinder.geodesic_length:1: WARNING: py:class reference target not found: ExprType
/home/moorepants/src/sympy/sympy/physics/mechanics/geometry.py:docstring of sympy.physics.mechanics.geometry.Cylinder.point:1: WARNING: more than one target found for cross-reference 'Point': sympy.diffgeom.Point, sympy.diffgeom.diffgeom.Point, sympy.geometry.point.Point, sympy.physics.vector.point.Point
/home/moorepants/src/sympy/sympy/physics/mechanics/geometry.py:docstring of sympy.physics.mechanics.geometry.GeometryBase.geodesic_length:1: WARNING: more than one target found for cross-reference 'Point': sympy.diffgeom.Point, sympy.diffgeom.diffgeom.Point, sympy.geometry.point.Point, sympy.physics.vector.point.Point
/home/moorepants/src/sympy/sympy/physics/mechanics/geometry.py:docstring of sympy.physics.mechanics.geometry.GeometryBase.geodesic_length:1: WARNING: more than one target found for cross-reference 'Point': sympy.diffgeom.Point, sympy.diffgeom.diffgeom.Point, sympy.geometry.point.Point, sympy.physics.vector.point.Point
/home/moorepants/src/sympy/sympy/physics/mechanics/geometry.py:docstring of sympy.physics.mechanics.geometry.GeometryBase.geodesic_length:1: WARNING: py:class reference target not found: ExprType
/home/moorepants/src/sympy/sympy/physics/mechanics/geometry.py:docstring of sympy.physics.mechanics.geometry.Sphere:1: WARNING: more than one target found for cross-reference 'Point': sympy.diffgeom.Point, sympy.diffgeom.diffgeom.Point, sympy.geometry.point.Point, sympy.physics.vector.point.Point
/home/moorepants/src/sympy/sympy/physics/mechanics/geometry.py:docstring of sympy.physics.mechanics.geometry.Sphere.geodesic_length:1: WARNING: more than one target found for cross-reference 'Point': sympy.diffgeom.Point, sympy.diffgeom.diffgeom.Point, sympy.geometry.point.Point, sympy.physics.vector.point.Point
/home/moorepants/src/sympy/sympy/physics/mechanics/geometry.py:docstring of sympy.physics.mechanics.geometry.Sphere.geodesic_length:1: WARNING: more than one target found for cross-reference 'Point': sympy.diffgeom.Point, sympy.diffgeom.diffgeom.Point, sympy.geometry.point.Point, sympy.physics.vector.point.Point
/home/moorepants/src/sympy/sympy/physics/mechanics/geometry.py:docstring of sympy.physics.mechanics.geometry.Sphere.geodesic_length:1: WARNING: py:class reference target not found: ExprType
/home/moorepants/src/sympy/sympy/physics/mechanics/geometry.py:docstring of sympy.physics.mechanics.geometry.Sphere.point:1: WARNING: more than one target found for cross-reference 'Point': sympy.diffgeom.Point, sympy.diffgeom.diffgeom.Point, sympy.geometry.point.Point, sympy.physics.vector.point.Point

These are just warnings, but it automatically selects the first object with a matching name that it finds and then makes a hyperlink to the object, in some cases to the incorrect object. It would be nice if we could disable hyperlink generation if the choice of objects is ambiguous. It isn't clear why it doesn't select the correct objects given that it has access to the actual object. Seems like a sphinx/autodoc/numpydoc bug.

@github-actions
Copy link

github-actions bot commented Aug 14, 2023

Benchmark results from GitHub Actions

Lower numbers are good, higher numbers are bad. A ratio less than 1
means a speed up and greater than 1 means a slowdown. Green lines
beginning with + are slowdowns (the PR is slower then master or
master is slower than the previous release). Red lines beginning
with - are speedups.

Significantly changed benchmark results (PR vs master)

Significantly changed benchmark results (master vs previous release)

       before           after         ratio
     [8059df73]       [77010f3b]
     <sympy-1.12^0>                 
-        95.9±3ms       62.4±0.7ms     0.65  integrate.TimeIntegrationRisch02.time_doit(10)
-        95.8±2ms         63.8±1ms     0.67  integrate.TimeIntegrationRisch02.time_doit_risch(10)
-     2.38±0.07ms         710±60μs     0.30  polys.TimePREM_LinearDenseQuadraticGCD.time_op(3, 'sparse')
-      11.4±0.1ms      1.98±0.01ms     0.17  polys.TimePREM_LinearDenseQuadraticGCD.time_op(5, 'sparse')
-         371±3μs         84.4±4μs     0.23  polys.TimePREM_QuadraticNonMonicGCD.time_op(1, 'sparse')
-      5.51±0.1ms          371±2μs     0.07  polys.TimePREM_QuadraticNonMonicGCD.time_op(3, 'sparse')
-      12.1±0.2ms      1.12±0.01ms     0.09  polys.TimePREM_QuadraticNonMonicGCD.time_op(5, 'sparse')
-     6.55±0.04ms      4.05±0.06ms     0.62  polys.TimeSUBRESULTANTS_LinearDenseQuadraticGCD.time_op(2, 'sparse')
-      28.7±0.7ms       12.2±0.1ms     0.42  polys.TimeSUBRESULTANTS_LinearDenseQuadraticGCD.time_op(3, 'sparse')
-      7.04±0.1ms      1.21±0.01ms     0.17  polys.TimeSUBRESULTANTS_QuadraticNonMonicGCD.time_op(1, 'sparse')
-      16.3±0.1ms      9.29±0.05ms     0.57  polys.TimeSUBRESULTANTS_QuadraticNonMonicGCD.time_op(2, 'sparse')
-         226±3ms       71.6±0.3ms     0.32  polys.TimeSUBRESULTANTS_QuadraticNonMonicGCD.time_op(3, 'sparse')
-     7.18±0.09ms          579±5μs     0.08  polys.TimeSUBRESULTANTS_SparseGCDHighDegree.time_op(3, 'sparse')
-      30.7±0.2ms         901±20μs     0.03  polys.TimeSUBRESULTANTS_SparseGCDHighDegree.time_op(5, 'sparse')
-         646±9μs          224±3μs     0.35  polys.TimeSUBRESULTANTS_SparseNonMonicQuadratic.time_op(1, 'sparse')
-     7.24±0.06ms          226±2μs     0.03  polys.TimeSUBRESULTANTS_SparseNonMonicQuadratic.time_op(3, 'sparse')
-      19.1±0.4ms          234±2μs     0.01  polys.TimeSUBRESULTANTS_SparseNonMonicQuadratic.time_op(5, 'sparse')
-         186±2μs        102±0.8μs     0.55  solve.TimeMatrixOperations.time_rref(3, 0)
-         345±4μs          127±4μs     0.37  solve.TimeMatrixOperations.time_rref(4, 0)
-      34.0±0.7ms      14.5±0.06ms     0.43  solve.TimeSolveLinSys189x49.time_solve_lin_sys

Full benchmark results can be found as artifacts in GitHub Actions
(click on checks at the top of the PR).

@moorepants
Copy link
Member Author

I removed all type hints in geometry because of the sphinx hyperlink bug. Couldn't find another way to fix it.

@brocksam brocksam changed the title Make physics.mechanics._geometry public Make physics.mechanics.wrapping_geometry public Aug 14, 2023
@oscarbenjamin
Copy link
Contributor

These are just warnings, but it automatically selects the first object with a matching name that it finds and then makes a hyperlink to the object

I think the problem is the use of if TYPE_CHECKING. Basically Sphinx needs to see the annotation at runtime because it imports and introspects everything. The if TYPE_CHECKING block would prevent Sphinx from seeing the actual object that is being used in the annotation.

@moorepants
Copy link
Member Author

@oscarbenjamin thanks for the clue.

@brocksam brocksam merged commit d5d8c14 into sympy:master Aug 15, 2023
57 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CZI: Codegen/Biomech Sam Brockie's CZI-funded postdoc work on codegen and biomechanics physics.mechanics
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants