diff --git a/pyproximal/proximal/Box.py b/pyproximal/proximal/Box.py index 9f52cf3..7adc82d 100644 --- a/pyproximal/proximal/Box.py +++ b/pyproximal/proximal/Box.py @@ -38,7 +38,7 @@ def __init__( self.box = BoxProj(self.lower, self.upper) def __call__(self, x: NDArray) -> bool: - return bool(np.all((x > self.lower) & (x < self.upper))) + return bool(np.all((x >= self.lower) & (x <= self.upper))) @_check_tau def prox(self, x: NDArray, tau: float) -> NDArray: diff --git a/pytests/test_projection.py b/pytests/test_projection.py index 2b91cca..b2d66e4 100644 --- a/pytests/test_projection.py +++ b/pytests/test_projection.py @@ -31,6 +31,11 @@ def test_Box(par): box = Box(-1, 1) x = np.random.normal(0.0, 1.0, par["nx"]).astype(par["dtype"]) + # evaluation + assert box(x) is False + xp = box.prox(x, 1.0) + assert box(xp) is True + # prox / dualprox tau = 2.0 assert moreau(box, x, tau)