Clojure:无法从java类导入特定的方法



可能链接到不能从Clojure调用特定的java方法

使用smile包,我已经升级到3.0.0并且无法调用一些方法。我的Leiningen项目。clj具有以下导入[com.github.haifengl/smile-core "3.0.0"]

现在在REPL中:


(import smile.math.MathEx)
(MathEx/log2 5.)
=> 2.321928094887362
(MathEx/pow2 5.)
Syntax error (IllegalArgumentException) compiling . at (C:UsersAAlmosniAppDataLocalTemp1form-init13649993705313983821.clj:1:1).
No matching method pow2 found taking 1 args for class smile.math.MathEx
(MathEx/sigmoid 5.)
Syntax error (IllegalArgumentException) compiling . at (C:UsersAAlmosniAppDataLocalTemp1form-init13649993705313983821.clj:1:1).
No matching method sigmoid found taking 1 args for class smile.math.MathEx
(MathEx/isPower2 32)
=> true

这让我很困惑——有些方法工作得很好,有些不行。下面是MathEx.class的摘录:

public static double log2(double x) {
return Math.log(x) / LOG2;
}
public static double log(double x) {
double y = -690.7755D;
if (x > 1.0E-300D) {
y = Math.log(x);
}
return y;
}
public static double log1pe(double x) {
double y = x;
if (x <= 15.0D) {
y = Math.log1p(Math.exp(x));
}
return y;
}
public static boolean isInt(float x) {
return x == (float)Math.floor((double)x) && !Float.isInfinite(x);
}
public static boolean isInt(double x) {
return x == Math.floor(x) && !Double.isInfinite(x);
}
public static boolean equals(double a, double b) {
if (a == b) {
return true;
} else {
double absa = Math.abs(a);
double absb = Math.abs(b);
return Math.abs(a - b) <= Math.min(absa, absb) * 2.220446049250313E-16D;
}
}
public static double sigmoid(double x) {
x = Math.max(-36.0D, Math.min(x, 36.0D));
return 1.0D / (1.0D + Math.exp(-x));
}
public static double pow2(double x) {
return x * x;
}
public static boolean isPower2(int x) {
return x > 0 && (x & x - 1) == 0;
}

知道是什么原因导致导入失败吗?

谢谢,

正如Juraj所暗示的,这是一个依赖冲突——我也在我的项目中使用tech.ml.dataset,版本6,它使用的是smile的旧版本。将tech.ml.dataset移动到版本7,该版本默认不包含smile,从而对问题进行了排序。

谢谢!

最新更新