首页 > 解决方案 > 使用JEP在java中运行python代码

问题描述

我正在尝试使用JEP在 java中运行这个 python 库。我使用以下代码将参数发送到 python。

NDArray<int[]> r = new NDArray<>(twf, 1, twf.length);
    NDArray<int[]> d = new NDArray<>(ndpw, 1, ndpw.length);
    jep.set("r", r);
    jep.set("d", d);
    jep.set("gamma", gamma);
    jep.set("smooth_win", smooth_win);
    jep.set("s", s);
    jep.set("n", n);

我最终得到了这个错误。

< class 'AttributeError' >: 'ImmutableDenseNDimArray' 对象没有属性 '_to_mpmath'

我搜索了原因,但一无所获。这个错误是什么意思?

编辑:

在库中,有一行代码用于SympyNDarray。我猜这个错误与那条线有关。

这是库中的行:

import sympy.functions.combinatorial.factorials as c

return -np.log(np.float(c.binomial(d, r)) * (p ** r) * (1 - p) ** (d - r))

标签: javapython

解决方案


推荐阅读