redundant-log-base (FURB163)
Added in 0.5.0 · Related issues · View source
Derived from the refurb linter.
Fix is sometimes available.
What it does
Checks for math.log calls with a redundant base.
Why is this bad?
The default base of math.log is e, so specifying it explicitly is
redundant.
Instead of passing 2 or 10 as the base, use math.log2 or math.log10
respectively, as these dedicated variants are typically more accurate
than math.log.
Example
Use instead:
Fix safety
This fix is marked unsafe when the argument is a starred expression, as this changes
the call semantics and may raise runtime errors. It is also unsafe if comments are
present within the call, as they will be removed. Additionally, math.log(x, base)
and math.log2(x) / math.log10(x) may differ due to floating-point rounding, so
the fix is also unsafe when making this transformation.