Type conversion of `masked_array` in `numpy.ma`
- Langage dominant
- Julia
- Étoiles
- 1.5k
- Forks
- 186
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Description
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}
```
Guide de contribution
Aucun guide de contribution indexé pour ce dépôt
Piste de recherche
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.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- julia, numpy, python
- Domaine
- developer-experience
- Type d'issue
- Bug
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 35/100