Convert the input to a numpy array if needed.
(array: npt.ArrayLike, *args, **kwargs)
| 355 | if np.lib.NumpyVersion(np.__version__) >= np.lib.NumpyVersion("1.19.0"): |
| 356 | |
| 357 | def toarray(array: npt.ArrayLike, *args, **kwargs) -> np.ndarray: |
| 358 | """Convert the input to a numpy array if needed.""" |
| 359 | with warnings.catch_warnings(): |
| 360 | warnings.simplefilter("error") |
| 361 | try: |
| 362 | array = np.array(array, *args, **kwargs) |
| 363 | except VisibleDeprecationWarning: |
| 364 | raise ValueError( |
| 365 | "cannot guess the desired dtype from the input" |
| 366 | ) |
| 367 | |
| 368 | return array |
| 369 | |
| 370 | else: |
| 371 | toarray = np.array |
no outgoing calls
no test coverage detected