Type conversion of `masked_array` in `numpy.ma`
- Vorherrschende Sprache
- Julia
- Sterne
- 1.5k
- Forks
- 186
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
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}
```
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Rechercherichtung
Reproduce the example with @pyimport numpy.ma, masked_equal, pycall, and pytype_query, then trace how PyCall classifies the returned masked_array. No file or test is named in the issue; done means masked_equal preserves the masked-array object so ma.is_masked(x) returns true without the Any workaround.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- julia, numpy, python
- Bereich
- developer-experience
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100