def matdot(A, B, axes=((-1,), (0,))): """np.tensordot with sane defaults for matrix multiplication""" return np.tensordot(A, B, axes=axes)