Commit 59630dc1 authored by Nico Mack's avatar Nico Mack

Fixed an issue with non scalar values in vectors

parent 13d0a571
......@@ -151,6 +151,34 @@ public class PythonExecutor extends Executor {
return (object != null) ? (Boolean) object.__tojava__(Boolean.class) : null;
}
// ---------------------------------------------------------------------------
/**
* Converts a java boolean value into a python boolean.
*
* @param value
* specifies the java boolean value to convert
* @return a python boolean initialized to the same value as the specified java boolean.
*/
// ---------------------------------------------------------------------------
private PyObject pythonizeObject(Object value) {
return (value != null) ? Py.java2py(value) : Py.None;
}
// ---------------------------------------------------------------------------
/**
* Converts a python boolean value into a java boolean.
*
* @param value
* specifies the python boolean value to convert
* @return a java boolean initialized to the same value as the specified python boolean.
*/
// ---------------------------------------------------------------------------
private Object depythonizeObject(PyObject object) {
return (object != null) ? object.__tojava__(Object.class) : null;
}
// ---------------------------------------------------------------------------
// ============================================================================
// = Low level conversion for vectors from Java to Python and back again
......@@ -190,6 +218,17 @@ public class PythonExecutor extends Executor {
// ---------------------------------------------------------------------------
private PyArray pythonizeObjectVector(List<Object> objects) {
PyArray array = new PyArray(Object.class, objects.size());
int index = 0;
for (Object value : objects) {
array.set(index++, pythonizeObject(value));
}
return array;
}
// ---------------------------------------------------------------------------
@SuppressWarnings("unchecked")
private PyArray pythonizeVectorVariable(VectorVariable<?> vector) {
PyArray array = null;
......@@ -204,6 +243,9 @@ public class PythonExecutor extends Executor {
} else if (Boolean.class.isAssignableFrom(vector.getClassOfValues())) {
List<Boolean> booleans = (List<Boolean>) vector.getValue();
array = this.pythonizeBooleanVector(booleans);
} else {
List<Object> objects = (List<Object>) vector.getValue();
array = this.pythonizeObjectVector(objects);
}
} else {
LOGGER.warn("Empty Vector {}", vector.getName()); //$NON-NLS-1$
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment