Skip to content

Commit fa2180d

Browse files
committed
simple_pid/PID.py: Add parentheses to more readable
1 parent 797a062 commit fa2180d

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

simple_pid/PID.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -96,17 +96,17 @@ def __call__(self, input_, dt=None):
9696

9797
now = _current_time()
9898
if dt is None:
99-
dt = now - self._last_time if now - self._last_time else 1e-16
99+
dt = now - self._last_time if (now - self._last_time) else 1e-16
100100
elif dt <= 0:
101101
raise ValueError('dt has negative value {}, must be positive'.format(dt))
102102

103-
if self.sample_time is not None and dt < self.sample_time and self._last_output is not None:
103+
if (self.sample_time is not None) and (dt < self.sample_time) and (self._last_output is not None):
104104
# only update every sample_time seconds
105105
return self._last_output
106106

107107
# compute error terms
108108
error = self.setpoint - input_
109-
d_input = input_ - (self._last_input if self._last_input is not None else input_)
109+
d_input = input_ - (self._last_input if (self._last_input is not None) else input_)
110110

111111
# check if must map the error
112112
if self.error_map is not None:
@@ -217,7 +217,7 @@ def output_limits(self, limits):
217217

218218
min_output, max_output = limits
219219

220-
if None not in limits and max_output < min_output:
220+
if (None not in limits) and (max_output < min_output):
221221
raise ValueError('lower limit must be less than upper limit')
222222

223223
self._min_output = min_output

0 commit comments

Comments
 (0)