|
7 | 7 | .. autoclass:: T_co |
8 | 8 | .. autoclass:: ResultT |
9 | 9 | .. autoclass:: ShapeT |
| 10 | +.. autoclass:: NumpyTypeT |
10 | 11 |
|
11 | 12 | .. autoclass:: ObjectArray |
12 | 13 | .. autoclass:: ObjectArray0D |
|
99 | 100 |
|
100 | 101 | ResultT = TypeVar("ResultT") |
101 | 102 | ShapeT = TypeVar("ShapeT", bound=tuple[int, ...]) |
| 103 | +NumpyTypeT = TypeVar("NumpyTypeT", bound="np.generic[Any]") |
102 | 104 |
|
103 | 105 |
|
104 | 106 | class _ObjectArrayMetaclass(type): |
@@ -340,7 +342,23 @@ def from_numpy( |
340 | 342 | return cast("ObjectArray[ShapeT, T_co]", cast("object", ary)) |
341 | 343 |
|
342 | 344 |
|
343 | | -def new_1d(res_list: Sequence[T_co]) -> ObjectArray1D[T_co]: |
| 345 | +@overload |
| 346 | +def new_1d( |
| 347 | + res_list: np.ndarray[tuple[int, ...], np.dtype[NumpyTypeT]] |
| 348 | + ) -> ObjectArray1D[np.ndarray[tuple[int, ...], np.dtype[NumpyTypeT]]]: ... |
| 349 | + |
| 350 | + |
| 351 | +@overload |
| 352 | +def new_1d(res_list: Sequence[T_co]) -> ObjectArray1D[T_co]: ... |
| 353 | + |
| 354 | + |
| 355 | +def new_1d( |
| 356 | + res_list: ( |
| 357 | + Sequence[T_co] |
| 358 | + | np.ndarray[tuple[int, ...], np.dtype[NumpyTypeT]] |
| 359 | + ) |
| 360 | + ) -> (ObjectArray1D[T_co] |
| 361 | + | ObjectArray1D[np.ndarray[tuple[int, ...], np.dtype[NumpyTypeT]]]): |
344 | 362 | """Create a one-dimensional object array from *res_list*. |
345 | 363 | This differs from ``numpy.array(res_list, dtype=object)`` |
346 | 364 | by whether it tries to determine its shape by descending |
|
0 commit comments