Created
December 8, 2017 19:10
-
-
Save ysaito8015/0144333c6c841d3c1f3864dcd8370195 to your computer and use it in GitHub Desktop.
julia で使う python を 3系にする ref: https://qiita.com/ysaito8015@github/items/bee0846c227b10f3f369
This file contains hidden or 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
| export CONDA_JL_VERSON="3" | |
| /paht/to/miniconda/bin/conda update --all -y | |
| export CONDA_JL_HOME="/path/to/miniconda/envs/conda_jl" |
This file contains hidden or 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
| Pkg.add("Conda.jl") | |
| using Conda | |
| Conda.PYTHONDIR # python のパス | |
| Conda.list() # インストールされている python パッケージのリスト | |
| Conda.add("パッケージ名") # python パッケージのインストール | |
| Conda.rm("パッケージ名") # python パッケージのアンインストール | |
| Conda.update() # python パッケージのアップデート |
This file contains hidden or 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
| Pkg.add("PyCall.jl") | |
| using PyCall | |
| PyCall.pyversion # python のバージョンを表示 | |
| PyCall.pyprogramname # python の絶対パス | |
| PyCall.libpython # python lib のパス | |
| PyCall.conda # Conda Python をつかっているか true, false |
This file contains hidden or 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
| using PyCall | |
| #@pyimport: import マクロ | |
| @pyimport math | |
| math.sin(math.pi / 4) - sin(pi / 4) # 0.0 | |
| @pyimport matplotlib.pyplot as plt | |
| x = linspace(0,2*pi,1000); y = sin(3*x + 4*cos(2*x)); | |
| plt.plot(x, y, color="red", linewidth=2.0, linestyle="--") | |
| plt.show() | |
| # Python の型とJulia の型を相互に変換 | |
| # TODO: Numpy array 多次元配列の渡し方について後で書き足す | |
| #@pywith: with ステートメントのマクロ | |
| @pywith pybuiltin("open")("file.txt","w") as f begin | |
| f[:write]("hello") | |
| end | |
| #オブジェクトのアトリビュート/メンバーズの扱いについてpythonとの違い | |
| @pyimport Bio.Seq as s | |
| @pyimport Bio.Alphabet as a | |
| my_dna = s.Seq("AGTACACTGGT", a.generic_dna) | |
| my_dna[:find]("ACT") # Python の場合は my_dna.find("ACT") | |
| # Python での `o.method(...)` を `o[:method](...)` に置き換える |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment