def as_numpy(self, shape=None):
        """Access the array as a numpy array.

        The numpy array shares the same underlying memory buffer, so
        changes are immediate, and you can use the numpy array as you would
        normally.  To set the entire contents of the array at once, use a
        ``[:]`` slice.

        If numpy is not installed, an ImportError will be raised.

        :rtype: numpy.ndarray
        """
        if not _have_numpy:
            raise ImportError('numpy could not be imported')
        if self.ctype not in _numpy_typemap:
            raise TypeError('%s has no numpy compatible type' % self.ctype)
        if shape is None:
            shape = (self.count,)
        ar = numpy.frombuffer(self.as_ctypes(), _numpy_typemap[self.ctype])
        ar = ar.reshape(shape)
        return ar

    # General interoperability (string)
dataset/ETHPy150Open los-cocos/cocos/cocos/audio/SDL/array.py/SDL_array.as_numpy/original