-
Notifications
You must be signed in to change notification settings - Fork 112
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
Type-hinting elastica #367
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work. Minor comments
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## update-0.3.3 #367 +/- ##
================================================
- Coverage 94.00% 93.96% -0.05%
================================================
Files 51 53 +2
Lines 3170 3295 +125
Branches 347 335 -12
================================================
+ Hits 2980 3096 +116
- Misses 140 152 +12
+ Partials 50 47 -3 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Type-hinting PyElastica
Resolve #255
Note
mypy
test.type-hinting
python library is to enhance the readability and to reduce ambiguity, not to increase the codebase.mypy
can easily become a cumbersome task. (https://www.reddit.com/r/Python/comments/10zdidm/why_type_hinting_sucks/)Any
or# type: ignore
. (mostly numpy-broadcasting)Major Updates
mypy
test is added as part of github-action (Makefile
)protocol
trees for different components in PyElastica (described below)elastica/typing.py
file. (described below)RodType
,RigidBodyType
, etc) used for each feature are now typed properly.Contact
feature: refactor system validation messages. (i.e.common_check_systems_identity
,common_check_systems_difference
,common_check_systems_validity
)InteractionPlane
: this operator was never possible to be used. Now, it is part offorcing
feature, and can be used like external forces. (apply_normal_force
-->apply_forces
)elastica/memory_block/memory_block_rod_base.py
-->elastica/memory_block/utils.py
..using
statement. It was useful for some testing features, but it is an over-exploitation of dynamic types. Now, we only support passing exact object (RodType
,RigidBodyType
, etc)__final_systems
._systems
list at finalize step needs to be discussed._systems
to__final_systems
, Restart issue while loading a ring-rod #376 could be resolved.extend_stepper_interface
andintegrate
should work same as before.extend_stepper_interface
.integrate
or custom stepping as above.Minor Changes
autoflake8
toautoflake
:autoflake8
was made because the originalautoflake
was out of maintenance. Sinceautoflake
is back on maintenance,autoflake8
is now deprecated. (Makefile
)KnotTheoryCompatibleProtocol
moved intoCosseratRodProtocol
.njit
decorators are skipped frommypy
check:numba
implicitly modify the return type, which is hard to trace exactly. For readability, we keepnumpy
type-hinting syntax.SelfContact
ExternalContact
Protocols
Systems
System Collection (Build memory block)
System Collection (Features)
Common Types Aliases
To use type aliases, developer should explicitly import using
from elastica.typing import ...
syntax.typing.py
is not included in the top access tree (i.e. `elastica/init.py).SystemType
: any generic object type for simulator (i.e.Rod
,RigidBody
, etc.)SystemCollectionType
: object collection (i.e.BaseSystemCollection
or simulator that user defines)OperatorType
: any genericstep
used in timestepperSteppersOperationstype
: collection ofOperatorType
used to define specific timestepperTasks
elastica/rod
Typing: Add typehinting forRod
modules #341rods
#396elastica/timestepper
Typing: timestepper module #372 @skim0119timestepper
fix pytest and cleanup integration routine #373elastica/memory_block
@armantekinalp Typing/memory block #384elastica/rigid_body
@sy-cuielastica/mesh
elastica/module
@skim0119modules
#382elastica/systems
@skim0119 Typing:systems
#394contact
#397contact
#397Useful Links