Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

numpy.bool_ does not automatically convert to java.lang.Boolean #563

Open
CHanzyLazer opened this issue Sep 20, 2024 · 1 comment
Open
Labels

Comments

@CHanzyLazer
Copy link

Describe the bug
numpy.bool_ does not automatically convert to java.lang.Boolean.

To Reproduce

try (SharedInterpreter inter = new SharedInterpreter()) {
    inter.exec("import numpy as np");
    Object pyBool = inter.getValue("True");
    Object npyBool = inter.getValue("np.True_");
    System.out.println(pyBool.getClass());
    System.out.println(npyBool.getClass());
}

Output:

class java.lang.Boolean
class jep.python.PyObject

Expected behavior

Output:

class java.lang.Boolean
class java.lang.Boolean
@ndjensen
Copy link
Member

Thank you for reporting this and providing an easily reproducible test case. A workaround is to cast it to a bool in Python, like

Object npyBool = interp.getValue("bool(numpy.True_)").

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants