-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from psrenergy/px/moi-pythoncall-ext
Add `MOI_PythonCall` extension + Add
- Loading branch information
Showing
6 changed files
with
59 additions
and
3 deletions.
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
973a41c
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.
@JuliaRegistrator register
973a41c
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.
Registration pull request created: JuliaRegistries/General/92544
After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.
This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via: