Skip to content

Instantly share code, notes, and snippets.

@MrKevinWeiss
Last active June 30, 2022 11:55
Show Gist options
  • Save MrKevinWeiss/103eefe5059d05fa3d911c62ff4a1442 to your computer and use it in GitHub Desktop.
Save MrKevinWeiss/103eefe5059d05fa3d911c62ff4a1442 to your computer and use it in GitHub Desktop.
for marcel
from statistics import mean, stdev
class PhilipExtIf(PhilipBaseIf):
def _get_stats(self, vals: list):
"""Calculate stats of a list of values.
Returns:
dict containing stats:
"""
return {
'values': vals,
'mean': mean(vals),
'min': min(vals),
'max': max(vals),
'stdev': stdev(vals)
}
def get_spi_clk_frames(self) -> int:
"""Get the amount of bytes in the spi clk buffer."""
pass
def get_spi_clk_byte_stats(self, byte=None) -> dict:
"""Get stats for each clock pulse of the spi clk.
Args:
byte (int, None): The byte in the 8 bit calculation to use, if None
then use all bytes.
Return:
dict containing stats.
"""
bit_diffs = []
return self._get_stats(bit_diffs)
def get_spi_clk_frame_stats(self) -> dict:
"""Get stats for byte in the spi frame.
Args:
byte (int, None): The byte in the 8 bit calculation to use, if None
then use all bytes.
Return:
dict containing stats.
"""
byte_diffs = []
for byte in range(self.get_spi_clk_frames()):
byte_diffs.append(self.get_spi_clk_byte_stats(byte)['mean'])
return self._get_stats(byte_diffs)
def get_spi_clk_deadtime_stats(self) -> dict:
"""Get stats for the time between spi bytes.
Return:
dict containing stats.
"""
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment