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

Implemented _NamedMixin mixin class for adding error-checked name attribute to classes #25540

Merged
merged 3 commits into from
Aug 17, 2023

Conversation

brocksam
Copy link
Contributor

@brocksam brocksam commented Aug 17, 2023

References to other Issues or PRs

Forms part of the CZI biomechanics work program described in #24240.

Brief description of what is fixed or changed

Introduces a mixin class, _NamedMixin, which can be used to add a name attribute to classes. This property comes with simple error checking and useful error messages when a user supplies an invalid name. These names are needed to help with the naming of automatically-created symbols while avoid name conflicts. Musculotendon and activation dynamics classes will use this mixin.

Other comments

The module and class are named with a leading underscore to signal that they are intended for internal use only and won't be part of the sympy.physics.biomechanics namespace. No release notes will be needed for this.

Release Notes

NO ENTRY

@brocksam brocksam added CZI: Codegen/Biomech Sam Brockie's CZI-funded postdoc work on codegen and biomechanics physics.biomechanics labels Aug 17, 2023
@sympy-bot
Copy link

sympy-bot commented Aug 17, 2023

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

  • No release notes entry will be added for this pull request.
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. -->

Forms part of the CZI biomechanics work program described in https://github.com/sympy/sympy/issues/24240.

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

Introduces a mixin class, `_NamedMixin`, which can be used to add a `name` attribute to classes. This property comes with simple error checking and useful error messages when a user supplies an invalid name. These names are needed to help with the naming of automatically-created symbols while avoid name conflicts. Musculotendon and activation dynamics classes will use this mixin.

#### Other comments

The module and class are named with a leading underscore to signal that they are intended for internal use only and won't be part of the `sympy.physics.biomechanics` namespace. No release notes will be needed for this.

#### 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 -->
NO ENTRY
<!-- END RELEASE NOTES -->

@sympy-bot
Copy link

sympy-bot commented Aug 17, 2023

🟠

Hi, I am the SymPy bot. 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:

  • eb8f177:
    • sympy/physics/_biomechanics/_mixin.py
  • 05fe84e:
    • sympy/physics/_biomechanics/tests/test_mixin.py

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

@moorepants
Copy link
Member

LGTM

@moorepants moorepants merged commit 3183e04 into sympy:master Aug 17, 2023
55 checks passed
@github-actions
Copy link

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]       [f99dec81]
     <sympy-1.12^0>                 
-      83.3±0.5ms       55.1±0.4ms     0.66  integrate.TimeIntegrationRisch02.time_doit(10)
-        83.7±1ms       54.9±0.5ms     0.66  integrate.TimeIntegrationRisch02.time_doit_risch(10)
-     6.79±0.02ms      3.66±0.01ms     0.54  logic.LogicSuite.time_load_file
-     2.10±0.01ms          619±2μs     0.29  polys.TimePREM_LinearDenseQuadraticGCD.time_op(3, 'sparse')
-     10.4±0.04ms         1.85±0ms     0.18  polys.TimePREM_LinearDenseQuadraticGCD.time_op(5, 'sparse')
-         364±1μs       77.8±0.3μs     0.21  polys.TimePREM_QuadraticNonMonicGCD.time_op(1, 'sparse')
-     4.75±0.02ms        344±0.7μs     0.07  polys.TimePREM_QuadraticNonMonicGCD.time_op(3, 'sparse')
-     10.6±0.07ms         1.03±0ms     0.10  polys.TimePREM_QuadraticNonMonicGCD.time_op(5, 'sparse')
-     6.27±0.01ms      3.82±0.01ms     0.61  polys.TimeSUBRESULTANTS_LinearDenseQuadraticGCD.time_op(2, 'sparse')
-     27.5±0.06ms      11.6±0.04ms     0.42  polys.TimeSUBRESULTANTS_LinearDenseQuadraticGCD.time_op(3, 'sparse')
-     6.76±0.01ms         1.12±0ms     0.17  polys.TimeSUBRESULTANTS_QuadraticNonMonicGCD.time_op(1, 'sparse')
-     15.8±0.02ms      8.90±0.01ms     0.56  polys.TimeSUBRESULTANTS_QuadraticNonMonicGCD.time_op(2, 'sparse')
-       206±0.6ms       68.2±0.2ms     0.33  polys.TimeSUBRESULTANTS_QuadraticNonMonicGCD.time_op(3, 'sparse')
-     6.32±0.01ms          502±2μs     0.08  polys.TimeSUBRESULTANTS_SparseGCDHighDegree.time_op(3, 'sparse')
-     27.2±0.04ms          805±1μs     0.03  polys.TimeSUBRESULTANTS_SparseGCDHighDegree.time_op(5, 'sparse')
-         592±3μs          200±1μs     0.34  polys.TimeSUBRESULTANTS_SparseNonMonicQuadratic.time_op(1, 'sparse')
-     6.34±0.01ms        204±0.8μs     0.03  polys.TimeSUBRESULTANTS_SparseNonMonicQuadratic.time_op(3, 'sparse')
-     16.5±0.06ms          208±1μs     0.01  polys.TimeSUBRESULTANTS_SparseNonMonicQuadratic.time_op(5, 'sparse')
-       162±0.2μs       90.2±0.2μs     0.56  solve.TimeMatrixOperations.time_rref(3, 0)
-       307±0.5μs        107±0.4μs     0.35  solve.TimeMatrixOperations.time_rref(4, 0)
-     30.0±0.09ms      12.5±0.03ms     0.42  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).

@brocksam brocksam deleted the physics-biomechanics-mixin branch August 21, 2023 16:37
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.biomechanics
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants