[docs]@typecheckeddefvstack(tup:Union[Tuple[pdarray],List[pdarray]],*,dtype:Optional[Union[type,str]]=None,casting:Literal["no","equiv","safe","same_kind","unsafe"]="same_kind",)->pdarray:""" Stack a sequence of arrays vertically (row-wise). This is equivalent to concatenation along the first axis after 1-D arrays of shape `(N,)` have been reshaped to `(1,N)`. Parameters ---------- tup : Tuple[pdarray] The arrays to be stacked dtype : Optional[Union[type, str]], optional The data-type of the output array. If not provided, the output array will be determined using `np.common_type` on the input arrays Defaults to None casting : {"no", "equiv", "safe", "same_kind", "unsafe"], optional Controls what kind of data casting may occur - currently unused Returns ------- pdarray The stacked array """ifcasting!="same_kind":# TODO: wasn't clear from the docs what each of the casting options doesraiseNotImplementedError(f"casting={casting} is not yet supported")# ensure all arrays have the same number of dimensionsndim=tup[0].ndimforaintup:ifa.ndim!=ndim:raiseValueError("all input arrays must have the same number of dimensions")# establish the dtype of the output arrayifdtypeisNone:dtype_=np.common_type(*[np.empty(0,dtype=a.dtype)foraintup])else:dtype_=akdtype(dtype)# cast the input arrays to the output dtype if necessaryarrays=[a.astype(dtype_)ifa.dtype!=dtype_elseaforaintup]# stack the arrays along the first axisreturncreate_pdarray(generic_msg(cmd=f"stack{ndim}D",args={"names":list(arrays),"n":len(arrays),"axis":0,},))