From b9c1bb1a69d8cdf04ee4d374fd66483186531641 Mon Sep 17 00:00:00 2001 From: lucasplagwitz Date: Wed, 2 Sep 2020 00:16:07 +0200 Subject: [PATCH] set matplotlib.backend by export --- build_tools/circle/build_doc.sh | 1 + doc/conf.py | 12 +++++------- examples/exploration-vs-exploitation.py | 3 +-- examples/interruptible-optimization.py | 21 +++++++++++---------- 4 files changed, 18 insertions(+), 19 deletions(-) diff --git a/build_tools/circle/build_doc.sh b/build_tools/circle/build_doc.sh index 8649463cd..e293f346b 100755 --- a/build_tools/circle/build_doc.sh +++ b/build_tools/circle/build_doc.sh @@ -174,6 +174,7 @@ conda create -n $CONDA_ENV_NAME --yes --quiet python="${PYTHON_VERSION:-*}" \ scikit-image="${SCIKIT_IMAGE_VERSION:-*}" pandas="${PANDAS_VERSION:-*}" \ joblib memory_profiler packaging +export MPLBACKEND="agg" source activate testenv pip install sphinx-gallery pip install numpydoc diff --git a/doc/conf.py b/doc/conf.py index 3a842424e..793851cc5 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -15,20 +15,18 @@ # import os # import sys # sys.path.insert(0, os.path.abspath('.')) +import sys +import os +sys.path.insert(0, os.path.abspath('sphinxext')) +import sphinx_gallery import warnings -import os import re from packaging.version import parse # import pkg_resources -import sys import skopt - -sys.path.insert(0, os.path.abspath('sphinxext')) from github_link import make_linkcode_resolve -import matplotlib -matplotlib.use('Agg') -import sphinx_gallery + # __version__ = pkg_resources.get_distribution('skopt').version on_rtd = os.environ.get('READTHEDOCS', None) == 'True' diff --git a/examples/exploration-vs-exploitation.py b/examples/exploration-vs-exploitation.py index 3a0f0b872..c00fd205f 100644 --- a/examples/exploration-vs-exploitation.py +++ b/examples/exploration-vs-exploitation.py @@ -59,12 +59,11 @@ def objective(x, noise_level=noise_level): def objective_wo_noise(x): return objective(x, noise_level=0) - ############################################################################# + opt = Optimizer([(-2.0, 2.0)], "GP", n_initial_points=3, acq_optimizer="sampling") - ############################################################################# # Plotting parameters diff --git a/examples/interruptible-optimization.py b/examples/interruptible-optimization.py index d3ea368e8..b10b71c8f 100644 --- a/examples/interruptible-optimization.py +++ b/examples/interruptible-optimization.py @@ -63,14 +63,15 @@ def obj_fun(x, noise_level=noise_level): checkpoint_saver = CheckpointSaver("./checkpoint.pkl", compress=9) # keyword arguments will be passed to `skopt.dump` -gp_minimize(obj_fun, # the function to minimize - [(-20.0, 20.0)], # the bounds on each dimension of x - x0=[-20.], # the starting point - acq_func="LCB", # the acquisition function (optional) - n_calls=10, # the number of evaluations of f including at x0 - n_random_starts=3, # the number of random initial points - callback=[checkpoint_saver], # a list of callbacks including the checkpoint saver - random_state=777); +gp_minimize(obj_fun, # the function to minimize + [(-20.0, 20.0)], # the bounds on each dimension of x + x0=[-20.], # the starting point + acq_func="LCB", # the acquisition function (optional) + n_calls=10, # number of evaluations of f including at x0 + n_random_starts=3, # the number of random initial points + callback=[checkpoint_saver], + # a list of callbacks including the checkpoint saver + random_state=777) ############################################################################# # Now let's assume this did not finish at once but took some long time: you @@ -111,10 +112,10 @@ def obj_fun(x, noise_level=noise_level): x0=x0, # already examined values for x y0=y0, # observed values for x0 acq_func="LCB", # the acquisition function (optional) - n_calls=10, # the number of evaluations of f including at x0 + n_calls=10, # number of evaluations of f including at x0 n_random_starts=3, # the number of random initialization points callback=[checkpoint_saver], - random_state=777); + random_state=777) ############################################################################# # Possible problems