-
Notifications
You must be signed in to change notification settings - Fork 139
Closed
Description
Steps to reproduce:
Create Pandas.java
File
import java.io.File;
import org.graalvm.polyglot.Context;
class Pandas {
public static void main(String... args) throws Exception {
var pwd = System.getProperty("user.dir");
var exe = new File(pwd + "/pandaspy/bin/graalpy");
if (!exe.exists()) {
throw new Exception("Cannot find " + exe);
}
var ctx = Context.newBuilder()
.option("python.Executable", exe.getAbsolutePath())
.allowAllAccess(true)
.build();
var df = ctx.eval("python", """
import site
import pandas as pd
df = pd.DataFrame(data={'col1': [1, 2], 'col2': [3, 4]})
print(df)
df
""");
System.out.println("Size: " + df.getArraySize());
System.out.println("At 0: " + df.getArrayElement(0));
}
}
$ /graalvm-community-openjdk-17.0.7+7.1/bin/graalpy -m venv pandaspy
$ ./pandaspy/bin/graalpy -m pip install pandas
Successfully installed numpy-1.23.5 pandas-1.5.2 python-dateutil-2.8.2 pytz-2022.2.1 six-1.16.0
$ /graalvm-community-openjdk-17.0.7+7.1/bin/java Pandas.java
col1 col2
0 1 3
1 2 4
Size: 2
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Invalid array index 0 for array ' col1 col2
0 1 3
1 2 4'(language: Python, type: DataFrame).
at org.graalvm.truffle/com.oracle.truffle.polyglot.PolyglotEngineException.arrayIndexOutOfBounds(PolyglotEngineException.java:159)
at org.graalvm.truffle/com.oracle.truffle.polyglot.PolyglotValueDispatch.invalidArrayIndex(PolyglotValueDispatch.java:1390)
at org.graalvm.truffle/com.oracle.truffle.polyglot.PolyglotValueDispatch$InteropValue$GetArrayElementNode.doCached(PolyglotValueDispatch.java:3396)
at org.graalvm.truffle/com.oracle.truffle.polyglot.PolyglotValueDispatchFactory$InteropValueFactory$GetArrayElementNodeGen.executeAndSpecialize(PolyglotValueDispatchFactory.java:2922)
at org.graalvm.truffle/com.oracle.truffle.polyglot.PolyglotValueDispatchFactory$InteropValueFactory$GetArrayElementNodeGen.executeImpl(PolyglotValueDispatchFactory.java:2870)
at org.graalvm.truffle/com.oracle.truffle.polyglot.HostToGuestRootNode.execute(HostToGuestRootNode.java:124)
at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.executeRootNode(OptimizedCallTarget.java:718)
at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.profiledPERoot(OptimizedCallTarget.java:641)
at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.callBoundary(OptimizedCallTarget.java:574)
at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.doInvoke(OptimizedCallTarget.java:558)
at jdk.internal.vm.compiler/org.graalvm.compiler.truffle.runtime.GraalRuntimeSupport.callProfiled(GraalRuntimeSupport.java:255)
at org.graalvm.truffle/com.oracle.truffle.polyglot.PolyglotValueDispatch$InteropValue.getArrayElement(PolyglotValueDispatch.java:2200)
at org.graalvm.sdk/org.graalvm.polyglot.Value.getArrayElement(Value.java:335)
at Pandas.main(Pandas.java:28)
Suppressed: Attached Guest Language Frames (1)
the Panda array can be printed in Python, it is recognized as an array, but accessing its elements doesn't work yielding unexpected exceptions.
Metadata
Metadata
Assignees
Labels
No labels