Skip to content

Commit 000a501

Browse files
committed
support base argument to math.log
1 parent 400d457 commit 000a501

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/MathModuleBuiltins.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -872,19 +872,24 @@ public double sin(double value) {
872872
}
873873
}
874874

875-
@Builtin(name = "log", fixedNumOfArguments = 1)
875+
@Builtin(name = "log", minNumOfArguments = 1, maxNumOfArguments = 2)
876876
@GenerateNodeFactory
877877
public abstract static class LogNode extends PythonBuiltinNode {
878878

879879
@Specialization
880-
public double log(int value) {
880+
public double log(int value, @SuppressWarnings("unused") PNone novalue) {
881881
return Math.log(value);
882882
}
883883

884884
@Specialization
885-
public double log(double value) {
885+
public double log(double value, @SuppressWarnings("unused") PNone novalue) {
886886
return Math.log(value);
887887
}
888+
889+
@Specialization
890+
public double log(int value, int base) {
891+
return Math.log(value) / Math.log(base);
892+
}
888893
}
889894

890895
@Builtin(name = "fabs", fixedNumOfArguments = 1)

0 commit comments

Comments
 (0)