-
Notifications
You must be signed in to change notification settings - Fork 240
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
check_partials
not working as intended with sparse partials
#3179
Comments
I think that's the right way to do it. Check if Val is a sparse array and convert as necessary, otherwise use rows and cols and assume it's COO |
Hi Rob, John, Bret, Thanks for your advice. Right now I'm using the more 'robust' method of manually getting the nonzero entries and specifying (I don't have any opinion on which flavor of sparse array I should be using.) |
Description
Originally sent to me as an email from @cfe316, I'm opening an issue so this can be tracked and solved. From Jacob:
"""
The docs say that OM will pick up on the sparsity pattern, but I'm worried there's a problem with this specifically during the check_partials step.
Evidence
I'm declaring partials with
self.declare_partials("P", "xu", val=<sparse matrix>)
. I see that when I run check_partials on it,1a) J_fd is missing certain entries. J_fwd is correct.
1b) The handy plot_partials function breaks.
1c) Weirdly when I run check_partials a second time, the J_fwd matrix that gets printed also drops those entries.
I can fix this by using
self.declare_partials("P", "xu", rows=r, cols=c, val=data)
where I've previously extracted r, c, and data from the sparse matrix.Q1) Does the sparsity pattern pickup only work some formats of sparse matrix? i.e. CSR but not COO?
Q2) Are the docs a lie???? [🎂 cake emoji added by John]
"""
I've poked around a bit in
problem.py
where we definecheck_partials
and I haven't found anything conclusive. It smells like some of the logic for how thederiv_value
is calculated (around here or before) might be relevant?Jacob very helpfully provided a MWE with comments to flip on or off the behavior.
Example
OpenMDAO Version
3.31.2-dev
Relevant environment information
No response
The text was updated successfully, but these errors were encountered: