Error on conversion of empty arrays to boolean.

PiperOrigin-RevId: 595264332
This commit is contained in:
Jake VanderPlas 2024-01-02 19:26:09 -08:00 committed by jax authors
parent 985a042d9a
commit c06e186f60
2 changed files with 3 additions and 3 deletions

View File

@ -36,6 +36,8 @@ Remember to align the itemized text with the first line of an item within a list
* from {mod}`jax.scipy.linalg`: `tril` and `triu`.
* The previously-deprecated method `PRNGKeyArray.unsafe_raw_array` has been
removed. Use {func}`jax.random.key_data` instead.
* `bool(empty_array)` now raises an error rather than returning `False`. This
previously raised a deprecation warning, and follows a similar change in NumPy.
## jaxlib 0.4.24

View File

@ -262,9 +262,7 @@ class ArrayImpl(basearray.Array):
raise TypeError("len() of unsized object") from err # same as numpy error
def __bool__(self):
# deprecated 2023 September 18.
# TODO(jakevdp) change to warn_on_empty=False
core.check_bool_conversion(self, warn_on_empty=True)
core.check_bool_conversion(self)
return bool(self._value)
def __float__(self):