From 57fb84709ae53124795658c6e51e50ccc50c5cd2 Mon Sep 17 00:00:00 2001 From: Eric Shi Date: Mon, 6 Jan 2025 16:30:47 -0800 Subject: [PATCH] Emit deprecation warnings for the length and owner keywords --- CHANGELOG.md | 3 +++ warp/types.py | 14 ++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cc170abc1..1b8828f5a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,9 @@ ### Changed +- Emit deprecation warnings for the use of the `owner` and `length` keywords in + the `wp.array` initializer. + ### Fixed - Fix errors during graph capture caused by module unloading ([GH-401](https://github.com/NVIDIA/warp/issues/401)). diff --git a/warp/types.py b/warp/types.py index c584392a6..50ce2cfb4 100644 --- a/warp/types.py +++ b/warp/types.py @@ -1701,8 +1701,22 @@ def __init__( ) elif length is not None: # backward compatibility + warp.utils.warn( + "The 'length' keyword is deprecated and will be removed\n" "in a future version. Use 'shape' instead.", + category=DeprecationWarning, + stacklevel=2, + ) shape = (length,) + if owner: + warp.utils.warn( + "The 'owner' keyword in the array initializer is\n" + "deprecated and will be removed in a future version. It currently has no effect.\n" + "Pass a function to the 'deleter' keyword instead.", + category=DeprecationWarning, + stacklevel=2, + ) + # determine the construction path from the given arguments if data is not None: # data or ptr, not both