Skip to content

Commit f75d4f9

Browse files
Drop numpy requirement until it's actually need in the future.
1 parent dbba5ea commit f75d4f9

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ The main features of the **ppk_api** include:
1111
### Requirements
1212
The interface to the PPK requires Nordic's [nRF Command Line Tools](https://www.nordicsemi.com/Software-and-Tools/Development-Tools/nRF-Command-Line-Tools).
1313

14-
Additionally, the excellent [nRF Pynrfjprog](https://www.nordicsemi.com/Software-and-Tools/Development-Tools/nRF-Pynrfjprog) and [numpy](https://numpy.org/) Python modules can be installed from the command line using pip:
14+
Additionally, the excellent [nRF Pynrfjprog](https://www.nordicsemi.com/Software-and-Tools/Development-Tools/nRF-Pynrfjprog) Python module can be installed from the command line using pip:
1515
```
1616
$ cd ppk_api
1717
$ pip3 install --user -r requirements.txt

ppk/ppk.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
import time
66
import struct
77
import re
8-
9-
from numpy import average as np_avg
8+
import math
109

1110

1211
class PPKError(Exception):
@@ -234,7 +233,7 @@ def measure_average(self, time_s, discard_jitter_count=500):
234233
ts, avg_buf = ppk_helper.get_average_buffs()[0]
235234
timestamped_buf = [(ts + self.AVERAGE_TIME_US * i, avg_buf[i])
236235
for i in range(discard_jitter_count, len(avg_buf))]
237-
return (np_avg(avg_buf[discard_jitter_count:]), timestamped_buf)
236+
return (self.favg(avg_buf[discard_jitter_count:]), timestamped_buf)
238237

239238
def measure_triggers(self, window_time_us, level_ua, count=1):
240239
"""Collect count trigger buffers."""
@@ -277,7 +276,7 @@ def _measure_triggers(self, count=1):
277276
for ts, trig_buf in ppk_helper.get_trigger_buffs(*self._resistors):
278277
timestamped_buf = [(ts + self.ADC_SAMPLING_TIME_US * i, trig_buf[i])
279278
for i in range(0, len(trig_buf))]
280-
result.append((np_avg(trig_buf), timestamped_buf))
279+
result.append((self.favg(trig_buf), timestamped_buf))
281280
return result
282281

283282
def _enable_ext_trigger_in(self):
@@ -371,6 +370,12 @@ def _log(self, logstring, **kwargs):
371370
if self.logprint:
372371
print(logstring, **kwargs)
373372

373+
@staticmethod
374+
def favg(float_seq):
375+
"""Return the average of a sequence of floats."""
376+
sum = math.fsum(float_seq)
377+
return sum / len(float_seq)
378+
374379
@staticmethod
375380
def _parse_metadata(metadata_str):
376381
"""Use a Regular Expression to parse a metadata packet."""

requirements.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
numpy
21
pynrfjprog
3-

0 commit comments

Comments
 (0)