-
Notifications
You must be signed in to change notification settings - Fork 167
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Add from complex matrix function #412
Conversation
bd7e12b
to
762576d
Compare
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.
Update: I confirmed it is not possible, we have to stick with the current implementation
I agree that we should make #411 possible, but I would implement this differently.
If we make a generic function that can take arbitrary Python, it would have the same effect and avoid PyO3/pyo3#1798. We could also support optional callables to make it even more flexible e.g:
# without optional arguments
retworkx.PyGraph.from_custom_adjacency_matrix(adjacency_matrix) # complex numbers
# with optional arguments
retworkx.PyGraph.from_custom_adjacency_matrix(
adjacency_matrix,
weight_fn=lambda x: x.imag,
null_value=0.0
) # example to do arbitrary conversions etc
This commit adds a new constructor method from_complex_adjacency_matrix that will build a new graph from an adjacency matrix with complex elements. Fixes Qiskit#411
This commit updates the implementation of the from_adjacency_matrix() functions to have a shared generic private function to be shared across the per type variants. To accomplish this the IsNan trait from rust nightly is copied into retworkx (so we can build with stable rust). If in the future if an int type variant is added we'll need to implement this trait for the int type (and just return false). Co-authored-by: georgios-ts <45130028+georgios-ts@users.noreply.github.com>
857b009
to
c446083
Compare
Pull Request Test Coverage Report for Build 1221392238
💛 - Coveralls |
Co-authored-by: georgios-ts <45130028+georgios-ts@users.noreply.github.com>
Co-authored-by: georgios-ts <45130028+georgios-ts@users.noreply.github.com>
This commit adds a new constructor method from_complex_adjacency_matrix
that will build a new graph from an adjacency matrix with complex
elements.
Fixes #411
TODO: