diff options
| author | Bas van Beek <b.f.van.beek@vu.nl> | 2021-05-18 14:07:54 +0200 |
|---|---|---|
| committer | Bas van Beek <b.f.van.beek@vu.nl> | 2021-05-18 22:55:47 +0200 |
| commit | e8f6438ecb0b3803b03e18f96cbf67c626823405 (patch) | |
| tree | 32efc595bb4024408a940ab2cef9a970e66e7cb1 | |
| parent | bdb0e44f931eaedfb45153fd1680f5980b3a459e (diff) | |
| download | numpy-e8f6438ecb0b3803b03e18f96cbf67c626823405.tar.gz | |
TST: Add typing tests for `np.core._internal._ctypes`
| -rw-r--r-- | numpy/typing/tests/data/reveal/ndarray_misc.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/numpy/typing/tests/data/reveal/ndarray_misc.py b/numpy/typing/tests/data/reveal/ndarray_misc.py index ecc322251..1e9124006 100644 --- a/numpy/typing/tests/data/reveal/ndarray_misc.py +++ b/numpy/typing/tests/data/reveal/ndarray_misc.py @@ -7,6 +7,7 @@ function-based counterpart in `../from_numeric.py`. """ import operator +import ctypes as ct from typing import Any import numpy as np @@ -19,6 +20,22 @@ AR_f8: np.ndarray[Any, np.dtype[np.float64]] AR_i8: np.ndarray[Any, np.dtype[np.int64]] AR_U: np.ndarray[Any, np.dtype[np.str_]] +ctypes_obj = AR_f8.ctypes + +reveal_type(ctypes_obj.data) # E: int +reveal_type(ctypes_obj.shape) # E: ctypes.Array[ctypes.c_int64] +reveal_type(ctypes_obj.strides) # E: ctypes.Array[ctypes.c_int64] +reveal_type(ctypes_obj._as_parameter_) # E: ctypes.c_void_p + +reveal_type(ctypes_obj.get_data()) # E: int +reveal_type(ctypes_obj.get_shape()) # E: ctypes.Array[ctypes.c_int64] +reveal_type(ctypes_obj.get_strides()) # E: ctypes.Array[ctypes.c_int64] +reveal_type(ctypes_obj.get_as_parameter()) # E: ctypes.c_void_p + +reveal_type(ctypes_obj.data_as(ct.c_void_p)) # E: ctypes.c_void_p +reveal_type(ctypes_obj.shape_as(ct.c_longlong)) # E: ctypes.Array[ctypes.c_longlong] +reveal_type(ctypes_obj.strides_as(ct.c_ubyte)) # E: ctypes.Array[ctypes.c_ubyte] + reveal_type(f8.all()) # E: numpy.bool_ reveal_type(AR_f8.all()) # E: numpy.bool_ reveal_type(AR_f8.all(axis=0)) # E: Any |
