Skip to content

Commit 6412615

Browse files
Update NDArray[object] to be NDArray[numpy.object_] (#5571)
* fix numpy.object_ * style: pre-commit fixes --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent bb504dd commit 6412615

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

include/pybind11/numpy.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1521,7 +1521,7 @@ struct npy_format_descriptor<
15211521
enable_if_t<is_same_ignoring_cvref<T, PyObject *>::value
15221522
|| ((std::is_same<T, handle>::value || std::is_same<T, object>::value)
15231523
&& sizeof(T) == sizeof(PyObject *))>> {
1524-
static constexpr auto name = const_name("object");
1524+
static constexpr auto name = const_name("numpy.object_");
15251525

15261526
static constexpr int value = npy_api::NPY_OBJECT_;
15271527

tests/test_numpy_array.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,13 @@ def test_constructors():
302302
assert results["array_t<double>"].dtype == np.float64
303303

304304

305+
def test_array_object_type(doc):
306+
assert (
307+
doc(m.pass_array_object_return_as_list)
308+
== "pass_array_object_return_as_list(arg0: typing.Annotated[numpy.typing.ArrayLike, numpy.object_]) -> list"
309+
)
310+
311+
305312
def test_overload_resolution(msg):
306313
# Exact overload matches:
307314
assert m.overloaded(np.array([1], dtype="float64")) == "double"

0 commit comments

Comments
 (0)