Skip to content

More robust digonal constant check#2173

Open
jessegrabowski wants to merge 4 commits into
pymc-devs:mainfrom
jessegrabowski:symmetric-check-fix
Open

More robust digonal constant check#2173
jessegrabowski wants to merge 4 commits into
pymc-devs:mainfrom
jessegrabowski:symmetric-check-fix

Conversation

@jessegrabowski
Copy link
Copy Markdown
Member

pymc-extras surfaced a small bug in _diagonal_from_constant, which used multiplication by a masking matrix to check for non-zero off-diagonal values. This raises a warning when there are non-finite values (inf/nan) in the matrix being checked. Use indexing instead to avoid the warnings.

@jessegrabowski jessegrabowski requested a review from ricardoV94 May 26, 2026 17:48
@jessegrabowski
Copy link
Copy Markdown
Member Author

I also upgraded the performance for checking diagonality. The cheapest thing me and mr. bot could come up with is to check if the number of nonzero entries in the matrix is equal to the number on the diagonal. If this is true, the matrix must be diagonal. This avoids allocation of a mask matrix, and seems to be a highly optimized numpy function (~2x speedup vs np.any(x, where=mask) even excluding the cost of building the mask)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant