Replace uses of np.log on scalers with math.log
This commit is contained in:
parent
b01e0e0895
commit
85c726e49a
@ -71,7 +71,7 @@ def siScale(x, minVal=1e-25, allowUnicode=True):
|
||||
m = 0
|
||||
x = 0
|
||||
else:
|
||||
m = int(np.clip(np.floor(np.log(abs(x))/np.log(1000)), -9.0, 9.0))
|
||||
m = int(clip_scalar(math.floor(math.log(abs(x))/math.log(1000)), -9.0, 9.0))
|
||||
|
||||
if m == 0:
|
||||
pref = ''
|
||||
|
@ -4,6 +4,7 @@ from ..python2_3 import asUnicode
|
||||
import numpy as np
|
||||
from ..Point import Point
|
||||
from .. import debug as debug
|
||||
from math import ceil, floor, log, log10
|
||||
import sys
|
||||
import weakref
|
||||
from .. import functions as fn
|
||||
@ -680,13 +681,13 @@ class AxisItem(GraphicsWidget):
|
||||
return []
|
||||
|
||||
## decide optimal minor tick spacing in pixels (this is just aesthetics)
|
||||
optimalTickCount = max(2., np.log(size))
|
||||
optimalTickCount = max(2., log(size))
|
||||
|
||||
## optimal minor tick spacing
|
||||
optimalSpacing = dif / optimalTickCount
|
||||
|
||||
## the largest power-of-10 spacing which is smaller than optimal
|
||||
p10unit = 10 ** np.floor(np.log10(optimalSpacing))
|
||||
p10unit = 10 ** floor(log10(optimalSpacing))
|
||||
|
||||
## Determine major/minor tick spacings which flank the optimal spacing.
|
||||
intervals = np.array([1., 2., 10., 20., 100.]) * p10unit
|
||||
@ -758,7 +759,7 @@ class AxisItem(GraphicsWidget):
|
||||
spacing, offset = tickLevels[i]
|
||||
|
||||
## determine starting tick
|
||||
start = (np.ceil((minVal-offset) / spacing) * spacing) + offset
|
||||
start = (ceil((minVal-offset) / spacing) * spacing) + offset
|
||||
|
||||
## determine number of ticks
|
||||
num = int((maxVal-start) / spacing) + 1
|
||||
@ -795,8 +796,8 @@ class AxisItem(GraphicsWidget):
|
||||
ticks.append((spacing, t))
|
||||
|
||||
if len(ticks) < 3:
|
||||
v1 = int(np.floor(minVal))
|
||||
v2 = int(np.ceil(maxVal))
|
||||
v1 = int(floor(minVal))
|
||||
v2 = int(ceil(maxVal))
|
||||
#major = list(range(v1+1, v2))
|
||||
|
||||
minor = []
|
||||
@ -822,7 +823,7 @@ class AxisItem(GraphicsWidget):
|
||||
if self.logMode:
|
||||
return self.logTickStrings(values, scale, spacing)
|
||||
|
||||
places = max(0, np.ceil(-np.log10(spacing*scale)))
|
||||
places = max(0, ceil(-log10(spacing*scale)))
|
||||
strings = []
|
||||
for v in values:
|
||||
vs = v * scale
|
||||
@ -969,7 +970,7 @@ class AxisItem(GraphicsWidget):
|
||||
if lineAlpha is None:
|
||||
lineAlpha = 255 / (i+1)
|
||||
if self.grid is not False:
|
||||
lineAlpha *= self.grid/255. * np.clip((0.05 * lengthInPixels / (len(ticks)+1)), 0., 1.)
|
||||
lineAlpha *= self.grid/255. * fn.clip_scalar((0.05 * lengthInPixels / (len(ticks)+1)), 0., 1.)
|
||||
elif isinstance(lineAlpha, float):
|
||||
lineAlpha *= 255
|
||||
lineAlpha = max(0, int(round(lineAlpha)))
|
||||
|
@ -126,8 +126,7 @@ class GridItem(UIGraphicsItem):
|
||||
for i in range(self.grid_depth - 1, -1, -1):
|
||||
dist = br-ul
|
||||
nlTarget = 10.**i
|
||||
|
||||
d = 10. ** np.floor(np.log10(abs(dist/nlTarget))+0.5)
|
||||
d = 10. ** np.floor(np.log10(np.abs(dist/nlTarget))+0.5)
|
||||
for ax in range(0,2):
|
||||
ts = self.opts['tickSpacing'][ax]
|
||||
try:
|
||||
@ -141,11 +140,6 @@ class GridItem(UIGraphicsItem):
|
||||
br1 = np.ceil(br / d) * d
|
||||
dist = br1-ul1
|
||||
nl = (dist / d) + 0.5
|
||||
#print "level", i
|
||||
#print " dim", dim
|
||||
#print " dist", dist
|
||||
#print " d", d
|
||||
#print " nl", nl
|
||||
for ax in range(0,2): ## Draw grid for both axes
|
||||
if i >= len(self.opts['tickSpacing'][ax]):
|
||||
continue
|
||||
|
@ -13,6 +13,7 @@ Widget used for displaying 2D or 3D data. Features:
|
||||
- Image normalization through a variety of methods
|
||||
"""
|
||||
import os, sys
|
||||
from math import log10
|
||||
import numpy as np
|
||||
|
||||
from ..Qt import QtCore, QtGui, QT_LIB
|
||||
@ -807,7 +808,7 @@ class ImageView(QtGui.QWidget):
|
||||
img = self.getProcessedImage()
|
||||
if self.hasTimeAxis():
|
||||
base, ext = os.path.splitext(fileName)
|
||||
fmt = "%%s%%0%dd%%s" % int(np.log10(img.shape[0])+1)
|
||||
fmt = "%%s%%0%dd%%s" % int(log10(img.shape[0])+1)
|
||||
for i in range(img.shape[0]):
|
||||
self.imageItem.setImage(img[i], autoLevels=False)
|
||||
self.imageItem.save(fmt % (base, i, ext))
|
||||
|
@ -1,6 +1,7 @@
|
||||
from collections import OrderedDict
|
||||
import numpy as np
|
||||
import copy
|
||||
from math import log2
|
||||
|
||||
|
||||
class SystemSolver(object):
|
||||
@ -409,7 +410,7 @@ if __name__ == '__main__':
|
||||
fl = self.flash
|
||||
|
||||
bal = (4.0 / ap) * (sh / (1./60.)) * (iso / 100.) * (2 ** light)
|
||||
return np.log2(bal)
|
||||
return log2(bal)
|
||||
|
||||
camera = Camera()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user