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

Typing: timestepper module #372

Merged
merged 16 commits into from
Apr 30, 2024

Conversation

skim0119
Copy link
Collaborator

@skim0119 skim0119 commented Apr 29, 2024

Type-hinting timestepper module

-> % mypy --config-file pyproject.toml elastica/timestepper
Success: no issues found in 5 source files

New Protocols

  • elastica/system/protocol.py: generic protocol for all SystemType
    • Also includes SymplecticSystemProtocol and ExplicitSystemProtocol
  • elastica/timestepper/protocol.py:
    • generic protocol for any StepperProtocol
      • Extended protocols: StatefulStepperProtocol
    • MethodCollectorProtocol for class that generates operators.
    • MemoryProtocol for state representation of timesteppers. (unused)

Refactoring

  • Unused __init__, args, and kwargs are removed.
  • SymplecticStepperTag and ExplicitStepperTag are now in tag.py
    • All stepper tagging are now done using elastica.timestepper.tag.tag.
  • In testing, some MockRod and MockRigidBody was created using TypeAlias, which is not an intended usage. It is refactored to import original base classes.

Minor changes

  • isinstance is safer type-comparison instead of type(...) == type(...)
  • Change some float types to np.floating
    • Not sure yet this is a good idea. Maybe we should make generic datatype: FLOAT: TypeAlias = float | np.floating.
  • Some commented-out by string is replaced with proper python-commenting for better syntax highlighitng.

@skim0119 skim0119 self-assigned this Apr 29, 2024
@skim0119 skim0119 requested review from Ali-7800 and removed request for bhosale2 April 29, 2024 16:01
@skim0119 skim0119 added enhancement New feature or request prio:low Priority level: low github_actions Pull requests that update GitHub Actions code labels Apr 29, 2024
@armantekinalp armantekinalp mentioned this pull request Apr 30, 2024
17 tasks
@armantekinalp armantekinalp requested a review from sy-cui April 30, 2024 16:16
@skim0119 skim0119 requested a review from armantekinalp April 30, 2024 16:38
Copy link
Contributor

@armantekinalp armantekinalp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM nice work @skim0119

@skim0119 skim0119 merged commit b152c20 into GazzolaLab:update/mypy Apr 30, 2024
2 of 6 checks passed
@skim0119 skim0119 deleted the typing/timestepper branch April 30, 2024 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request github_actions Pull requests that update GitHub Actions code prio:low Priority level: low
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants