generated from amazon-archives/__template_Apache-2.0
-
Couldn't load subscription status.
- Fork 29
feat: Make MAX_NET_DETUNING in AHS device capabilities optional and extend field validator utility functions. #272
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
Altanali
wants to merge
10
commits into
amazon-braket:main
Choose a base branch
from
Altanali:optional_net_detuning
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
95f5375
feat: Make MAX_NET_DETUNING optional for AHS validation.
ltnln eb400a3
feat: Add field validator helpers
ltnln b925289
test: Add field validators unit tests
ltnln ef86610
change: Add additional documentation to field_validatior functions.
ltnln 20c1b54
change: Add additional documentation to field_validatior functions & …
ltnln 8657633
Merge branch 'main' into optional_net_detuning
speller26 3827b95
idiomatic typinh
speller26 6dc4755
Add copyright and license information to test file
speller26 62871b9
Change List type hints to lowercase 'list'
speller26 3731450
Fix type hint for values parameter in validate_max_absolute_slope
speller26 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
157 changes: 157 additions & 0 deletions
157
...aket/analog_hamiltonian_simulator/test_validator/validators/test_field_validator_utils.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,157 @@ | ||
| # Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"). You | ||
| # may not use this file except in compliance with the License. A copy of | ||
| # the License is located at | ||
| # | ||
| # http://aws.amazon.com/apache2.0/ | ||
| # | ||
| # or in the "license" file accompanying this file. This file is | ||
| # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF | ||
| # ANY KIND, either express or implied. See the License for the specific | ||
| # language governing permissions and limitations under the License. | ||
|
|
||
| from decimal import Decimal | ||
|
|
||
| import pytest | ||
|
|
||
| from braket.analog_hamiltonian_simulator.rydberg.validators.field_validator_util import ( | ||
| validate_max_absolute_slope, | ||
| validate_time_precision, | ||
| validate_time_separation, | ||
| validate_value_precision, | ||
| ) | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| "times, min_time_separation, fail", | ||
| [ | ||
| ( | ||
| [Decimal("0.0"), Decimal("1e-5"), Decimal("2e-5"), Decimal("2.5"), Decimal("4")], | ||
| Decimal("1e-3"), | ||
| True, | ||
| ), | ||
| ( | ||
| [Decimal("0.0"), Decimal("1e-5"), Decimal("2e-5"), Decimal("2.5"), Decimal("4")], | ||
| Decimal("1e-6"), | ||
| False, | ||
| ), | ||
| ( | ||
| [Decimal("0.0"), Decimal("1"), Decimal("2"), Decimal("3"), Decimal("4")], | ||
| Decimal("1e-3"), | ||
| False, | ||
| ), | ||
| ], | ||
| ) | ||
| def test_validate_time_separation(times, min_time_separation, fail): | ||
| if fail: | ||
| with pytest.raises(ValueError): | ||
| validate_time_separation(times, min_time_separation, "test") | ||
| else: | ||
| try: | ||
| validate_time_separation(times, min_time_separation, "test") | ||
| except ValueError as e: | ||
| pytest.fail(f"Failed valid validate_min_time_separation: {str(e)}") | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| "values, max_precision, fail", | ||
| [ | ||
| ( | ||
| [Decimal("0.0"), Decimal("1e-5"), Decimal("2e-5"), Decimal("2.5"), Decimal("4")], | ||
| Decimal("1e-3"), | ||
| True, | ||
| ), | ||
| ( | ||
| [Decimal("0.0"), Decimal("1e-9"), Decimal("2e-5"), Decimal("3e-4"), Decimal("5.0")], | ||
| Decimal("1e-6"), | ||
| True, | ||
| ), | ||
| ( | ||
| [ | ||
| Decimal("0.0"), | ||
| Decimal("0.00089"), | ||
| Decimal("2e-4"), | ||
| Decimal("0.003"), | ||
| Decimal("0.21"), | ||
| Decimal("1"), | ||
| ], | ||
| Decimal("1e-5"), | ||
| False, | ||
| ), | ||
| ], | ||
| ) | ||
| def test_validate_value_precision(values, max_precision, fail): | ||
| if fail: | ||
| with pytest.raises(ValueError): | ||
| validate_value_precision(values, max_precision, "test") | ||
| else: | ||
| try: | ||
| validate_value_precision(values, max_precision, "test") | ||
| except ValueError as e: | ||
| pytest.fail(f"Failed valid validate_value_precision: {str(e)}") | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| "times, values, max_slope, fail", | ||
| [ | ||
| ( | ||
| [Decimal("0.0"), Decimal("1.0"), Decimal("2.0"), Decimal("3.0")], | ||
| [Decimal("0.0"), Decimal("2.1"), Decimal("3.2"), Decimal("3.9")], | ||
| Decimal("2.0"), | ||
| True, | ||
| ), | ||
| ( | ||
| [Decimal("0.0"), Decimal("1e-5"), Decimal("2e-5"), Decimal("3")], | ||
| [Decimal("0.0"), Decimal("1.2"), Decimal("2.34"), Decimal("2.39")], | ||
| Decimal("1.5e5"), | ||
| False, | ||
| ), | ||
| ( | ||
| [Decimal("0.0"), Decimal("1.0"), Decimal("2e-5"), Decimal("3")], | ||
| [Decimal("0.0"), Decimal("1.2"), Decimal("2.34"), Decimal("2.39")], | ||
| Decimal("1e4"), | ||
| False, | ||
| ), | ||
| ], | ||
| ) | ||
| def test_validate_max_absolute_slope(times, values, max_slope, fail): | ||
| if fail: | ||
| with pytest.raises(ValueError): | ||
| validate_max_absolute_slope(times, values, max_slope, "test") | ||
| else: | ||
| try: | ||
| validate_max_absolute_slope(times, values, max_slope, "test") | ||
| except ValueError as e: | ||
| pytest.fail(f"Failed valid validate_max_absolute_slope: {str(e)}") | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| "times, max_precision, fail", | ||
| [ | ||
| ( | ||
| [Decimal("0.0"), Decimal("1e-5"), Decimal("2e-5"), Decimal("2.5"), Decimal("4")], | ||
| Decimal("1.3"), | ||
| True, | ||
| ), | ||
| ( | ||
| [Decimal("0.0"), Decimal("1e-9"), Decimal("2e-5"), Decimal("3e-4"), Decimal("5.0")], | ||
| Decimal("1e-6"), | ||
| True, | ||
| ), | ||
| ( | ||
| [Decimal("0"), Decimal("1e-07"), Decimal("3.9e-06"), Decimal("4e-06")], | ||
| Decimal("1e-09"), | ||
| False, | ||
| ), | ||
| ], | ||
| ) | ||
| def test_validate_time_precision(times, max_precision, fail): | ||
| if fail: | ||
| with pytest.raises(ValueError): | ||
| validate_time_precision(times, max_precision, "test") | ||
| else: | ||
| try: | ||
| validate_time_precision(times, max_precision, "test") | ||
| except ValueError as e: | ||
| pytest.fail(f"Failed valid validate_min_time_precision: {str(e)}") |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
Just want to remind myself, are these four functions the only things that needs to be moved from the service side to the client side? Also it maybe good to comment on the top of each of these functions that they are only for device emulator and not for AHS local simulator [so that people won't be confused that why they are not used in this repo].
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.
Actually, don't we also need "validate_pattern_precision"?
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.
validate_pattern_precision is never used by the Device validators so I chose not to bring it over to the Default Simulator repo.
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.
Adding the additional comments makes sense for explaining the use of these helpers!