Skip to content

Commit

Permalink
Added a typing stub file so that users can use type checking with the…
Browse files Browse the repository at this point in the history
… library
  • Loading branch information
m-lundberg committed Mar 5, 2020
1 parent 945f4da commit 1b622b1
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 2 deletions.
9 changes: 7 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- Typing information through a stub file so that users of the library can use e.g.
[mypy](https://github.com/python/mypy) to type check their code

- This project now uses the [Black code style](https://github.com/psf/black)

### Fixed
Expand Down Expand Up @@ -43,7 +46,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- Allow the proportional term to be monitored properly through the components-property when _proportional on measurement_ is enabled.
- Allow the proportional term to be monitored properly through the components-property when
_proportional on measurement_ is enabled.

### Fixed

Expand All @@ -63,7 +67,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

- Use monotonic time to prevent errors that may be difficult to diagnose when the system time is modified. Thanks [@deniz195](https://github.com/m-lundberg/simple-pid/issues/1)
- Use monotonic time to prevent errors that may be difficult to diagnose when the system time is
modified. Thanks [@deniz195](https://github.com/m-lundberg/simple-pid/issues/1)

### Added

Expand Down
5 changes: 5 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
],
keywords='pid controller control',
packages=['simple_pid'],
package_data={
'simple_pid': ['*.pyi', 'py.typed'],
},
include_package_data=True,
zip_safe=False,
extras_require={
'docs': ['m2r', 'sphinx-rtd-theme']
},
Expand Down
39 changes: 39 additions & 0 deletions simple_pid/PID.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
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: ...
Empty file added simple_pid/py.typed
Empty file.

0 comments on commit 1b622b1

Please sign in to comment.