Skip to content

Commit 15bc8cb

Browse files
committed
Add constructor initialisation warning. Add Note on deviation from spec. Dump minimal numpy version required.
1 parent ae6be05 commit 15bc8cb

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

arrayfire/array_api/array_object.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import array as py_array
44
import ctypes
55
import enum
6+
import warnings
67
from dataclasses import dataclass
78
from typing import Any, List, Optional, Tuple, Union
89

@@ -43,6 +44,9 @@ def __init__(
4344
pointer_source: PointerSource = PointerSource.host, offset: Optional[ctypes._SimpleCData[int]] = None,
4445
strides: Optional[ShapeType] = None) -> None:
4546
_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)
4650

4751
# Initialise array object
4852
self.arr = ctypes.c_void_p(0)
@@ -773,6 +777,7 @@ def __int__(self) -> int:
773777
return NotImplemented
774778

775779
def __len__(self) -> int:
780+
# NOTE a part of the array-api spec
776781
return self.shape[0] if self.shape else 0
777782

778783
def __setitem__(
@@ -989,7 +994,7 @@ def _get_cshape(shape: Optional[ShapeType], buffer_length: int) -> CShape:
989994
if buffer_length != 0:
990995
return CShape(buffer_length)
991996

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.")
993998

994999

9951000
def _c_api_value_to_dtype(value: int) -> Dtype:

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ exclude =
2727
examples
2828
tests
2929
install_requires =
30-
numpy~=1.23.4
30+
numpy~=1.22.0
3131

3232
[options.extras_require]
3333
dev =

0 commit comments

Comments
 (0)