Skip to content

Commit 852b019

Browse files
0.29.6
bestlhd accepts edges arg
1 parent 018265b commit 852b019

3 files changed

Lines changed: 24 additions & 23 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta"
77

88
[project]
99
name = "spotpython"
10-
version = "0.29.5"
10+
version = "0.29.6"
1111
authors = [
1212
{ name="T. Bartz-Beielstein", email="tbb@bartzundbartz.de" }
1313
]

src/spotpython/utils/effects.py

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -229,35 +229,32 @@ def screening_print(X, fun, xi, p, labels, bounds=None) -> pd.DataFrame:
229229
return df
230230

231231

232-
def screening_plot(X, fun, xi, p, labels, bounds=None, show=True):
232+
def screening_plot(X, fun, xi, p, labels, bounds=None, show=True) -> None:
233233
"""Generates a plot with elementary effect screening metrics.
234234
235235
This function calculates the mean and standard deviation of the
236236
elementary effects for a given set of design variables and plots
237237
the results.
238238
239239
Args:
240-
X (np.ndarray): The screening plan matrix, typically structured
241-
within a [0,1]^k box.
242-
fun (object): The objective function to evaluate at each
243-
design point in the screening plan.
244-
xi (float): The elementary effect step length factor.
245-
p (int): Number of discrete levels along each dimension.
246-
labels (list of str): A list of variable names corresponding to
247-
the design variables.
248-
bounds (np.ndarray): A 2xk matrix where the first row contains
249-
lower bounds and the second row contains upper bounds for
250-
each variable.
251-
show: (bool): If True, the plot is displayed. Defaults to True.
240+
X (np.ndarray):
241+
The screening plan matrix, typically structured within a [0,1]^k box.
242+
fun (object):
243+
The objective function to evaluate at each design point in the screening plan.
244+
xi (float):
245+
The elementary effect step length factor.
246+
p (int):
247+
Number of discrete levels along each dimension.
248+
labels (list of str):
249+
A list of variable names corresponding to the design variables.
250+
bounds (np.ndarray):
251+
A 2xk matrix where the first row contains lower bounds and
252+
the second row contains upper bounds for each variable.
253+
show (bool):
254+
If True, the plot is displayed. Defaults to True.
252255
253256
Returns:
254-
pd.DataFrame: A DataFrame containing three columns:
255-
- 'varname': The name of each variable.
256-
- 'mean': The mean of the elementary effects for each variable.
257-
- 'sd': The standard deviation of the elementary effects for
258-
each variable.
259-
or None: If print is set to False, a plot of the results is
260-
generated instead of returning a DataFrame.
257+
None: The function generates a plot of the results.
261258
262259
Examples:
263260
>>> import numpy as np

src/spotpython/utils/sampling.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ def mmlhs(X_start: np.ndarray, population: int, iterations: int, q: Optional[flo
620620
return X_best
621621

622622

623-
def bestlh(n: int, k: int, population: int, iterations: int, p=1, plot=False, verbosity=0) -> np.ndarray:
623+
def bestlh(n: int, k: int, population: int, iterations: int, p=1, plot=False, verbosity=0, edges=0) -> np.ndarray:
624624
"""
625625
Generates an optimized Latin hypercube by evolving the Morris-Mitchell
626626
criterion across multiple exponents (q values) and selecting the best plan.
@@ -642,6 +642,10 @@ def bestlh(n: int, k: int, population: int, iterations: int, p=1, plot=False, ve
642642
will be displayed. Only if k>=2. Defaults to False.
643643
verbosity (int, optional):
644644
Verbosity level. 0 is silent, 1 prints the best q value found. Defaults to 0.
645+
edges (int, optional):
646+
If 1, places centers of the extreme bins at the domain edges ([0,1]).
647+
Otherwise, bins are fully contained within the domain, i.e. midpoints.
648+
Defaults to 0.
645649
646650
Returns:
647651
np.ndarray:
@@ -675,7 +679,7 @@ def bestlh(n: int, k: int, population: int, iterations: int, p=1, plot=False, ve
675679
q_list = [1, 2, 5, 10, 20, 50, 100]
676680

677681
# Start with a random Latin hypercube
678-
X_start = rlh(n, k, edges=1)
682+
X_start = rlh(n, k, edges=edges)
679683

680684
# Allocate a 3D array to store the results for each q
681685
# (shape: (n, k, number_of_q_values))

0 commit comments

Comments
 (0)