Arrays of structs should be returned as a list of the struct objects
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 32/100
Línea de trabajo
No source file or test is named. Start by reproducing the MATLAB Engine cases with a = whos and a Simulink.BusElement array, then trace the conversion and ml.get/indexing entry points. Done means struct arrays become usable Python lists of struct objects and BusElement access no longer fails.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Currently, using Matlab 2019a and the associated Matlab Engine.
The engine fails to convert arrays of structs, which is a known limitation. However, the equivalent of a vector in Matlab is simply a list in Python, or, for a matrix, a list of lists. Other non-struct items correctly translate this way. The struct arrays should simply pass a list of struct objects to Python (which may need further conversion to be usable).
I worked around this by checking if it is a struct with max(size) greater than 1, and if so, I convert the variable to a cell with the struct2cell property, then pull the object into Python, which pulls it in as a list of the struct objects (or list of lists). The engine should be able to do this directly, rather than having to figure out whether to do a conversion first in the Matlab workspace.
An example of such an object is the output of whos: a = whos in Matlab.
Simulink.BusElement example and different error
Also, the Simulink.BusElement object of a Simulink.Bus will be a vector (though could be size 1). It will pull the multi-dimensional struct array into an object in Python, but the .get property fails, even if accessing the keys. i.e. ml.get(BusElement[0]) fails when BusElement is the matlab object given for the Elements property of a Simulink.Bus after translation into Python. The odd thing here is this fails with a different error. There seems to be a problem with the array indexing either in the struct array object, or the get function, or both.
Note
I just happened across the get and struct2cell properties by chance after a lot of digging from a stray answer for something else. I was pulling my hair out on getting this to work. Better documentation or examples for different types would be very helpful.
- Lenguaje dominante
- Python
- Estrellas
- 97
- Forks
- 13
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de mathworks/matlab-engine-for-python
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 78/100
-
Dificultad 3/5 1-2 días Aptitud para principiantes 38/100
-
Support sparse array Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 42/100
-
Dificultad 4/5 3-5 días Aptitud para principiantes 25/100
-
Failed to build matlabengine Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 25/100
Todos los issues de mathworks/matlab-engine-for-python
Issues similares
-
triage/confirmed
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
agentscope-ai/agentscope#2775 ·
-
comp/desktop P3 type/bug
Dificultad 1/5 Menos de una hora Aptitud para principiantes 92/100
NousResearch/hermes-agent#118866 ·
-
bug
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
apache/cloudstack#14222 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100