Hi, I'm evaluating Jep 3.8.2 and feel stuck with a floating type conversion issue.
I'm new to Jep and Python though.
My Java application hands over an object of a protobuf-generated class to a Python script, for some user-supplied computation. The class contains data of type List<Float> that should be modified in Python and then be written back to the Java protobuf object.
It's fine to convert the list of Java Floats to a float32 numpy array on the Py side, but the problem is getting back the float32 to Java.
There is always auto-conversion by Jep. When I acess the data afterwards in Java, my List<Float> contains Double objects, and casting is a mess. Especially since my application is generic, i.e. it does not know the protobuf classes.
In isolated testing, the conversion would work using jep.getValue("myFloat", Float.class), but in the real project my floats are not top-level, instead they are embedded inside the protobuf class.
With jep.getValue("np.float32(myFloat)") I still get Double, and struct.pack("=f", myFloat) gives String.
It's a scientifc project with high data rates and volumes, so that defining the protobuf types as double is probably not an option.
The Py scripts are meant to be written by non-software people and should ideally not contain Jep- oder Java-specific code.
Can anyone help me how to set 32 bit floats from Python on a Java object?
With type erasure, I'm especially sceptical what Jep could do for the case of List<Float>. But let's see...