Skip to content

Commit

Permalink
Bump version and apply more fixes (#342)
Browse files Browse the repository at this point in the history
  • Loading branch information
uri-granta authored Aug 20, 2021
1 parent 751e0ac commit bb724fa
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 11 deletions.
1 change: 1 addition & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.

on:
workflow_dispatch:
push:
tags: v[0-9]+.[0-9]+.[0-9]+*

Expand Down
1 change: 1 addition & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,6 @@ help:

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: export TF_CPP_MIN_LOG_LEVEL = 3
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" -W $(SPHINXOPTS) $(O)
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
author = "The Trieste Contributors"

# The full version, including alpha/beta/rc tags
release = "0.6.0"
release = "0.6.1"

# -- General configuration ---------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion docs/constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ requests==2.26.0
six==1.16.0
snowballstemmer==2.1.0
soupsieve==2.2.1
Sphinx==4.1.2
Sphinx==3.5.4
sphinx-autoapi==1.8.3
sphinxcontrib-applehelp==1.0.2
sphinxcontrib-bibtex==2.3.0
Expand Down
8 changes: 3 additions & 5 deletions docs/notebooks/inequality_constraints.pct.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ def batch_efi(at):
#
# We'll now show how to use a reducer to combine multiple constraints. The new problem `Sim2` inherets from the previous one its objective and first constraint, but possess a second constraint. We start by adding an output to our observer, and creating a set of three models.


# %%
class Sim2(Sim):
threshold2 = 0.5

Expand All @@ -277,25 +277,23 @@ def constraint2(input_data):
z = tf.sin(x) * tf.cos(y) - tf.cos(x) * tf.sin(y)
return z[:, None]


CONSTRAINT2 = "CONSTRAINT2"


def observer_two_constraints(query_points):
return {
OBJECTIVE: Dataset(query_points, Sim2.objective(query_points)),
CONSTRAINT: Dataset(query_points, Sim2.constraint(query_points)),
CONSTRAINT2: Dataset(query_points, Sim2.constraint2(query_points)),
}


num_initial_points = 10
initial_data = observer_two_constraints(search_space.sample(num_initial_points))
initial_models = trieste.utils.map_values(create_bo_model, initial_data)

# %% [markdown]
# Now, the probability that the two constraints are feasible is the product of the two feasibilities. Hence, we combine the two `ProbabilityOfFeasibility` into one quantity by using a `Product` `Reducer`:

# %%
from trieste.acquisition.combination import Product
pof1 = trieste.acquisition.ProbabilityOfFeasibility(threshold=Sim2.threshold)
pof2 = trieste.acquisition.ProbabilityOfFeasibility(threshold=Sim2.threshold2)
Expand All @@ -304,6 +302,7 @@ def observer_two_constraints(query_points):
# %% [markdown]
# We can now run the BO loop as before, and visualize the results:

# %%
eci = trieste.acquisition.ExpectedConstrainedImprovement(OBJECTIVE, pof) # type: ignore
rule = EfficientGlobalOptimization(eci) # type: ignore

Expand Down Expand Up @@ -348,7 +347,6 @@ def masked_objective(x):
)
plt.show()


# %% [markdown]
# ## LICENSE
#
Expand Down
5 changes: 4 additions & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

sphinx
# ping sphinx to 3.5 for now to work around https://github.com/plotly/plotly.js/issues/4563
# setting mathjax_path in docs/confg.py to https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/MathJax.js?config=TeX-MML-AM_CHTML
# SHOULD fix this, but it doesn't seem to quite
sphinx~=3.5.4
sphinx-autoapi
pydata-sphinx-theme
ipython
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

setup(
name="trieste",
version="0.6.0",
version="0.6.1",
author="The Trieste contributors",
author_email="[email protected]",
description="A Bayesian optimization research toolbox built on TensorFlow",
Expand Down
16 changes: 14 additions & 2 deletions tests/unit/test_space.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,20 @@ def test_box_raises_if_bounds_have_invalid_shape(
) -> None:
lower, upper = tf.zeros(lower_shape), tf.ones(upper_shape)

with pytest.raises(TF_DEBUGGING_ERROR_TYPES):
Box(lower, upper)
if lower_shape == upper_shape == (0,):
Box(lower, upper) # empty box is ok
else:
with pytest.raises(TF_DEBUGGING_ERROR_TYPES):
Box(lower, upper)


def test_box___mul___for_empty_search_space() -> None:
empty = Box(tf.zeros(0, dtype=tf.float64), tf.zeros(0, dtype=tf.float64))
cube = Box([0, 0, 0], [1, 1, 1])
npt.assert_array_equal((cube * empty).lower, cube.lower)
npt.assert_array_equal((cube * empty).upper, cube.upper)
npt.assert_array_equal((empty * cube).lower, cube.lower)
npt.assert_array_equal((empty * cube).upper, cube.upper)


def test_box___mul___for_empty_search_space() -> None:
Expand Down

0 comments on commit bb724fa

Please sign in to comment.