-
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 register_is_from_calibrated_layout and is_calibrated_layout to Device #586
Conversation
if ( | ||
isinstance(register, BaseRegister) | ||
and register._layout_info is None | ||
): | ||
return False | ||
return self.is_calibrated_layout(cast(RegisterLayout, register.layout)) | ||
|
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 will raise an AttributeError
when register_layout
is not a MappableRegister
nor a BaseRegister
. I think a TypeError
would be more appropriate in that case, so perhaps we can check the type of register_layout
first.
if not isinstance(register, BaseRegister) or isinstance( | ||
register, MappableRegister |
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.
if not isinstance(register, BaseRegister) or isinstance( | |
register, MappableRegister | |
if not isinstance(register, (BaseRegister, MappableRegister)) |
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, let's wait for @MatthieuMoreau0
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!
Main changes: e0943d9 Override `optimal_detuning_off` on stored calls (#588) 3e40319 Deprecate legacy serializer + Improve error messages (#585) 9e05982 Adding register_is_from_calibrated_layout and is_calibrated_layout to Device (#586) c08dfa8 Adding dmm config and modulation to sequence (#564) 5270944 Clarify the Conventions in Pulser (#573) 2315989 Give access to all EOM block parameters and allow for phase drift correction (#566) d5ac020 Adding DetuningMap, DMM (#539) f56a19f Remove expired deprecations in pulser-pasqal
As suggested by @HGSilveri:
Add two new methods to
Device
:Device.is_calibrated_layout(layout: RegisterLayout)
: Checks whether a layout is within the calibrated layouts.Device.register_is_from_calibrated_layout(register: BaseRegister|MappableRegister)
: Checks whether the register was constructed from a pre-calibrated layout (ie checks if it has a layout ANDis_calibrated_layout(layout)
)As discussed, returns a boolean and not an error.
register_is_from_calibrated_layout works with BaseRegister (hence Register and Register3D) and MappableRegister (always has a layout in this case) because the type of the register in a sequence can be of type one of these two types.
Closes #577