Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions python/ray/air/util/tensor_extensions/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,16 @@ def _create_possibly_ragged_ndarray(
# `np.array(...)` without the `dtype=object` parameter will raise a
# VisibleDeprecationWarning which we suppress.
# More details: https://stackoverflow.com/q/63097829
warnings.simplefilter("ignore", category=np.VisibleDeprecationWarning)
return np.array(values, copy=False)
if np.lib.NumpyVersion(np.__version__) >= "2.0.0":
copy_if_needed = None
warning_type = np.exceptions.VisibleDeprecationWarning
else:
copy_if_needed = False
warning_type = np.VisibleDeprecationWarning

warnings.simplefilter("ignore", category=warning_type)
arr = np.array(values, copy=copy_if_needed)
return arr
except ValueError as e:
# Constructing a ragged ndarray directly via `np.array(...)`
# without the `dtype=object` parameter will raise a ValueError.
Expand Down
Loading