Skip to content

Commit

Permalink
Better exception message
Browse files Browse the repository at this point in the history
  • Loading branch information
Uri Granta committed Sep 10, 2024
1 parent b95af67 commit 69448cf
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions trieste/space.py
Original file line number Diff line number Diff line change
Expand Up @@ -656,8 +656,8 @@ def one_hot_encoder(self) -> EncoderFunction:

def binary_encoder(x: TensorType) -> TensorType:
# no need to one-hot encode binary categories (but we should still validate)
if not tf.reduce_all((x == 0) | (x == 1)):
raise ValueError(f"Invalid value {x}")
if tf.reduce_any((x != 0) & (x != 1)):
raise ValueError(f"Invalid values {tf.boolean_mask(x, ((x != 0) & (x != 1)))}")
return x

def encoder(x: TensorType) -> TensorType:
Expand Down

0 comments on commit 69448cf

Please sign in to comment.