Merged in develop
This commit is contained in:
commit
46d1eda94d
@ -3,7 +3,8 @@ Provides class MeasurementSet, a class used to perform checks and adjustments
|
|||||||
on a group of measurements at the same time.
|
on a group of measurements at the same time.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
__all__ = ['MeasurementSet']
|
|
||||||
|
__all__ = ["MeasurementSet"]
|
||||||
from .lasp_measurement import Measurement, MeasurementType
|
from .lasp_measurement import Measurement, MeasurementType
|
||||||
from typing import List
|
from typing import List
|
||||||
import time
|
import time
|
||||||
@ -16,7 +17,7 @@ class MeasurementSet(list):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, mlist: List[Measurement]=[]):
|
def __init__(self, mlist: List[Measurement] = []):
|
||||||
"""
|
"""
|
||||||
Initialize a measurement set
|
Initialize a measurement set
|
||||||
|
|
||||||
@ -25,8 +26,10 @@ class MeasurementSet(list):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
if any([not isinstance(i, Measurement) for i in mlist]):
|
if any([not isinstance(i, Measurement) for i in mlist]):
|
||||||
raise TypeError('Object in list should be of Measurement type')
|
raise TypeError("Object in list should be of Measurement type")
|
||||||
|
|
||||||
|
# Sort by time stamp, otherwise the order is random
|
||||||
|
mlist.sort(key=lambda x: x.time, reverse=True)
|
||||||
super().__init__(mlist)
|
super().__init__(mlist)
|
||||||
|
|
||||||
def getNewestReferenceMeasurement(self, mtype: MeasurementType):
|
def getNewestReferenceMeasurement(self, mtype: MeasurementType):
|
||||||
@ -46,7 +49,8 @@ class MeasurementSet(list):
|
|||||||
return mnewest
|
return mnewest
|
||||||
|
|
||||||
def getReferenceMeasurements(self, mtype: MeasurementType):
|
def getReferenceMeasurements(self, mtype: MeasurementType):
|
||||||
"""Get all reference measurements of a certain type
|
"""Get all available reference measurements of a certain type in the
|
||||||
|
current set.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
mtype (MeasurementType): The type of which to list
|
mtype (MeasurementType): The type of which to list
|
||||||
@ -72,7 +76,7 @@ class MeasurementSet(list):
|
|||||||
|
|
||||||
def newestReferenceOlderThan(self, secs):
|
def newestReferenceOlderThan(self, secs):
|
||||||
"""Returns a dictionary of references with the newest reference, that is still
|
"""Returns a dictionary of references with the newest reference, that is still
|
||||||
older than `secs` seconds. """
|
older than `secs` seconds."""
|
||||||
curtime = time.time()
|
curtime = time.time()
|
||||||
newest = self.getNewestReferenceMeasurements()
|
newest = self.getNewestReferenceMeasurements()
|
||||||
newest_older_than = {}
|
newest_older_than = {}
|
||||||
@ -81,7 +85,6 @@ class MeasurementSet(list):
|
|||||||
newest_older_than[key] = m
|
newest_older_than[key] = m
|
||||||
return newest_older_than
|
return newest_older_than
|
||||||
|
|
||||||
|
|
||||||
def measTimeSame(self):
|
def measTimeSame(self):
|
||||||
"""
|
"""
|
||||||
Returns True if all measurements have the same measurement
|
Returns True if all measurements have the same measurement
|
||||||
@ -117,4 +120,3 @@ class MeasurementSet(list):
|
|||||||
return all([first == meas.channelConfig for meas in self])
|
return all([first == meas.channelConfig for meas in self])
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user