JuliaPy / JuliaPy/PyCall.jl

keep python nested list/array structure

未关闭
#142 8 条评论 0 个 reaction 已指派 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

贡献指南

这个仓库没有索引到贡献指南

调研方向

从 PyCall.py2array 和 issue 中所示的 @pyimport 用法开始,然后检查嵌套 Python 列表如何转换为 Julia 数组。定义预期的 1:1 嵌套列表表示,并验证现有的转换入口是否能够保留该表示,而无需强制进行多维数组转换。

由索引模型根据 Issue 内容生成。

评估

技术栈
julia, python
领域
tooling
Issue 类型
功能
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。