Skip to content

Commit dbaa043

Browse files
committed
Small style corrections.
1 parent 70308e6 commit dbaa043

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

graalpython/com.oracle.graal.python.test/src/tests/test_math.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ def testLog(self):
242242
self.ftest('log(32,2)', math.log(32,2), 5)
243243
self.ftest('log(10**40, 10)', math.log(10**40, 10), 40)
244244
self.ftest('log(10**40, 10**20)', math.log(10**40, 10**20), 2)
245+
# TODO uncomment when GR-10346 will be fixed
245246
#self.ftest('log(10**1000)', math.log(10**1000), 2302.5850929940457)
246247
self.assertRaises(ValueError, math.log, -1.5)
247248
self.assertRaises(ValueError, math.log, -10**1000)

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1189,9 +1189,8 @@ private double executeRecursiveLogNode(Object value, Object base) {
11891189

11901190
private static double logBigInteger(BigInteger val) {
11911191
int blex = val.bitLength() - 1022; // any value in 60..1023 is ok
1192-
if (blex > 0)
1193-
val = val.shiftRight(blex);
1194-
double res = Math.log(val.doubleValue());
1192+
BigInteger value = blex > 0 ? val.shiftRight(blex) : val;
1193+
double res = Math.log(value.doubleValue());
11951194
return blex > 0 ? res + blex * LOG2 : res;
11961195
}
11971196

@@ -1212,7 +1211,7 @@ private double countBase(BigInteger base, ConditionProfile divByZero) {
12121211
}
12131212

12141213
@Specialization
1215-
public double log(long value, @SuppressWarnings("unused") PNone novalue,
1214+
public double log(long value, PNone novalue,
12161215
@Cached("createBinaryProfile()") ConditionProfile doNotFit) {
12171216
return logDN(value, novalue, doNotFit);
12181217
}
@@ -1316,7 +1315,7 @@ public double logPIPI(PInt value, PInt base,
13161315
}
13171316

13181317
@Specialization(guards = "!isNumber(value)")
1319-
public double logO(Object value, @SuppressWarnings("unused") PNone novalue,
1318+
public double logO(Object value, PNone novalue,
13201319
@Cached("createBinaryProfile()") ConditionProfile notNumber) {
13211320
Object result = getRealNumber(value, getValueDispatchNode(), notNumber);
13221321
return executeRecursiveLogNode(result, novalue);
@@ -1359,7 +1358,7 @@ private void raiseMathError(ConditionProfile doNotFit, boolean con) {
13591358

13601359
private Object getRealNumber(Object object, LookupAndCallUnaryNode dispatchNode, ConditionProfile isNotRealNumber) {
13611360
Object result = dispatchNode.executeObject(object);
1362-
if (result == PNone.NO_VALUE) {
1361+
if (isNotRealNumber.profile(result == PNone.NO_VALUE)) {
13631362
throw raise(TypeError, "must be real number, not %p", object);
13641363
}
13651364
return result;

0 commit comments

Comments
 (0)