-
Notifications
You must be signed in to change notification settings - Fork 65
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
Adding ability to perturb a vector by some factor #861
Adding ability to perturb a vector by some factor #861
Conversation
…/toqito into 260-perturb-vector
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #861 +/- ##
======================================
Coverage 97.9% 97.9%
======================================
Files 165 166 +1
Lines 3253 3262 +9
Branches 713 715 +2
======================================
+ Hits 3185 3194 +9
Misses 44 44
Partials 24 24 ☔ View full report in Codecov by Sentry. |
toqito/matrix_ops/perturb_vectors.py
Outdated
>>> from toqito.matrix_ops import perturb_vectors | ||
>>> import numpy as np | ||
>>> vectors = [np.array([1.0, 2.0]), np.array([3.0, 4.0])] | ||
>>> perturbed_vectors = perturb_vectors(vectors, eps=0.1) |
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.
>>> perturbed_vectors = perturb_vectors(vectors, eps=0.1) | |
>>> perturb_vectors(vectors, eps=0.1) |
Show the output as we want it to show in the documentation build. You can use # doctest: +SKIP
for doctest failures as we expect the output to be different due to randn
.
toqito/toqito/rand/random_unitary.py
Line 24 in 4a4ce5e
>>> complex_dm # doctest: +SKIP |
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!
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.
This is not done yet. See #861 (comment)
Co-authored-by: Purva Thakre <66048318+purva-thakre@users.noreply.github.com>
Thanks for the changes and updates, @Shivansh20128 ! LGTM, but I'll ping @purva-thakre to see if she has any additional final comments. Great work, as always! |
>>> import numpy as np | ||
>>> vectors = [np.array([1.0, 2.0]), np.array([3.0, 4.0])] | ||
>>> perturb_vectors(vectors, eps=0.1) # doctest: +SKIP | ||
|
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.
@Shivansh20128 You have to add the output manually here. Right now, the RTD output is blank for the example.
See below for example:
toqito/toqito/rand/random_povm.py
Lines 21 to 34 in 9b355a5
>>> povms # doctest: +SKIP | |
array([[[[ 0.20649603+0.j, 0.79350397+0.j], | |
[ 0.77451456+0.j, 0.22548544+0.j]], | |
<BLANKLINE> | |
[[-0.25971638+0.j, 0.25971638+0.j], | |
[-0.28048509+0.j, 0.28048509+0.j]]], | |
<BLANKLINE> | |
<BLANKLINE> | |
[[[-0.25971638+0.j, 0.25971638+0.j], | |
[-0.28048509+0.j, 0.28048509+0.j]], | |
<BLANKLINE> | |
[[ 0.40448792+0.j, 0.59551208+0.j], | |
[ 0.10740892+0.j, 0.89259108+0.j]]]]) | |
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.
@purva-thakre Added! I hope its fine now.
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.
LGTM. Thank you for your patience @Shivansh20128 !
Description
Provide a brief description of the PR's purpose here. If your PR is supposed to fix an existing issue, use
a keyword to link your PR to the issue.
Adding the ability to perturb a vector by some random value by adding a submodule in matrix_ops.
This PR includes the docstring, the function as described in the issue mentioned, and the tests for the feature function.
#Resolves #260
Changes
Notable changes that this PR has either accomplished or will accomplish. Feel free to add more lines to the itemized list
below.
perturb_vectors
perturb_vectors
perturb_vectors
in filetest_perturb_vector.py
Checklist
Before marking your PR ready for review, make sure you checked the following locally. If this is your first PR, you might be notified of some workflow failures after a maintainer has approved the workflow jobs to be run on your PR.
Additional information is available in the documentation.
ruff
for errors related to code style and formatting.pytest
.Sphinx
build can be checked locally for any failures related to your PRlinkcheck
to check for broken links in the documentationdoctest
to verify the examples in the function docstrings work as expected.