JuliaPy / JuliaPy/PyCall.jl

keep python nested list/array structure

オープン
#142 コメント 8 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Julia
スター
1.5k
フォーク
186
PR マージ指標
30日以内にマージされた PR はありません

説明

I was wondering is there any way to retain structure of python nested lists.

In Python - a nested list/array is defined:
e = [[1,2,3],[9,8,[3,2,1]]]

The standard PyCall import output in Julia looks like this:
2x3 Array{Any,2}:
1 2 3
9 8 Any[3,2,1]

Often conversion to multidimensional arrays is very convenient but sometimes I need a bit more explicit control, especially when I want to keep things in order. I'm looking basically for a 1:1 representation:

[1,2,3],[9,8,Any[3,2,1]]

Is there any way I can instruct Julia/PyCall not to do the conversion into multidimensional arrays?
So far I can prevent it by sticking to pyobject type, but then I'm not sure what is the right PyCall's conversion function.

@pyimport mymodule
c = [] # which initilalzes 1-dim Array
PyCall.py2array(c,mymodule.pymember("e"))

Thanks

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。