|
3 | 3 | import array as py_array |
4 | 4 | import ctypes |
5 | 5 | import enum |
| 6 | +import warnings |
6 | 7 | from dataclasses import dataclass |
7 | 8 | from typing import Any, List, Optional, Tuple, Union |
8 | 9 |
|
@@ -43,6 +44,9 @@ def __init__( |
43 | 44 | pointer_source: PointerSource = PointerSource.host, offset: Optional[ctypes._SimpleCData[int]] = None, |
44 | 45 | strides: Optional[ShapeType] = None) -> None: |
45 | 46 | _no_initial_dtype = False # HACK, FIXME |
| 47 | + warnings.warn( |
| 48 | + "Initialisation with __init__ constructor is about to be deprecated and replaced with asarray() method.", |
| 49 | + DeprecationWarning, stacklevel=2) |
46 | 50 |
|
47 | 51 | # Initialise array object |
48 | 52 | self.arr = ctypes.c_void_p(0) |
@@ -773,6 +777,7 @@ def __int__(self) -> int: |
773 | 777 | return NotImplemented |
774 | 778 |
|
775 | 779 | def __len__(self) -> int: |
| 780 | + # NOTE a part of the array-api spec |
776 | 781 | return self.shape[0] if self.shape else 0 |
777 | 782 |
|
778 | 783 | def __setitem__( |
@@ -989,7 +994,7 @@ def _get_cshape(shape: Optional[ShapeType], buffer_length: int) -> CShape: |
989 | 994 | if buffer_length != 0: |
990 | 995 | return CShape(buffer_length) |
991 | 996 |
|
992 | | - raise RuntimeError("Shape and buffer length are size invalid.") |
| 997 | + raise RuntimeError("Shape and buffer length have invalid size to process them into C shape.") |
993 | 998 |
|
994 | 999 |
|
995 | 1000 | def _c_api_value_to_dtype(value: int) -> Dtype: |
|
0 commit comments