-
Notifications
You must be signed in to change notification settings - Fork 1
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 MOI_PythonCall
extension + Add
#10
Merged
Merged
Changes from all commits
Commits
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 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 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,10 @@ | ||
module MOI_PythonCall | ||
|
||
import MathOptInterface as MOI | ||
import PythonCall | ||
|
||
if !hasmethod(MOI.Utilities.map_indices, Tuple{PythonCall.Py}) | ||
MOI.Utilities.map_indices(::Function, obj::PythonCall.Py) = obj | ||
end | ||
|
||
end # module MOI_PythonCall |
This file contains 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 |
---|---|---|
@@ -1,2 +1,6 @@ | ||
[deps] | ||
PythonCall = "6099a3de-0909-46bc-b1f4-468b9a2dfc0d" | ||
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" | ||
|
||
[compat] | ||
PythonCall = "0.9.14" |
This file contains 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,21 @@ | ||
function test_moi_pythoncall_ext() | ||
@testset "⚠ MathOptInterface-PythonCall ⚠" begin | ||
py_objs = [ | ||
PythonCall.pylist([1, 2, 3]), | ||
PythonCall.pydict(Dict("a" => 1, "b" => 2, "c" => 3)), | ||
PythonCall.pytuple((1, 2, 3)), | ||
PythonCall.pyset(Set([1, 2, 3])), | ||
PythonCall.pyint(1), | ||
PythonCall.pyfloat(1.0), | ||
PythonCall.pycomplex(1.0 + 1.0im), | ||
PythonCall.pystr("1"), | ||
PythonCall.pybool(true), | ||
] | ||
|
||
for py_obj in py_objs | ||
@test MOI.Utilities.map_indices(identity, py_obj) === py_obj | ||
end | ||
end | ||
|
||
return nothing | ||
end |
This file contains 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,9 @@ | ||
include("MOI_PythonCall.jl") | ||
|
||
function test_extensions() | ||
@testset "□ Extensions" verbose = true begin | ||
test_moi_pythoncall_ext() | ||
end | ||
|
||
return nothing | ||
end |
This file contains 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
Oops, something went wrong.
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.
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.
What was the motivation for adding as an extension?
MOI will always be loaded by QUBODrivers.jl (it is a direct dependency).
This method could have been added directly to
src
.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.
MOI is always loaded but PythonCall isn't.
PythonCall is also double-trouble: besides being heavy, precompiling it involves installing and managing python deps. We don't want to add it as a QUBODrivers dep