-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Add get_parameter_by_uuid
to CircuitData
#12926
Conversation
- This method receives a `uuid` instance from Python and returns the parameter object identified by said `uuid`.
One or more of the following people are relevant to this code:
|
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.
Thanks Ray, this looks very sensible to me.
crates/circuit/src/circuit_data.rs
Outdated
|
||
pub fn get_parameter_by_uuid(&self, py: Python, uuid: ParameterUuid) -> Option<Py<PyAny>> { | ||
self.param_table | ||
.py_parameter_by_uuid(uuid) | ||
.map(|ob| ob.clone_ref(py)) | ||
} | ||
|
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.
Does this need to be a pymethod
?
Do you think there might any reason to call this without needing the GIL? If so, we could return the Option<&Py<PyAny>>
directly and let the caller handle cloning the reference if they need it. I can't think of a huge amount of use for that, though.
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 don't see a need for it to be a pymethod
mainly other than keeping it consistent with the counterpart method that allows for you to look for a parameter by name. Now, I could turn it into a rust-native method and then have a pymethod
call directly to it, unless we won't use this at all.
Pull Request Test Coverage Report for Build 10308429432Details
💛 - Coveralls |
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.
Cool, thanks!
Summary
The following commits add a method
get_parameter_by_uuid
to obtain theParameter
object fromCircuitData
byuuid
.Details and comments
The method retrieves a
Parameter
object from theParameterTable
based on itsuuid
without exposing any extra data. This could be useful when performing mapping based parameter assignment (as one of the methods from #12913 attempts to do), from rust-space, without having to necessarily pass the aParameter
object to do so.Known issues:
Nothing so far but, if anything is found, leave a comment or review. Thank you!