utils_nd.py
- GiveDegreeCandidates(degree_max, ndim, ncandidates=10)
Create a vector of degree candidates in each dimension.
- Parameters:
degree_max (int or array[int]) – The maximum degree to be considered (if an integer), or the maximum degree to be considered in each dimension (if an array of integers).
ndim (int) – The number of dimensions.
ncandidates (int, default=10) – The number of degree candidates to consider.
- Returns:
degree_candidates – A 2D array containing the vector of degree candidates in each dimension.
- Return type:
array[int]
- MakePlot(Data, Title, degree_candidates, Interpolate=False, AddContour=False)
Plot a 2D heat-map as a function of the degree candidates in each dimension.
- Parameters:
Data (array[float]) – The 2-d array to plot.
Title (str) – The title of the figure.
degree_candidates (array[int] or list[array[int]]) – The array or list containing the vector of degree candidates in each dimension.
Interpolate (bool, default=False) – Whether to interpolate the heat-map from
Data.AddContour (bool, default=False) – Whether to add contour levels to the plot.
- Returns:
fig – The figure containing the plot.
- Return type:
matplotlib.figure.Figure
- FlattenGrid(Inputs, ndim)
Create a flattened mesh of
Inputs.- Parameters:
Inputs (list[list[float]] or array[float]) – The input list/array of lists/arrays or 2D array.
ndim (int) – The number of dimensions in (length of)
Inputs.
- Returns:
FlattenedMesh – The flattened list of mesh points; see example below.
- Return type:
list[list[float]]
Examples
>>> Inputs = [[1,2,3,4], [1,2,3,4], [1,2,3,4]] # 3 dimensions with 4 points >>> FlattenGrid(Inputs, 3) [[1,1,1], [1,1,2], [1,1,3], [1,1,4], [2,1,1], [2,1,2], [2,1,3], ..., [4,4,3], [4,4,4]]