Source code for prismapi.core

from dataclasses import dataclass
from numpy import ndarray


[docs] @dataclass class Parameter: """A class representing a parameter with a value and constraints. This class stores information about a parameter including its name, value, units, and valid range. Attributes: name (str): The display name of the parameter. key (str): The unique identifier/key for the parameter. value (float): The current value of the parameter. units (str): The units of measurement for the parameter. min (float): The minimum allowed value for the parameter. max (float): The maximum allowed value for the parameter. """ name: str key: str value: float units: str min: float max: float
[docs] def __str__(self) -> str: """Return a string representation of the parameter. Returns: str: A formatted string showing the parameter name, value, units, and range. """ return f"{self.name} = {self.value} {self.units} [{self.min}, {self.max}]"
[docs] @dataclass class Measurement: """A class representing a measurement with x and y data points. This class stores measurement data including the data points, units, and timing information. Attributes: name (str): The display name of the measurement. key (str): The unique identifier/key for the measurement. x_data (ndarray | None): The x-axis data points. y_data (ndarray | None): The y-axis data points. x_units (str): The units for the x-axis data. y_units (str): The units for the y-axis data. start_time (float | None): The timestamp when the measurement started. finish_time (float | None): The timestamp when the measurement finished. """ name: str key: str x_data: ndarray | None y_data: ndarray | None x_units: str y_units: str start_time: float | None finish_time: float | None
[docs] def __str__(self) -> str: """Return a string representation of the measurement. Returns: str: A formatted string showing the measurement name and units. """ return f"{self.name} ({self.y_units} vs {self.x_units})"