[docs]classCast(DelayedOp):"""Delayed cast to a different NumPy type. This is most useful for promoting integer matrices to floating point to avoid problems with integer overflow in arithmetic operations. This class is intended for developers to construct new :py:class:`~delayedarray.DelayedArray.DelayedArray` instances. End users should not be interacting with ``Cast`` objects directly. """
[docs]def__init__(self,seed,dtype:dtype):""" Args: seed: Any object that satisfies the seed contract, see :py:class:`~delayedarray.DelayedArray.DelayedArray` for details. dtype: The desired type. """self._seed=seedself._dtype=dtype
@propertydefshape(self)->Tuple[int,...]:""" Returns: Tuple of integers specifying the extent of each dimension of this object. This is the same as the ``seed`` object. """returnself._seed.shape@propertydefdtype(self)->dtype:""" Returns: NumPy type for the contents after casting. """returndtype(self._dtype)@propertydefseed(self):""" Returns: The seed object. """returnself._seed