Skip to content

Test Diagonal functions against non-dense matrices #1316

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

jishnub
Copy link
Member

@jishnub jishnub commented Apr 27, 2025

In the Diagonal tests, we often compare results of function evaluations with that for the corresponding dense matrix. E.g., with D = Diagonal(::Vector) and DM = Matrix(D),

@test log(Diagonal(abs.(D.diag)))  log(abs.(DM)) atol=n^3*eps(relty)

The problem with this is that, in the dense method log(::Matrix), we check if the matrix is diagonal, and dispatch to the Diagonal methods for performance. This makes this test useless, as we are comparing identical methods.

In this PR, I've changed the type of DM to be Hermitian for real matrices, and UpperTriangular for complex ones. Both of these types have special methods for log, at least. The Hermitian matrices have special methods for all the trigonometric functions, and for the complex matrices, we wrap these in a custom wrapper NotDiagonal that avoids the isdiag paths. This wrapper lies about the structure, but it should be ok for the testing purposes as we ensure that we are comparing different paths.

Copy link

codecov bot commented Apr 27, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.71%. Comparing base (5d3d02a) to head (e022e2c).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1316      +/-   ##
==========================================
- Coverage   93.72%   93.71%   -0.02%     
==========================================
  Files          34       34              
  Lines       15733    15733              
==========================================
- Hits        14746    14744       -2     
- Misses        987      989       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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