-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
148 additions
and
56 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 was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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,40 @@ | ||
module PyPlotSlimExt | ||
|
||
import SlimPlotting: seiscm, getcmap | ||
|
||
isdefined(Base, :get_extension) ? (using PyPlot) : (using ..PyPlot) | ||
isdefined(Base, :get_extension) ? (using PyPlot.PyCall) : (using ..PyPlot.PyCall) | ||
|
||
function tryimport(pkg::String) | ||
pyi = try | ||
PyPlot.pyimport(pkg) | ||
catch e | ||
if PyPlot.PyCall.conda | ||
PyPlot.PyCall.Conda.pip_interop(true) | ||
PyPlot.PyCall.Conda.pip("install", pkg) | ||
else | ||
run(PyPlot.PyCall.python_cmd(`-m pip install --user $(pkg)`)) | ||
end | ||
PyPlot.pyimport(pkg) | ||
end | ||
return pyi | ||
end | ||
|
||
const cc = PyNULL() | ||
const scm = PyNULL() | ||
|
||
pypltref = PyPlot | ||
|
||
function __init__() | ||
@info "Initializing PyPlotSlimExt" | ||
# Import colorcet | ||
copy!(cc, tryimport("colorcet")) | ||
# Import SeisCM | ||
copy!(scm, tryimport("seiscm")) | ||
|
||
end | ||
|
||
seiscm(s::String) = py"scm.$s"() | ||
getcmap(s) = ColorMap(s) | ||
|
||
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,38 @@ | ||
module PythonPlotSlimExt | ||
|
||
import SlimPlotting: seiscm, getcmap | ||
isdefined(Base, :get_extension) ? (using PythonPlot) : (using ..PythonPlot) | ||
|
||
function tryimport(pkg::String) | ||
pyi = try | ||
PythonPlot.pyimport(pkg) | ||
catch e | ||
if get(ENV, "JULIA_CONDAPKG_BACKEND", "conda") == "Null" | ||
pyexe = PythonPlot.PythonCall.python_executable_path() | ||
run(Cmd(`$(pyexe) -m pip install --user $(pkg)`)) | ||
else | ||
PythonPlot.CondaPkg.add_pip(pkg) | ||
end | ||
PythonPlot.pyimport(pkg) | ||
end | ||
return pyi | ||
end | ||
|
||
const cc = PythonPlot.PythonCall.pynew() | ||
const scm = PythonPlot.PythonCall.pynew() | ||
|
||
pypltref = PythonPlot | ||
|
||
function __init__() | ||
@info "Initializing PythonPlotSlimExt" | ||
# Import colorcet | ||
PythonPlot.PythonCall.pycopy!(cc, tryimport("colorcet")) | ||
# Import SeisCM | ||
PythonPlot.PythonCall.pycopy!(scm, tryimport("seiscm")) | ||
end | ||
|
||
seiscm(s::String) = PythonPlot.pygetattr(scm, s)() | ||
getcmap(s) = ColorMap(s) | ||
getcmap(c::PythonPlot.PythonCall.Py) = c | ||
|
||
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