Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added error message in fallback to matvec failure #10925

Closed
wants to merge 8 commits into from
Closed

added error message in fallback to matvec failure #10925

wants to merge 8 commits into from

Conversation

lobpcg
Copy link
Contributor

@lobpcg lobpcg commented Oct 13, 2019

Reference issue

Closes #8444

What does this implement/fix?

added specific error message when sparse.linalg.LinearOperator.matmat cannot fallback properly to matvec, an extended version of

        try:
            return np.hstack([self.matvec(col.reshape(-1,1)) for col in X.T])
        except ValueError:
            raise ValueError('The user-defined matvec(v) function must properly'
                                      'handle the case where v has shape (N,1).')

added specific error message when sparse.linalg.LinearOperator.matmat cannot fallback properly to matvec

        try:
            return np.hstack([self.matvec(col.reshape(-1,1)) for col in X.T])
        except ValueError:
            raise ValueError('The user-defined matvec(v) function must properly
                             handle the case where v has shape (N,1).')
``` 
       except ValueError:
            col = X.T[:,0]
            matvec_col = self.matvec(col.reshape(-1,1))
            raise ValueError('The user-defined matvec(v) function must return'
                             'shape (N,1) if v has shape (N,1). Instead,'
                             'matvec(v) has shape %r, where v has shape %r.' 
                             % (matvec_col.shape, col.shape))
```
@pv
Copy link
Member

pv commented Oct 13, 2019

I think that instead of this, the error message handling of matvec() should be improved.

update the fork to the latest master
@lobpcg
Copy link
Contributor Author

lobpcg commented Oct 13, 2019

I think that instead of this, the error message handling of matvec() should be improved.

Sorry, you are correct. I forgot where the error came from and tried to fix elsewhere in this PR...

Unfortunately, I ran out of time to play with this, so just close this PR.

@tylerjereddy tylerjereddy added scipy.sparse.linalg enhancement A new feature or improvement labels Oct 15, 2019
@lobpcg lobpcg closed this Oct 19, 2019
@lobpcg lobpcg deleted the matvec_error_message branch October 19, 2019 03:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A new feature or improvement scipy.sparse.linalg
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] sparse.linalg.LinearOperator.matmat cannot fallback properly to matvec
3 participants