Description
_ArrayAnnotationBase.__repr__() interpolates the raw dtype class object directly into the format string, producing output like:
>>> import warp as wp
>>> wp.array4d[wp.uint32]
wp.array(dtype=<class 'warp._src.types.uint32'>, ndim=4)
>>> wp.array[wp.float32]
wp.array(dtype=<class 'warp._src.types.float32'>, ndim=1)
The dtype value is a class object, and str() on a class produces the <class '...'> form.
Impact
This is user-facing because Sphinx autodoc uses repr() to render Return type fields when autodoc_typehints = "description" is set.
For example, in the Newton Physics docs, functions like create_albedo_image_output() that are annotated as -> wp.array4d[wp.uint32] render as:
Return type: wp.array(dtype=<class 'warp._src.types.uint32'>, ndim=4)
This affects any downstream project using Warp array type annotations in Sphinx-documented APIs.
Relevant code
https://github.com/NVIDIA/warp/blob/main/warp/_src/types.py#L4647-L4650
def __repr__(self):
dtype_str = "Any" if self.dtype is Any else self.dtype # ← raw class object
ndim_str = "Any" if self.ndim is Any else self.ndim
return f"wp.{self._concrete_cls.__name__}(dtype={dtype_str}, ndim={ndim_str})"
Description
_ArrayAnnotationBase.__repr__()interpolates the raw dtype class object directly into the format string, producing output like:The
dtypevalue is a class object, andstr()on a class produces the<class '...'>form.Impact
This is user-facing because Sphinx autodoc uses
repr()to renderReturn typefields whenautodoc_typehints = "description"is set.For example, in the Newton Physics docs, functions like
create_albedo_image_output()that are annotated as-> wp.array4d[wp.uint32]render as:This affects any downstream project using Warp array type annotations in Sphinx-documented APIs.
Relevant code
https://github.com/NVIDIA/warp/blob/main/warp/_src/types.py#L4647-L4650