-
Notifications
You must be signed in to change notification settings - Fork 64
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
feat: add rand_circulant_gram func #389
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #389 +/- ##
========================================
+ Coverage 97.6% 98.0% +0.4%
========================================
Files 154 156 +2
Lines 3059 3065 +6
Branches 744 742 -2
========================================
+ Hits 2987 3006 +19
+ Misses 45 37 -8
+ Partials 27 22 -5 ☔ View full report in Codecov by Sentry. |
toqito/rand/random_circulant_gram.py
Outdated
def random_circulant_gram(dim: int) -> np.ndarray: | ||
r"""Generate a random circulant Gram matrix of specified dimension. | ||
|
||
This function creates a circulant matrix based on a random diagonal matrix and the normalized Discrete |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be better to add some details/ref on what a circulant matrix is in this docstring + more details on what a normalized DFT is.
https://en.wikipedia.org/wiki/Circulant_matrix
https://ccrma.stanford.edu/~jos/st/Normalized_DFT.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have made the changes, please review it and let me know if further modification is required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might want to double-check how references are added. Other docstrings might be helpful for you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ankit-pn I think you'll want to add the links you provided within the references in docs/articles.bib
. So for instance,
@misc{WikiCirculantMat,
author = "Wikipedia",
title = "Circulant matrix",
howpublished = {https://en.wikipedia.org/wiki/Circulant_matrix}
}
And then use the :cite:
command in the docstring (as done elsewhere in toqito
) instead of putting the whole link there. Similarly for your other link as well.
I have done the changes that you have recommended. Please review it. |
toqito/rand/random_circulant_gram.py
Outdated
def random_circulant_gram(dim: int) -> np.ndarray: | ||
r"""Generate a random circulant Gram matrix of specified dimension. | ||
|
||
This function creates a circulant matrix based on a random diagonal matrix and the normalized Discrete |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ankit-pn I think you'll want to add the links you provided within the references in docs/articles.bib
. So for instance,
@misc{WikiCirculantMat,
author = "Wikipedia",
title = "Circulant matrix",
howpublished = {https://en.wikipedia.org/wiki/Circulant_matrix}
}
And then use the :cite:
command in the docstring (as done elsewhere in toqito
) instead of putting the whole link there. Similarly for your other link as well.
toqito/rand/random_circulant_gram.py
Outdated
def random_circulant_gram(dim: int) -> np.ndarray: | ||
r"""Generate a random circulant Gram matrix of specified dimension. | ||
|
||
A circulant matrix is a square matrix where each row is a shifted version of the one above, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something seems a bit off with the formatting of these lines. They should have a length of 120, but these look like they are around 80.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably because black
was used for formatting issues?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, it was because i was using formatter in wrong way. i have corrected it and do let me know if any other further changes is required.
circulant_matrix = random_circulant_gram(dim) | ||
|
||
# Ensure the matrix has the correct shape. | ||
assert circulant_matrix.shape == (dim, dim) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of using assert
here we should be using np.testing.assert_equal
(check out the other tests for reference)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
docs/rand.rst
Outdated
@@ -17,3 +17,4 @@ Random | |||
toqito.rand.random_state_vector | |||
toqito.rand.random_states | |||
toqito.rand.random_unitary | |||
toqito.rand.random_circulant_gram |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor nit: might want to move this addition up (alphabetical order)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Co-authored-by: Purva Thakre <66048318+purva-thakre@users.noreply.github.com>
Co-authored-by: Purva Thakre <66048318+purva-thakre@users.noreply.github.com>
toqito/rand/random_circulant_gram.py
Outdated
This function utilizes the normalized DFT, a variation of DFT with normalized basis vectors. This | ||
variation alters computational requirements and offers a different view on signal transformations. | ||
|
||
:cite:`StanfordNormDFT`. | ||
|
||
The function creates a circulant matrix from a random diagonal matrix and the normalized DFT matrix. | ||
First, it generates a diagonal matrix with random non-negative entries. Next, it constructs the | ||
normalized DFT matrix. Finally, it computes the circulant matrix, which is real due to its origin | ||
from the DFT of a real diagonal matrix. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be just me, but this part seems vague: This variation alters computational requirements and offers a different view on signal transformations
Could this be re-worded differently?
Co-authored-by: Purva Thakre <66048318+purva-thakre@users.noreply.github.com>
@purva-thakre i have pushed the changes, error was because of ruff check. do let me know know if any further changes required. thanks. |
Co-authored-by: Purva Thakre <66048318+purva-thakre@users.noreply.github.com>
I think this is good to go, nice job, @ankit-pn ! Anything additional to address before merging, @purva-thakre ? |
I think one of the lines in the docstring is vague. I don't think it is related to what the function is intended to do. #389 (comment) But besides this, LGTM. |
Co-authored-by: Purva Thakre <66048318+purva-thakre@users.noreply.github.com>
Thanks for pushing this over the line, @purva-thakre And thank you as well to @ankit-pn for putting this feature into toqito! |
Fixing linter.
Removing whitespace.
Description
add feat described inFixes #379Status