Skip to content

Commit

Permalink
Add __init__ return type
Browse files Browse the repository at this point in the history
  • Loading branch information
ankith26 committed May 7, 2024
1 parent 9d616c6 commit b1cfdba
Show file tree
Hide file tree
Showing 82 changed files with 143 additions and 144 deletions.
2 changes: 1 addition & 1 deletion docs/advanced/LocalizedForceTorque.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class EndpointForcesWithTorques(NoForces):
This class applies constant forces on the endpoint nodes.
"""

def __init__(self, end_force, ramp_up_time=0.0):
def __init__(self, end_force, ramp_up_time=0.0) -> None:
"""
Parameters
Expand Down
2 changes: 1 addition & 1 deletion docs/guide/workflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ from elastica.callback_functions import CallBackBaseClass

# MyCallBack class is derived from the base call back class.
class MyCallBack(CallBackBaseClass):
def __init__(self, step_skip: int, callback_params):
def __init__(self, step_skip: int, callback_params) -> None:
CallBackBaseClass.__init__(self)
self.every = step_skip
self.callback_params = callback_params
Expand Down
2 changes: 1 addition & 1 deletion elastica/_synchronize_periodic_boundary.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class _ConstrainPeriodicBoundaries(ConstraintBase):
is to synchronize periodic boundaries of ring rod.
"""

def __init__(self, **kwargs):
def __init__(self, **kwargs) -> None:
super().__init__(**kwargs)

def constrain_values(self, rod, time):
Expand Down
6 changes: 3 additions & 3 deletions elastica/boundary_conditions.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class ConstraintBase(ABC):
_constrained_position_idx: np.ndarray
_constrained_director_idx: np.ndarray

def __init__(self, *args, **kwargs):
def __init__(self, *args, **kwargs) -> None:
"""Initialize boundary condition"""
try:
self._system = kwargs["_system"]
Expand Down Expand Up @@ -104,7 +104,7 @@ class FreeBC(ConstraintBase):
Boundary condition template.
"""

def __init__(self, **kwargs):
def __init__(self, **kwargs) -> None:
super().__init__(**kwargs)

def constrain_values(self, system: SystemType, time: float) -> None:
Expand Down Expand Up @@ -506,7 +506,7 @@ class FixedConstraint(GeneralConstraint):
GeneralConstraint: Generalized constraint with configurable DOF.
"""

def __init__(self, *args, **kwargs):
def __init__(self, *args, **kwargs) -> None:
"""
Initialization of the constraint. Any parameter passed to 'using' will be available in kwargs.
Expand Down
4 changes: 2 additions & 2 deletions elastica/callback_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class CallBackBaseClass:
"""

def __init__(self):
def __init__(self) -> None:
"""
CallBackBaseClass does not need any input parameters.
"""
Expand Down Expand Up @@ -61,7 +61,7 @@ class MyCallBack(CallBackBaseClass):
Collected callback data is saved in this dictionary.
"""

def __init__(self, step_skip: int, callback_params: dict):
def __init__(self, step_skip: int, callback_params: dict) -> None:
"""
Parameters
Expand Down
6 changes: 3 additions & 3 deletions elastica/contact_forces.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class NoContact:
"""

def __init__(self):
def __init__(self) -> None:
"""
NoContact class does not need any input parameters.
"""
Expand Down Expand Up @@ -101,7 +101,7 @@ class RodRodContact(NoContact):
"""

def __init__(self, k: float, nu: float):
def __init__(self, k: float, nu: float) -> None:
"""
Parameters
----------
Expand Down Expand Up @@ -338,7 +338,7 @@ class RodSelfContact(NoContact):
"""

def __init__(self, k: float, nu: float):
def __init__(self, k: float, nu: float) -> None:
"""
Parameters
Expand Down
6 changes: 3 additions & 3 deletions elastica/dissipation.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class DamperBase(ABC):

_system: SystemType

def __init__(self, *args, **kwargs):
def __init__(self, *args, **kwargs) -> None:
"""Initialize damping module"""
try:
self._system = kwargs["_system"]
Expand Down Expand Up @@ -113,7 +113,7 @@ class AnalyticalLinearDamper(DamperBase):
Damping coefficient acting on rotational velocity.
"""

def __init__(self, damping_constant: float, time_step: float, **kwargs):
def __init__(self, damping_constant: float, time_step: float, **kwargs) -> None:
"""
Analytical linear damper initializer
Expand Down Expand Up @@ -202,7 +202,7 @@ class LaplaceDissipationFilter(DamperBase):
Filter term that modifies rod rotational velocity.
"""

def __init__(self, filter_order: int, **kwargs):
def __init__(self, filter_order: int, **kwargs) -> None:
"""
Filter damper initializer
Expand Down
10 changes: 5 additions & 5 deletions elastica/external_forces.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class NoForces:
"""

def __init__(self):
def __init__(self) -> None:
"""
NoForces class does not need any input parameters.
"""
Expand Down Expand Up @@ -70,7 +70,7 @@ class GravityForces(NoForces):
"""

def __init__(self, acc_gravity=np.array([0.0, -9.80665, 0.0])):
def __init__(self, acc_gravity=np.array([0.0, -9.80665, 0.0])) -> None:
"""
Parameters
Expand Down Expand Up @@ -122,7 +122,7 @@ class EndpointForces(NoForces):
"""

def __init__(self, start_force, end_force, ramp_up_time):
def __init__(self, start_force, end_force, ramp_up_time) -> None:
"""
Parameters
Expand Down Expand Up @@ -190,7 +190,7 @@ class UniformTorques(NoForces):
"""

def __init__(self, torque, direction=np.array([0.0, 0.0, 0.0])):
def __init__(self, torque, direction=np.array([0.0, 0.0, 0.0])) -> None:
"""
Parameters
Expand Down Expand Up @@ -224,7 +224,7 @@ class UniformForces(NoForces):
2D (dim, 1) array containing data with 'float' type. Total force applied to a rod-like object.
"""

def __init__(self, force, direction=np.array([0.0, 0.0, 0.0])):
def __init__(self, force, direction=np.array([0.0, 0.0, 0.0])) -> None:
"""
Parameters
Expand Down
2 changes: 1 addition & 1 deletion elastica/interaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ class SlenderBodyTheory(NoForces):
"""

def __init__(self, dynamic_viscosity: float):
def __init__(self, dynamic_viscosity: float) -> None:
"""
Parameters
Expand Down
4 changes: 2 additions & 2 deletions elastica/joint.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class FreeJoint:
# pass the k and nu for the forces
# also the necessary rods for the joint
# indices should be 0 or -1, we will provide wrappers for users later
def __init__(self, k: float, nu: float):
def __init__(self, k: float, nu: float) -> None:
"""
Parameters
Expand Down Expand Up @@ -720,7 +720,7 @@ class SelfContact(FreeJoint):
"""

def __init__(self, k: float, nu: float):
def __init__(self, k: float, nu: float) -> None:
super().__init__(k, nu)
log = logging.getLogger(self.__class__.__name__)
log.warning(
Expand Down
2 changes: 1 addition & 1 deletion elastica/memory_block/memory_block_rigid_body.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


class MemoryBlockRigidBody(RigidBodyBase, _RigidRodSymplecticStepperMixin):
def __init__(self, systems: Sequence, system_idx_list: Sequence[np.int64]):
def __init__(self, systems: Sequence, system_idx_list: Sequence[np.int64]) -> None:

self.n_bodies = len(systems)
self.n_elems = self.n_bodies
Expand Down
2 changes: 1 addition & 1 deletion elastica/memory_block/memory_block_rod.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class MemoryBlockCosseratRod(
TODO: need more documentation!
"""

def __init__(self, systems: Sequence, system_idx_list):
def __init__(self, systems: Sequence, system_idx_list) -> None:

# separate straight and ring rods
system_straight_rod = []
Expand Down
2 changes: 1 addition & 1 deletion elastica/memory_block/memory_block_rod_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,5 +160,5 @@ class MemoryBlockRodBase:
This is the base class for memory blocks for rods.
"""

def __init__(self):
def __init__(self) -> None:
pass
2 changes: 1 addition & 1 deletion elastica/modules/base_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class BaseSystemCollection(MutableSequence):
https://stackoverflow.com/q/3945940
"""

def __init__(self):
def __init__(self) -> None:
# Collection of functions. Each group is executed as a collection at the different steps.
# Each component (Forcing, Connection, etc.) registers the executable (callable) function
# in the group that that needs to be executed. These should be initialized before mixin.
Expand Down
4 changes: 2 additions & 2 deletions elastica/modules/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class CallBacks:
List of call back classes defined for rod-like objects.
"""

def __init__(self):
def __init__(self) -> None:
self._callback_list = []
super(CallBacks, self).__init__()
self._feature_group_callback.append(self._callback_execution)
Expand Down Expand Up @@ -92,7 +92,7 @@ class _CallBack:
Arbitrary keyword arguments.
"""

def __init__(self, sys_idx: int):
def __init__(self, sys_idx: int) -> None:
"""
Parameters
Expand Down
2 changes: 1 addition & 1 deletion elastica/modules/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Connections:
List of joint classes defined for rod-like objects.
"""

def __init__(self):
def __init__(self) -> None:
self._connections = []
super(Connections, self).__init__()
self._feature_group_synchronize.append(self._call_connections)
Expand Down
4 changes: 2 additions & 2 deletions elastica/modules/constraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Constraints:
List of boundary condition classes defined for rod-like objects.
"""

def __init__(self):
def __init__(self) -> None:
self._constraints = []
super(Constraints, self).__init__()
self._feature_group_constrain_values.append(self._constrain_values)
Expand Down Expand Up @@ -98,7 +98,7 @@ class _Constraint:
Arbitrary keyword arguments.
"""

def __init__(self, sys_idx: int):
def __init__(self, sys_idx: int) -> None:
"""
Parameters
Expand Down
2 changes: 1 addition & 1 deletion elastica/modules/contact.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Contact:
List of contact classes defined for rod-like objects.
"""

def __init__(self):
def __init__(self) -> None:
self._contacts = []
super(Contact, self).__init__()
self._feature_group_synchronize.append(self._call_contacts)
Expand Down
4 changes: 2 additions & 2 deletions elastica/modules/damping.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Damping:
List of damper classes defined for rod-like objects.
"""

def __init__(self):
def __init__(self) -> None:
self._dampers = []
super(Damping, self).__init__()
self._feature_group_constrain_rates.append(self._dampen_rates)
Expand Down Expand Up @@ -88,7 +88,7 @@ class _Damper:
Arbitrary keyword arguments.
"""

def __init__(self, sys_idx: int):
def __init__(self, sys_idx: int) -> None:
"""
Parameters
Expand Down
4 changes: 2 additions & 2 deletions elastica/modules/forcing.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Forcing:
List of forcing class defined for rod-like objects.
"""

def __init__(self):
def __init__(self) -> None:
self._ext_forces_torques = []
super(Forcing, self).__init__()
self._feature_group_synchronize.append(self._call_ext_forces_torques)
Expand Down Expand Up @@ -101,7 +101,7 @@ class _ExtForceTorque:
Arbitrary keyword arguments.
"""

def __init__(self, sys_idx: int):
def __init__(self, sys_idx: int) -> None:
"""
Parameters
Expand Down
2 changes: 1 addition & 1 deletion elastica/rigidbody/cylinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


class Cylinder(RigidBodyBase):
def __init__(self, start, direction, normal, base_length, base_radius, density):
def __init__(self, start, direction, normal, base_length, base_radius, density) -> None:
"""
Rigid body cylinder initializer.
Expand Down
8 changes: 4 additions & 4 deletions elastica/rigidbody/data_structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# FIXME : Explicit Stepper doesn't work as States lose the
# views they initially had when working with a timestepper.
class _RigidRodExplicitStepperMixin:
def __init__(self):
def __init__(self) -> None:
(
self.state,
self.__deriv_state,
Expand Down Expand Up @@ -44,7 +44,7 @@ def __call__(self, time, *args, **kwargs):


class _RigidRodSymplecticStepperMixin(_RodSymplecticStepperMixin):
def __init__(self):
def __init__(self) -> None:
super(_RigidRodSymplecticStepperMixin, self).__init__()
# Expose rate returning functions in the interface
# to be used by the time-stepping algorithm
Expand Down Expand Up @@ -286,7 +286,7 @@ def _bootstrap_from_data(stepper_type: str, n_elems: int, vector_states, matrix_
# /multiplication used.
# """
#
# def __init__(self, _unused_n_elems: int, rate_collection_view):
# def __init__(self, _unused_n_elems: int, rate_collection_view) -> None:
# """
# Parameters
# ----------
Expand Down Expand Up @@ -380,7 +380,7 @@ class _KinematicState:
only these methods are provided.
"""

def __init__(self, position_collection_view, director_collection_view):
def __init__(self, position_collection_view, director_collection_view) -> None:
"""
Parameters
----------
Expand Down
2 changes: 1 addition & 1 deletion elastica/rigidbody/rigid_body.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class RigidBodyBase(ABC):
"""

def __init__(self):
def __init__(self) -> None:

self.position_collection = NotImplementedError
self.velocity_collection = NotImplementedError
Expand Down
2 changes: 1 addition & 1 deletion elastica/rigidbody/sphere.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


class Sphere(RigidBodyBase):
def __init__(self, center, base_radius, density):
def __init__(self, center, base_radius, density) -> None:
"""
Rigid body sphere initializer.
Expand Down
Loading

0 comments on commit b1cfdba

Please sign in to comment.