pybop.plot.voronoi#
Functions#
|
Computes the far-point of the voronoi region. |
|
Check for points outside of bounds. Originally adapted from PINTS. |
|
Sorts the region vertices according to the given point. |
|
Takes a set of |
|
Computes an array of values given by the score of the nearest point. |
|
Interpolates a new point on the line segment between p and q at the given boundary value. |
|
Plot a 2D representation of the Voronoi diagram with color-coded regions. |
|
Truncates a region along a specific axis. Originally adapted from PINTS. |
Module Contents#
- pybop.plot.voronoi._compute_far_point(vor, y1, y2, x2, center, radius2)[source]#
Computes the far-point of the voronoi region. Originally adapted from PINTS.
- pybop.plot.voronoi._is_region_outside_bounds(region, xmin, xmax, ymin, ymax)[source]#
Check for points outside of bounds. Originally adapted from PINTS.
- pybop.plot.voronoi._sort_region_vertices(region, point)[source]#
Sorts the region vertices according to the given point. Originally adapted from PINTS.
- pybop.plot.voronoi._voronoi_regions(x, y, f, xlim, ylim)[source]#
Takes a set of
(x, y, f)points and returns the edgepoints of the voronoi region around each point within the boundaries specified byxlimandylim. Originally adapted from PINTS.- Parameters:
x (array-like) – A list of x-coordinates.
y (array-like) – A list of y-coordinates.
f (array-like) – The score function at the given x and y coordinates.
xlim (tuple) – Lower and upper bound for the x coordinates.
ylim (tuple) – Lower and upper bound for the y coordinates.
- Returns:
A tuple
(x, y, f, regions)wherex,yandfare the coordinates of the accepted points and eachregions[i]is a list of the vertices making up the voronoi region for point(x[i], y[i])with scoref[i].- Return type:
tuple
- pybop.plot.voronoi.assign_nearest_value(x, y, f, xi, yi)[source]#
Computes an array of values given by the score of the nearest point.
- Parameters:
x (array-like) – The x coordinates of points with known scores.
y (array-like) – The y coordinates of points with known scores.
f (array-like) – The score function at the given x and y coordinates.
xi (array-like) – The x coordinates of grid points.
yi (array-like) – The y coordinates of grid points.
- Return type:
A numpy array containing the scores corresponding to the grid points.
- pybop.plot.voronoi.interpolate_point(p, q, axis, boundary_val)[source]#
Interpolates a new point on the line segment between p and q at the given boundary value.
- Parameters:
p – The first point.
q – The second point.
axis – The axis to interpolate along (0 for x, 1 for y).
boundary_val – The boundary value.
- Returns:
A numpy array representing the interpolated point.
- pybop.plot.voronoi.surface(optim: pybop.BaseOptimiser | pybop.Optimisation, bounds=None, normalise=True, resolution=250, show=True, **layout_kwargs)[source]#
Plot a 2D representation of the Voronoi diagram with color-coded regions.
Parameters:#
- optimpybop.BaseOptimiser | pybop.Optimisation
Solved optimisation object
- boundsnumpy.ndarray, optional
A 2x2 array specifying the [min, max] bounds for each parameter. If None, uses cost.parameters.get_bounds_for_plotly.
- normalisebool, optional
If True, the voronoi regions are computed using the Euclidean distance between points normalised with respect to the bounds (default: True).
- resolutionint, optional
Resolution of the plot. Default is 500.
- showbool, optional
If True, the figure is shown upon creation (default: True).
- **layout_kwargsoptional
Valid Plotly layout keys and their values, e.g. xaxis_title=”Time [s]” or xaxis={“title”: “Time [s]”, “titlefont_size”: 18}.
- pybop.plot.voronoi.truncate_region_by_axis(region, axis, min_val, max_val)[source]#
Truncates a region along a specific axis. Originally adapted from PINTS.
- Parameters:
region – A list of points (numpy arrays) representing the region.
axis – The axis to truncate along (0 for x, 1 for y).
min_val – The minimum value along the axis.
max_val – The maximum value along the axis.
- Returns:
A list of points representing the truncated region.