は、あなたが質問をより明確に
using PyCall
@pyimport numpy as np # 'np' becomes a julia module
a = np.array([[1, 2], [3, 4]]) # access objects directly under a module
# (in this case the 'array' function)
# using a dot operator directly on the module
#> 2×2 Array{Int64,2}:
#> 1 2
#> 3 4
a = PyObject(a) # dear Julia, we appreciate the automatic
# convertion back to a julia native type,
# but let's get 'a' back in PyObject form
# here so we can use one of its methods:
#> PyObject array([[1, 2],
#> [3, 4]])
b = a[:mean](axis=1) # 'a' here is a python Object (not a python
# module), so the way to access a method
# or object that belongs to it is via the
# pythonobject[:method] syntax.
# Here we're calling the 'mean' function,
# with the appropriate keyword argument
#> 2-element Array{Float64,1}:
#> 1.5
#> 3.5
pybuiltin(:type)(b) # Use 'pybuiltin' to use built-in python
# commands (i.e. commands that are not
# under a module)
#> PyObject <type 'numpy.ndarray'>
pybuiltin(:isinstance)(b, np.ndarray)
#> true
を始めるために簡単な例です。これを行う方法:a)あなたのコードをいくつか追加します。 b)あなたの関数の目的が何であるか、それが何を計算しようとしているのかを説明してください。 c)共有するコードを実行可能にし、おそらく結果やエラーを追加してください。 d)質問である文(最後に?)を追加し、答えが何であるかを記述しようとする。 (a)、(b)、(c)、(d)の任意の組み合わせが役立ちます。 –
とにかく、ありがとう、最初の答えは私の問題を解決しました。 –