Creates a :class:`~ray.data.Dataset` from a list of NumPy ndarrays. The column name defaults to "data". Examples: >>> import numpy as np >>> import ray >>> arr = np.array([1]) >>> ray.data.from_numpy(arr) # doctest: +ELLIPSIS shape: (1, 1) ╭
(ndarrays: Union[np.ndarray, List[np.ndarray]])
| 3506 | |
| 3507 | @PublicAPI |
| 3508 | def from_numpy(ndarrays: Union[np.ndarray, List[np.ndarray]]) -> MaterializedDataset: |
| 3509 | """Creates a :class:`~ray.data.Dataset` from a list of NumPy ndarrays. |
| 3510 | |
| 3511 | The column name defaults to "data". |
| 3512 | |
| 3513 | Examples: |
| 3514 | >>> import numpy as np |
| 3515 | >>> import ray |
| 3516 | >>> arr = np.array([1]) |
| 3517 | >>> ray.data.from_numpy(arr) # doctest: +ELLIPSIS |
| 3518 | shape: (1, 1) |
| 3519 | ╭───────╮ |
| 3520 | │ data │ |
| 3521 | │ --- │ |
| 3522 | │ int64 │ |
| 3523 | ╞═══════╡ |
| 3524 | │ 1 │ |
| 3525 | ╰───────╯ |
| 3526 | (Showing 1 of 1 rows) |
| 3527 | |
| 3528 | Create a Ray Dataset from a list of NumPy arrays. |
| 3529 | |
| 3530 | >>> ray.data.from_numpy([arr, arr]) # doctest: +ELLIPSIS |
| 3531 | shape: (2, 1) |
| 3532 | ╭───────╮ |
| 3533 | │ data │ |
| 3534 | │ --- │ |
| 3535 | │ int64 │ |
| 3536 | ╞═══════╡ |
| 3537 | │ 1 │ |
| 3538 | │ 1 │ |
| 3539 | ╰───────╯ |
| 3540 | (Showing 2 of 2 rows) |
| 3541 | |
| 3542 | Args: |
| 3543 | ndarrays: A NumPy ndarray or a list of NumPy ndarrays. |
| 3544 | |
| 3545 | Returns: |
| 3546 | :class:`~ray.data.Dataset` holding data from the given ndarrays. |
| 3547 | """ |
| 3548 | if isinstance(ndarrays, np.ndarray): |
| 3549 | ndarrays = [ndarrays] |
| 3550 | |
| 3551 | return from_numpy_refs([ray.put(ndarray) for ndarray in ndarrays]) |
| 3552 | |
| 3553 | |
| 3554 | @DeveloperAPI |
nothing calls this directly
no test coverage detected
searching dependent graphs…