Open stevekew opened 6 years ago
I am also having trouble with that. The object that is being passed to the method is an int
, but not a python primitive, but a java int
primitive. I am trying all too desperately to convert the passed argument to something Python can work with, either numpy or whatever, because I'll have to pass big arrays of floats for calculation, and I see that there is no documentation covering how to pass arguments from Java to Python using interfaces.
The problem might be the actual use of interfaces. Perhaps just declaring a function and executing it with PyModule's call
method could solve the problem
That is it.
@Test
public void testAddOneInPython() {
PyModule testFunctionsModule = PyModule.importModule("testFunctions");
PyObject result = testFunctionsModule.call("add_one", 1);
assertNotEquals(1, result.getIntValue());
assertEquals(2, result.getIntValue());
}
with testFunctions.py
:
def add_one(x)
return x + 1
works.
I wonder how I could do the same with interfaces.
hacky workaround: a_int = int("%s" % a)
correct way:
interface Calculator {
void initialise();
int calc(Integer val, Integer val2);
}
Hi, first, thanks for the great project.
I'm trying to call a python script from Java. I have setup everything in Java and can call basic methods in python with no issue. However I'm having a problem trying to do basic arithmetic. If I try to add two python values, it works fine, but when I try to add values passed in from java I get this error
It seems that python doesn't like the integers being passed across.
The python script looks like this
And I'm calling it via a proxy class
like so
I was wondering if i am doing something wrong, or if there is an issue here?
thanks
Steve