JuliaPy / JuliaPy/PyCall.jl

Type conversion of `masked_array` in `numpy.ma`

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

説明

Also described in my question in StackOverflow: [How to create a masked array using numpy.ma imported by PyCall in Julia](http://stackoverflow.com/questions/35709042/how-to-create-a-masked-array-using-numpy-ma-imported-by-pycall-in-julia/35710432#35710432)

I was trying to create a `masked_array` Python object with `numpy.ma`.

``` julia
using PyCall
@pyimport numpy.ma as ma
x = ma.masked_equal([0, 1, 0, 2, 3], 0)
ma.is_masked(x)
```

The output, however, is just a Julia array.

```julia
julia> x = ma.masked_equal([0, 1, 0, 2, 3], 0)
5-element Array{Int64,1}:
0
1
0
2
3
julia> ma.is_masked(x)
false
```

The correct output can be obtained by using `pycall()` (thank Matt B. for pointing it out in my stackoverflow question):

```julia
julia> x = pycall(ma.masked_equal, Any, [0,1,0,2,3], 0)
PyObject masked_array(data = [-- 1 -- 2 3],
mask = [ True False True False False],
fill_value = 0)
julia> ma.is_masked(x)
true
```

It happens because PyCall considers the `masked_array` as just a usual array.

```julia
julia> pytype_query(x)
Array{Int64,N}
```

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

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

評価

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

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

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