mirror of
https://github.com/littlefs-project/littlefs.git
synced 2025-12-01 12:20:02 +00:00
scripts: Renamed import math alias m -> mt
Mainly to avoid conflicts with match results m, this frees up the single letter variables m for other purposes. Choosing a two letter alias was surprisingly difficult, but mt is nice in that it somewhat matches it (for itertools) and ft (for functools).
This commit is contained in:
@ -15,7 +15,7 @@ import csv
|
||||
import io
|
||||
import itertools as it
|
||||
import logging
|
||||
import math as m
|
||||
import math as mt
|
||||
import numpy as np
|
||||
import os
|
||||
import shlex
|
||||
@ -98,7 +98,7 @@ def si(x):
|
||||
if x == 0:
|
||||
return '0'
|
||||
# figure out prefix and scale
|
||||
p = 3*int(m.log(abs(x), 10**3))
|
||||
p = 3*int(mt.log(abs(x), 10**3))
|
||||
p = min(18, max(-18, p))
|
||||
# format with 3 digits of precision
|
||||
s = '%.3f' % (abs(x) / (10.0**p))
|
||||
@ -114,7 +114,7 @@ def si2(x):
|
||||
if x == 0:
|
||||
return '0'
|
||||
# figure out prefix and scale
|
||||
p = 10*int(m.log(abs(x), 2**10))
|
||||
p = 10*int(mt.log(abs(x), 2**10))
|
||||
p = min(30, max(-30, p))
|
||||
# format with 3 digits of precision
|
||||
s = '%.3f' % (abs(x) / (2.0**p))
|
||||
@ -148,7 +148,8 @@ class AutoMultipleLocator(mpl.ticker.MultipleLocator):
|
||||
nbins = np.clip(self.axis.get_tick_space(), 1, 9)
|
||||
|
||||
# find the best power, use this as our locator's actual base
|
||||
scale = self.base ** (m.ceil(m.log((vmax-vmin) / (nbins+1), self.base)))
|
||||
scale = self.base
|
||||
** (mt.ceil(mt.log((vmax-vmin) / (nbins+1), self.base)))
|
||||
self.set_params(scale)
|
||||
|
||||
return super().__call__()
|
||||
@ -181,7 +182,7 @@ def dat(x):
|
||||
try:
|
||||
return float(x)
|
||||
# just don't allow infinity or nan
|
||||
if m.isinf(x) or m.isnan(x):
|
||||
if mt.isinf(x) or mt.isnan(x):
|
||||
raise ValueError("invalid dat %r" % x)
|
||||
except ValueError:
|
||||
pass
|
||||
@ -352,9 +353,9 @@ class Grid:
|
||||
self_i = 0
|
||||
other_i = 0
|
||||
self_xweight = (self_xweights[self_i]
|
||||
if self_i < len(self_xweights) else m.inf)
|
||||
if self_i < len(self_xweights) else mt.inf)
|
||||
other_xweight = (other_xweights[other_i]
|
||||
if other_i < len(other_xweights) else m.inf)
|
||||
if other_i < len(other_xweights) else mt.inf)
|
||||
while self_i < len(self_xweights) and other_i < len(other_xweights):
|
||||
if other_xweight - self_xweight > 0.0000001:
|
||||
new_xweights.append(self_xweight)
|
||||
@ -373,7 +374,7 @@ class Grid:
|
||||
|
||||
self_i += 1
|
||||
self_xweight = (self_xweights[self_i]
|
||||
if self_i < len(self_xweights) else m.inf)
|
||||
if self_i < len(self_xweights) else mt.inf)
|
||||
elif self_xweight - other_xweight > 0.0000001:
|
||||
new_xweights.append(other_xweight)
|
||||
self_xweight -= other_xweight
|
||||
@ -391,7 +392,7 @@ class Grid:
|
||||
|
||||
other_i += 1
|
||||
other_xweight = (other_xweights[other_i]
|
||||
if other_i < len(other_xweights) else m.inf)
|
||||
if other_i < len(other_xweights) else mt.inf)
|
||||
else:
|
||||
new_xweights.append(self_xweight)
|
||||
|
||||
@ -403,10 +404,10 @@ class Grid:
|
||||
|
||||
self_i += 1
|
||||
self_xweight = (self_xweights[self_i]
|
||||
if self_i < len(self_xweights) else m.inf)
|
||||
if self_i < len(self_xweights) else mt.inf)
|
||||
other_i += 1
|
||||
other_xweight = (other_xweights[other_i]
|
||||
if other_i < len(other_xweights) else m.inf)
|
||||
if other_i < len(other_xweights) else mt.inf)
|
||||
|
||||
# squish so ratios are preserved
|
||||
self_h = sum(self.yweights)
|
||||
@ -450,9 +451,9 @@ class Grid:
|
||||
self_i = 0
|
||||
other_i = 0
|
||||
self_yweight = (self_yweights[self_i]
|
||||
if self_i < len(self_yweights) else m.inf)
|
||||
if self_i < len(self_yweights) else mt.inf)
|
||||
other_yweight = (other_yweights[other_i]
|
||||
if other_i < len(other_yweights) else m.inf)
|
||||
if other_i < len(other_yweights) else mt.inf)
|
||||
while self_i < len(self_yweights) and other_i < len(other_yweights):
|
||||
if other_yweight - self_yweight > 0.0000001:
|
||||
new_yweights.append(self_yweight)
|
||||
@ -471,7 +472,7 @@ class Grid:
|
||||
|
||||
self_i += 1
|
||||
self_yweight = (self_yweights[self_i]
|
||||
if self_i < len(self_yweights) else m.inf)
|
||||
if self_i < len(self_yweights) else mt.inf)
|
||||
elif self_yweight - other_yweight > 0.0000001:
|
||||
new_yweights.append(other_yweight)
|
||||
self_yweight -= other_yweight
|
||||
@ -489,7 +490,7 @@ class Grid:
|
||||
|
||||
other_i += 1
|
||||
other_yweight = (other_yweights[other_i]
|
||||
if other_i < len(other_yweights) else m.inf)
|
||||
if other_i < len(other_yweights) else mt.inf)
|
||||
else:
|
||||
new_yweights.append(self_yweight)
|
||||
|
||||
@ -501,10 +502,10 @@ class Grid:
|
||||
|
||||
self_i += 1
|
||||
self_yweight = (self_yweights[self_i]
|
||||
if self_i < len(self_yweights) else m.inf)
|
||||
if self_i < len(self_yweights) else mt.inf)
|
||||
other_i += 1
|
||||
other_yweight = (other_yweights[other_i]
|
||||
if other_i < len(other_yweights) else m.inf)
|
||||
if other_i < len(other_yweights) else mt.inf)
|
||||
|
||||
# squish so ratios are preserved
|
||||
self_w = sum(self.xweights)
|
||||
@ -978,7 +979,7 @@ def main(csv_paths, output, *,
|
||||
# try different column counts until we fit in the axes
|
||||
for ncol in reversed(range(1, len(legend)+1)):
|
||||
# permute the labels, mpl wants to order these column first
|
||||
nrow = m.ceil(len(legend)/ncol)
|
||||
nrow = mt.ceil(len(legend)/ncol)
|
||||
legend_ = ncol*nrow*[None]
|
||||
for x in range(ncol):
|
||||
for y in range(nrow):
|
||||
@ -1012,7 +1013,7 @@ def main(csv_paths, output, *,
|
||||
# try different column counts until we fit in the axes
|
||||
for ncol in reversed(range(1, len(legend)+1)):
|
||||
# permute the labels, mpl wants to order these column first
|
||||
nrow = m.ceil(len(legend)/ncol)
|
||||
nrow = mt.ceil(len(legend)/ncol)
|
||||
legend_ = ncol*nrow*[None]
|
||||
for x in range(ncol):
|
||||
for y in range(nrow):
|
||||
|
||||
Reference in New Issue
Block a user