From 89c76019b18f7d335c7160129a01e6d08e43dc52 Mon Sep 17 00:00:00 2001 From: jakirkham Date: Fri, 27 Sep 2024 22:05:28 -0700 Subject: [PATCH] Touch ups to `Array` --- python/kvikio/kvikio/_lib/arr.pxd | 3 +++ python/kvikio/kvikio/_lib/arr.pyi | 2 +- python/kvikio/kvikio/_lib/arr.pyx | 5 +++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/python/kvikio/kvikio/_lib/arr.pxd b/python/kvikio/kvikio/_lib/arr.pxd index a9d2b7e7f1..47bad21a3b 100644 --- a/python/kvikio/kvikio/_lib/arr.pxd +++ b/python/kvikio/kvikio/_lib/arr.pxd @@ -28,6 +28,9 @@ cdef class Array: cpdef Py_ssize_t _nbytes(self) +cpdef Array asarray(obj) + + cdef pair[uintptr_t, size_t] parse_buffer_argument( buf, size, bint accept_host_buffer ) except * diff --git a/python/kvikio/kvikio/_lib/arr.pyi b/python/kvikio/kvikio/_lib/arr.pyi index 0d2a8201eb..d2ba479895 100644 --- a/python/kvikio/kvikio/_lib/arr.pyi +++ b/python/kvikio/kvikio/_lib/arr.pyi @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2021, NVIDIA CORPORATION. All rights reserved. +# Copyright (c) 2020-2024, NVIDIA CORPORATION. All rights reserved. # See file LICENSE for terms. from typing import Generic, Tuple, TypeVar diff --git a/python/kvikio/kvikio/_lib/arr.pyx b/python/kvikio/kvikio/_lib/arr.pyx index 793a414b17..dc3b040601 100644 --- a/python/kvikio/kvikio/_lib/arr.pyx +++ b/python/kvikio/kvikio/_lib/arr.pyx @@ -289,9 +289,10 @@ cdef inline Py_ssize_t _nbytes(Py_ssize_t itemsize, nbytes *= shape_mv[i] return nbytes -cpdef asarray(obj): + +cpdef Array asarray(obj): if isinstance(obj, Array): - return obj + return obj else: return Array(obj)