def tomatrix(self):
        if self.rank() != 2:
            raise ValueError('Dimensions must be of size of 2')

        return Matrix(self.shape[0], self.shape[1], self._array)
Converts MutableDenseNDimArray to Matrix. Can convert only 2-dim array, else will raise error.
dataset/ETHPy150Open sympy/sympy/sympy/tensor/array/dense_ndim_array.py/DenseNDimArray.tomatrix