JuliaPy / JuliaPy/PyCall.jl

Some ndarrays are not translated to Julia arrays

Abierto
#805 0 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
Julia
Estrellas
1.5k
Forks
186
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

I am not sure how to reduce this. This requires `pymatgen` library which can be installed by `conda install --channel conda-forge pymatgen`.

```julia
julia> using PyCall

julia> pmg = pyimport("pymatgen")
PyObject

julia> structure = pmg.Structure.from_file("D:/Temp/C.vasp")
PyObject Structure Summary
Lattice
abc : 4.3635439873 4.363543987280233 69.108813801
angles : 90.0 90.0 60.00000381533356
volume : 1139.5747128269852
A : 4.3635439873 0.0 0.0
B : 2.181771742 3.7789400888 0.0
C : 0.0 0.0 69.108813801
PeriodicSite: C (-1.0909, -0.6298, 6.7636) [-0.1667, -0.1667, 0.0979]
PeriodicSite: C (-3.2727, -1.8895, 20.2908) [-0.5000, -0.5000, 0.2936]
PeriodicSite: C (-5.4544, -3.1491, 33.8180) [-0.8333, -0.8333, 0.4893]
PeriodicSite: C (-7.6362, -4.4088, 47.3452) [-1.1667, -1.1667, 0.6851]

julia> structure.lattice.matrix # expect a julia matrix here.
PyObject array([[ 4.36354399, 0. , 0. ],
[ 2.18177174, 3.77894009, 0. ],
[ 0. , 0. , 69.1088138 ]])
```
I was expecting a julia matrix in the last output. `D:/Temp/C.vasp` is here
```
C
1.0
4.3635439873 0.0000000000 0.0000000000
2.1817717420 3.7789400888 0.0000000000
0.0000000000 0.0000000000 69.1088138010
C
4
Cartesian
-1.090885694 -0.629823198 6.763601725
-3.272657083 -1.889469593 20.290805175
-5.454428472 -3.149115989 33.818008626
-7.636199861 -4.408762384 47.345212076
```

In Python
```python
In [3]: import pymatgen as pmg

In [4]: structure = pmg.Structure.from_file("D:/Temp/C.vasp")

In [5]: structure.lattice.matrix
Out[5]:
array([[ 4.36354399, 0. , 0. ],
[ 2.18177174, 3.77894009, 0. ],
[ 0. , 0. , 69.1088138 ]])

In [6]: type(structure.lattice.matrix)
Out[6]: numpy.ndarray
```

```julia
julia> versioninfo()
Julia Version 1.5.0
Commit 96786e22cc (2020-08-01 23:44 UTC)
Platform Info:
OS: Windows (x86_64-w64-mingw32)
CPU: Intel(R) Core(TM) i5-8265U CPU @ 1.60GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-9.0.1 (ORCJIT, skylake)

(@v1.5) pkg> st
Status `C:\Users\xxx\.julia\environments\v1.5\Project.toml`
[7073ff75] IJulia v1.21.2
[438e738f] PyCall v1.91.4
[d330b81b] PyPlot v2.9.0
[295af30f] Revise v2.7.3
```

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Línea de trabajo

No se nombra ningún archivo fuente ni ninguna prueba. Reproduce el caso de Julia 1.5/Windows con PyCall y pymatgen y, a continuación, sigue cómo se devuelve structure.lattice.matrix, un numpy.ndarray; se considera terminado cuando el ndarray se convierte en la matriz de Julia esperada sin romper el manejo de otros arrays de Python.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
julia, numpy, python
Área
data
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Necesita aclaración
Aptitud para principiantes
25/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.