Skip to content

Commit

Permalink
Added a __repr__() method to the PID class
Browse files Browse the repository at this point in the history
  • Loading branch information
m-lundberg committed Mar 14, 2020
1 parent 4c20427 commit ccd6437
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 39 deletions.
8 changes: 8 additions & 0 deletions simple_pid/PID.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,14 @@ def __call__(self, input_, dt=None):

return output

def __repr__(self):
return ('{self.__class__.__name__}('
'Kp={self.Kp!r}, Ki={self.Ki!r}, Kd={self.Kd!r}, '
'setpoint={self.setpoint!r}, sample_time={self.sample_time!r}, '
'output_limits={self.output_limits!r}, auto_mode={self.auto_mode!r}, '
'proportional_on_measurement={self.proportional_on_measurement!r}'
')').format(self=self)

@property
def components(self):
"""
Expand Down
79 changes: 40 additions & 39 deletions simple_pid/PID.pyi
Original file line number Diff line number Diff line change
@@ -1,39 +1,40 @@
from typing import Callable, Optional, Tuple

_Limits = Tuple[Optional[float], Optional[float]]
_Components = Tuple[float, float, float]
_Tunings = Tuple[float, float, float]

def _clamp(value: Optional[float], limits: _Limits) -> Optional[float]: ...

_current_time: Callable[[], float]

class PID(object):
def __init__(
self,
Kp: float = ...,
Ki: float = ...,
Kd: float = ...,
setpoint: float = ...,
sample_time: Optional[float] = ...,
output_limits: _Limits = ...,
auto_mode: bool = ...,
proportional_on_measurement: bool = ...,
) -> None: ...
def __call__(self, input_: float, dt: Optional[float] = ...) -> Optional[float]: ...
@property
def components(self) -> _Components: ...
@property
def tunings(self) -> _Tunings: ...
@tunings.setter
def tunings(self, tunings: _Tunings) -> None: ...
@property
def auto_mode(self) -> bool: ...
@auto_mode.setter
def auto_mode(self, enabled: bool) -> None: ...
def set_auto_mode(self, enabled: bool, last_output: Optional[float] = ...) -> None: ...
@property
def output_limits(self) -> _Limits: ...
@output_limits.setter
def output_limits(self, limits: _Limits) -> None: ...
def reset(self) -> None: ...
from typing import Callable, Optional, Tuple

_Limits = Tuple[Optional[float], Optional[float]]
_Components = Tuple[float, float, float]
_Tunings = Tuple[float, float, float]

def _clamp(value: Optional[float], limits: _Limits) -> Optional[float]: ...

_current_time: Callable[[], float]

class PID(object):
def __init__(
self,
Kp: float = ...,
Ki: float = ...,
Kd: float = ...,
setpoint: float = ...,
sample_time: Optional[float] = ...,
output_limits: _Limits = ...,
auto_mode: bool = ...,
proportional_on_measurement: bool = ...,
) -> None: ...
def __call__(self, input_: float, dt: Optional[float] = ...) -> Optional[float]: ...
def __repr__(self) -> str: ...
@property
def components(self) -> _Components: ...
@property
def tunings(self) -> _Tunings: ...
@tunings.setter
def tunings(self, tunings: _Tunings) -> None: ...
@property
def auto_mode(self) -> bool: ...
@auto_mode.setter
def auto_mode(self, enabled: bool) -> None: ...
def set_auto_mode(self, enabled: bool, last_output: Optional[float] = ...) -> None: ...
@property
def output_limits(self) -> _Limits: ...
@output_limits.setter
def output_limits(self, limits: _Limits) -> None: ...
def reset(self) -> None: ...

0 comments on commit ccd6437

Please sign in to comment.