Skip to content

Commit

Permalink
ENH: enhance code style wrapping
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreaBlengino committed Oct 4, 2024
1 parent 967c0fd commit bbbc383
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 32 deletions.
10 changes: 5 additions & 5 deletions gearpy/mechanical_objects/helical_gear.py
Original file line number Diff line number Diff line change
Expand Up @@ -1140,11 +1140,11 @@ def external_torque(

@external_torque.setter
def external_torque(
self,
external_torque: Callable[
[AngularPosition, AngularSpeed, Time],
Torque
]
self,
external_torque: Callable[
[AngularPosition, AngularSpeed, Time],
Torque
]
):
super(
HelicalGear,
Expand Down
16 changes: 9 additions & 7 deletions gearpy/mechanical_objects/mechanical_object_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,13 +314,15 @@ class GearBase(RotatingObject):
"""

@abstractmethod
def __init__(self,
name: str,
n_teeth: int,
module: Length,
face_width: Length,
inertia_moment: InertiaMoment,
elastic_modulus: Stress):
def __init__(
self,
name: str,
n_teeth: int,
module: Length,
face_width: Length,
inertia_moment: InertiaMoment,
elastic_modulus: Stress
):
super().__init__(name=name, inertia_moment=inertia_moment)

if not isinstance(n_teeth, int):
Expand Down
10 changes: 6 additions & 4 deletions gearpy/motor_control/rules/constant_pwm.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,12 @@ class ConstantPWM(RuleBase):
:py:attr:`DCMotor.pwm <gearpy.mechanical_objects.dc_motor.DCMotor.pwm>`
"""

def __init__(self,
timer: Timer,
powertrain: Powertrain,
target_pwm_value: float | int):
def __init__(
self,
timer: Timer,
powertrain: Powertrain,
target_pwm_value: float | int
):
super().__init__()

if not isinstance(timer, Timer):
Expand Down
12 changes: 7 additions & 5 deletions gearpy/motor_control/rules/reach_angular_position.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,13 @@ class ReachAngularPosition(RuleBase):
:py:attr:`DCMotor.pwm <gearpy.mechanical_objects.dc_motor.DCMotor.pwm>`
"""

def __init__(self,
encoder: AbsoluteRotaryEncoder,
powertrain: Powertrain,
target_angular_position: AngularPosition,
braking_angle: Angle):
def __init__(
self,
encoder: AbsoluteRotaryEncoder,
powertrain: Powertrain,
target_angular_position: AngularPosition,
braking_angle: Angle
):
super().__init__()

if not isinstance(encoder, AbsoluteRotaryEncoder):
Expand Down
20 changes: 11 additions & 9 deletions gearpy/solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,13 @@ def __init__(self, powertrain: Powertrain):
self.__powertrain = powertrain
self.__powertrain_is_locked = False

def run(self,
time_discretization: TimeInterval,
simulation_time: TimeInterval,
motor_control: Optional[MotorControlBase] = None,
stop_condition: Optional[StopCondition] = None) -> None:
def run(
self,
time_discretization: TimeInterval,
simulation_time: TimeInterval,
motor_control: Optional[MotorControlBase] = None,
stop_condition: Optional[StopCondition] = None
) -> None:
"""It runs the powertrain simulation. \n
The simulation is performed in several steps:
Expand Down Expand Up @@ -219,8 +221,8 @@ def _compute_powertrain_inertia(self):
self.__powertrain_inertia_moment += element.inertia_moment

def _compute_powertrain_variables(
self,
motor_control: Optional[MotorControlBase]
self,
motor_control: Optional[MotorControlBase]
):

self._compute_angular_position_and_speed()
Expand Down Expand Up @@ -262,8 +264,8 @@ def _transmit_angular_acceleration(self, gear_ratio, i):
self.__powertrain.elements[i + 1].angular_acceleration

def _compute_motor_control(
self,
motor_control: Optional[MotorControlBase]
self,
motor_control: Optional[MotorControlBase]
):

if motor_control is not None:
Expand Down
4 changes: 2 additions & 2 deletions gearpy/units/units.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ def __rmul__(self, other: float | int) -> AngularPosition:
return AngularPosition(value=self.__value*other, unit=self.__unit)

def __truediv__(
self,
other: AngularPosition | float | int
self,
other: AngularPosition | float | int
) -> AngularPosition | float:
super().__truediv__(other=other)

Expand Down

0 comments on commit bbbc383

Please sign in to comment.