def make_sub_jacobian(self, A, pd_type):
    if (pd_type == 'array'):
        return A
    if (pd_type == 'sparse'):
        return sparse.csr_matrix(A)
    if (pd_type == 'aij'):
        data = []
        rows = []
        cols = []
        A = np.atleast_2d(A)
        for i in range(A.shape[0]):
            for j in range(A.shape[1]):
                if (np.abs(A[(i, j)]) > 1e-15):
                    data.append(A[(i, j)])
                    rows.append(i)
                    cols.append(j)
        return [np.array(data), np.array(rows), np.array(cols)]
    raise ValueError('Unknown partial_type: {}'.format(pd_type))
def make_sub_jacobian(self, A, pd_type):
    if (pd_type == 'array'):
        return A
    if (pd_type == 'sparse'):
        return sparse.csr_matrix(A)
    if (pd_type == 'aij'):
        data = []
        rows = []
        cols = []
        A = np.atleast_2d(A)
        for i in range(A.shape[0]):
            for j in range(A.shape[1]):
                if (np.abs(A[(i, j)]) > 1e-15):
                    data.append(A[(i, j)])
                    rows.append(i)
                    cols.append(j)
        return [np.array(data), np.array(rows), np.array(cols)]
    raise ValueError('Unknown partial_type: {}'.format(pd_type))