simopt.curve
Curve class for plotting and analysis.
Module Contents
- class simopt.curve.CurveType(*args, **kwds)
Bases:
enum.EnumEnumeration for different curve styles.
- REGULAR = 'regular'
- CONF_BOUND = 'conf_bound'
- property style: tuple[str, int]
Returns linestyle and linewidth for the curve type.
- class simopt.curve.Curve(x_vals: collections.abc.Sequence[int | float], y_vals: collections.abc.Sequence[int | float])
Base class for all curves.
Initialize a curve with x- and y-values.
- Parameters:
x_vals (Sequence[int | float]) – Values of horizontal components.
y_vals (Sequence[int | float]) – Values of vertical components.
- Raises:
TypeError – If x_vals or y_vals are not numeric.
ValueError – If x_vals and y_vals have different lengths or if they contain non-numeric values.
- property x_vals: tuple[float, Ellipsis]
Values of horizontal components.
- property y_vals: tuple[float, Ellipsis]
Values of vertical components.
- property n_points: int
Number of points in the curve.
- lookup(x_val: float) float
Lookup the y-value of the curve at an intermediate x-value.
- Parameters:
x_val (float) – X-value to lookup.
- Returns:
Y-value corresponding to x, or NaN if x_val is out of range.
- Return type:
float
- Raises:
TypeError – If x_val is not numeric.
- compute_crossing_time(threshold: float) float
Compute the first time at which a curve drops below a given threshold.
- Parameters:
threshold (float) – Value for which to find the first crossing time.
- Returns:
First time at which the curve drops below the threshold.
- Return type:
float
- compute_area_under_curve() float
Compute the area under a curve.
- Returns:
Area under the curve.
- Return type:
float
- curve_to_mesh(mesh: collections.abc.Iterable[float]) Curve
Create a curve defined at equally spaced x values.
- Parameters:
mesh (Iterable[float]) – Collection of uniformly spaced x-values.
- Returns:
A curve with equally spaced x-values.
- Return type:
- Raises:
TypeError – If mesh is not an iterable of numeric values.
- curve_to_full_curve() Curve
Create a curve with duplicate x- and y-values to indicate steps.
- Returns:
A curve with duplicate x- and y-values.
- Return type:
- plot(color_str: str = 'C0', curve_type: CurveType = CurveType.REGULAR) matplotlib.lines.Line2D
Plot a curve.
- Parameters:
color_str (str) – String indicating line color, e.g., “C0”, “C1”, etc.
curve_type (CurveType) – Type of line.
- Returns:
Curve handle, useful when creating legends.
- Return type:
Line2D
- Raises:
ValueError – If an invalid curve type is provided.