so many pep8 fixes

(cherry picked from commit bee125d)
This commit is contained in:
a-tal
2016-12-03 17:04:12 -08:00
committed by Ebag333
parent 510492e5e9
commit d3b6bc1c93
133 changed files with 3371 additions and 3319 deletions

View File

@@ -1,83 +1,98 @@
import math
def OUT_CIRC (t, b, c, d):
t=float(t)
b=float(b)
c=float(c)
d=float(d)
t = t/d -1
return c * math.sqrt(1 - t*t) + b;
def OUT_CIRC(t, b, c, d):
t = float(t)
b = float(b)
c = float(c)
d = float(d)
t = t / d - 1
return c * math.sqrt(1 - t * t) + b
def OUT_QUART(t, b, c, d):
t=float(t)
b=float(b)
c=float(c)
d=float(d)
t = t/d -1
return -c * ((t)*t*t*t - 1) + b;
t = float(t)
b = float(b)
c = float(c)
d = float(d)
t = t / d - 1
return -c * (t * t * t * t - 1) + b
def INOUT_CIRC(t, b, c, d):
t=float(t)
b=float(b)
c=float(c)
d=float(d)
t = float(t)
b = float(b)
c = float(c)
d = float(d)
t1 = t / (d / 2)
if ((t / (d/2)) < 1):
return -c/2 * (math.sqrt(1 - (t/(d/2))**2) - 1) + b
return c/2 * (math.sqrt(1 - (t1-2)**2) + 1) + b;
def IN_CUBIC (t, b, c, d):
t=float(t)
b=float(b)
c=float(c)
d=float(d)
t = t/d
return c*t*t*t + b
def OUT_QUAD (t, b, c, d):
t=float(t)
b=float(b)
c=float(c)
d=float(d)
t/=d
return -c *(t)*(t-2) + b
def OUT_BOUNCE (t, b, c, d):
t=float(t)
b=float(b)
c=float(c)
d=float(d)
t/=d
if ((t) < (1/2.75)):
return c*(7.5625*t*t) + b
if (t / (d / 2)) < 1:
return -c / 2 * (math.sqrt(1 - (t / (d / 2)) ** 2) - 1) + b
else:
if (t < (2/2.75)):
t-=(1.5/2.75)
return c*(7.5625*t*t + .75) + b
else:
if (t < (2.5/2.75)):
t-=(2.25/2.75)
return c*(7.5625*(t)*t + .9375) + b
else:
t-=(2.625/2.75)
return c*(7.5625*(t)*t + .984375) + b
return c / 2 * (math.sqrt(1 - (t1 - 2) ** 2) + 1) + b
def IN_CUBIC(t, b, c, d):
t = float(t)
b = float(b)
c = float(c)
d = float(d)
t = t / d
return c * t * t * t + b
def OUT_QUAD(t, b, c, d):
t = float(t)
b = float(b)
c = float(c)
d = float(d)
t /= d
return -c * t * (t - 2) + b
def OUT_BOUNCE(t, b, c, d):
t = float(t)
b = float(b)
c = float(c)
d = float(d)
t /= d
if t < (1 / 2.75):
return c * (7.5625 * t * t) + b
elif t < (2 / 2.75):
t -= (1.5 / 2.75)
return c * (7.5625 * t * t + .75) + b
elif t < (2.5 / 2.75):
t -= (2.25 / 2.75)
return c * (7.5625 * t * t + .9375) + b
else:
t -= (2.625 / 2.75)
return c * (7.5625 * t * t + .984375) + b
def INOUT_EXP(t, b, c, d):
t=float(t)
b=float(b)
c=float(c)
d=float(d)
t1 = t / (d/2)
if t==0:
return b
if t==d:
return b+c
if (t1) < 1:
return c/2 * math.pow(2, 10 * (t1 - 1)) + b - c * 0.0005
return c/2 * 1.0005 * (-math.pow(2, -10 * (t1-1)) + 2) + b
t = float(t)
b = float(b)
c = float(c)
d = float(d)
t1 = t / (d / 2)
if t == 0:
return b
elif t == d:
return b + c
elif t1 < 1:
return c / 2 * math.pow(2, 10 * (t1 - 1)) + b - c * 0.0005
else:
return c / 2 * 1.0005 * (-math.pow(2, -10 * (t1 - 1)) + 2) + b

View File

@@ -1,9 +1,10 @@
import wx
import gui.utils.colorUtils as colorUtils
class LoadAnimation(wx.Window):
def __init__ (self, parent, id = wx.ID_ANY, label = "", pos = wx.DefaultPosition, size = wx.DefaultSize, style = 0):
wx.Window.__init__(self, parent, id, pos = pos, size = size, style = style)
def __init__(self, parent, id=wx.ID_ANY, label="", pos=wx.DefaultPosition, size=wx.DefaultSize, style=0):
wx.Window.__init__(self, parent, id, pos=pos, size=size, style=style)
self.label = label
@@ -16,7 +17,6 @@ class LoadAnimation(wx.Window):
self.bars = 10
self.padding = 2
self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)
self.Bind(wx.EVT_TIMER, self.OnTimer)
self.Bind(wx.EVT_PAINT, self.OnPaint)
@@ -64,14 +64,14 @@ class LoadAnimation(wx.Window):
x = self.padding
for bar in xrange(self.bars):
for bar in range(self.bars):
if bar != self.animCount:
dc.SetPen(wx.Pen(shadeColor))
dc.SetBrush(wx.Brush(shadeColor))
bh = barHeight
y = self.padding
else:
barColor = colorUtils.GetSuitableColor(barColor,float(self.animCount/2)/10)
barColor = colorUtils.GetSuitableColor(barColor, float(self.animCount / 2) / 10)
dc.SetPen(wx.Pen(barColor))
dc.SetBrush(wx.Brush(barColor))
bh = rect.height
@@ -82,17 +82,17 @@ class LoadAnimation(wx.Window):
textColor = wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOWTEXT)
dc.SetTextForeground(textColor)
dc.DrawLabel(self.label,rect,wx.ALIGN_CENTER)
dc.DrawLabel(self.label, rect, wx.ALIGN_CENTER)
class WaitDialog(wx.Dialog):
def __init__(self, parent, title = "Processing"):
wx.Dialog.__init__ (self, parent, id=wx.ID_ANY, title = title, size=(300,30),
def __init__(self, parent, title="Processing"):
wx.Dialog.__init__(self, parent, id=wx.ID_ANY, title=title, size=(300, 30),
style=wx.NO_BORDER)
mainSizer = wx.BoxSizer( wx.HORIZONTAL )
mainSizer = wx.BoxSizer(wx.HORIZONTAL)
self.progress = LoadAnimation(self,label = title, size=(300,30))
mainSizer.Add( self.progress, 1, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 0 )
self.SetSizer( mainSizer )
self.progress = LoadAnimation(self, label=title, size=(300, 30))
mainSizer.Add(self.progress, 1, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 0)
self.SetSizer(mainSizer)
self.Layout()
self.CenterOnParent()

View File

@@ -1,5 +1,6 @@
import wx
def toClipboard(text):
clip = wx.TheClipboard
clip.Open()
@@ -7,6 +8,7 @@ def toClipboard(text):
clip.SetData(data)
clip.Close()
def fromClipboard():
clip = wx.TheClipboard
clip.Open()
@@ -16,4 +18,4 @@ def fromClipboard():
return data.GetText()
else:
clip.Close()
return None
return None

View File

@@ -1,25 +1,26 @@
import wx
import math
#Brightens a color (wx.Colour), factor = [0,1]
def BrightenColor(color, factor):
# Brightens a color (wx.Colour), factor = [0,1]
r,g,b = color
r, g, b = color
a = color.Alpha()
factor = min(max(factor, 0), 1)
r+=(255-r)*factor
b+=(255-b)*factor
g+=(255-g)*factor
r += (255 - r) * factor
b += (255 - b) * factor
g += (255 - g) * factor
return wx.Colour(r,g,b,a)
return wx.Colour(r, g, b, a)
#Darkens a color (wx.Colour), factor = [0, 1]
def DarkenColor(color, factor):
bkR ,bkG , bkB = color
# Darkens a color (wx.Colour), factor = [0, 1]
bkR, bkG, bkB = color
alpha = color.Alpha()
@@ -30,50 +31,50 @@ def DarkenColor(color, factor):
g = float(bkG * factor)
b = float(bkB * factor)
r = min(max(r,0),255)
b = min(max(b,0),255)
g = min(max(g,0),255)
r = min(max(r, 0), 255)
b = min(max(b, 0), 255)
g = min(max(g, 0), 255)
return wx.Colour(r, g, b, alpha)
#Calculates the brightness of a color, different options
def GetBrightnessO1(color):
r,g,b = color
return (0.299*r + 0.587*g + 0.114*b)
# Calculates the brightness of a color, different options
r, g, b = color
return (0.299 * r + 0.587 * g + 0.114 * b)
def GetBrightnessO2(color):
r,g,b = color
return math.sqrt( 0.241 * r * r + 0.691 * g * g + 0.068 * b * b )
r, g, b = color
return math.sqrt(0.241 * r * r + 0.691 * g * g + 0.068 * b * b)
#Calculates a suitable color based on original color (wx.Colour), its brightness, a factor=[0,1] (darken/brighten by factor depending on calculated brightness)
def GetSuitableColor(color, factor):
# Calculates a suitable color based on original color (wx.Colour), its brightness, a factor=[0,1] (darken/brighten by factor depending on calculated brightness)
brightness = GetBrightnessO1(color)
if brightness >129:
if brightness > 129:
return DarkenColor(color, factor)
else:
return BrightenColor(color, factor)
#Calculates the color between a given start and end colors, delta = [0,1]
#Colors are wx.Colour objects
def CalculateTransitionColor(startColor, endColor, delta):
sR,sG,sB = startColor
eR,eG,eB = endColor
"""
Calculates the color between a given start and end colors, delta = [0,1]
Colors are wx.Colour objects
"""
sR, sG, sB = startColor
eR, eG, eB = endColor
alphaS = startColor.Alpha()
alphaE = endColor.Alpha()
tR = sR + (eR - sR) * delta
tG = sG + (eG - sG) * delta
tB = sB + (eB - sB) * delta
tR = sR + (eR - sR) * delta
tG = sG + (eG - sG) * delta
tB = sB + (eB - sB) * delta
return wx.Colour(tR, tG, tB, (alphaS + alphaE)/2)
return wx.Colour(tR, tG, tB, (alphaS + alphaE) / 2)

View File

@@ -237,7 +237,7 @@ class OrderedDict(dict):
'''
if isinstance(other, OrderedDict):
return len(self)==len(other) and self.items() == other.items()
return len(self) == len(other) and self.items() == other.items()
return dict.__eq__(self, other)
def __ne__(self, other):

View File

@@ -2,17 +2,17 @@ import wx
import gui.utils.colorUtils as colorUtils
def RenderGradientBar(windowColor, width, height, sFactor, eFactor, mFactor = None , fillRatio = 2):
def RenderGradientBar(windowColor, width, height, sFactor, eFactor, mFactor=None, fillRatio=2):
if sFactor == 0 and eFactor == 0 and mFactor == None:
return DrawFilledBitmap(width,height, windowColor)
if sFactor == 0 and eFactor == 0 and mFactor is None:
return DrawFilledBitmap(width, height, windowColor)
gStart = colorUtils.GetSuitableColor(windowColor, sFactor)
if mFactor:
gMid = colorUtils.GetSuitableColor(windowColor, mFactor)
else:
gMid = colorUtils.GetSuitableColor(windowColor, sFactor + (eFactor - sFactor) / 2)
gMid = colorUtils.GetSuitableColor(windowColor, sFactor + (eFactor - sFactor) / 2)
gEnd = colorUtils.GetSuitableColor(windowColor, eFactor)
@@ -20,7 +20,7 @@ def RenderGradientBar(windowColor, width, height, sFactor, eFactor, mFactor = No
def DrawFilledBitmap(width, height, color):
canvas = wx.EmptyBitmap(width,height)
canvas = wx.EmptyBitmap(width, height)
mdc = wx.MemoryDC()
mdc.SelectObject(canvas)
@@ -32,10 +32,11 @@ def DrawFilledBitmap(width, height, color):
return canvas
def DrawGradientBar(width, height, gStart, gEnd, gMid = None, fillRatio = 4):
def DrawGradientBar(width, height, gStart, gEnd, gMid=None, fillRatio=4):
# we need to have dimensions to draw
#assert width > 0 and height > 0
canvas = wx.EmptyBitmap(width,height)
# assert width > 0 and height > 0
canvas = wx.EmptyBitmap(width, height)
mdc = wx.MemoryDC()
mdc.SelectObject(canvas)
@@ -48,7 +49,7 @@ def DrawGradientBar(width, height, gStart, gEnd, gMid = None, fillRatio = 4):
mdc.GradientFillLinear(r, gStart, gMid, wx.SOUTH)
r.top = r.height
r.height = height * (fillRatio - 1)/fillRatio + (1 if height % fillRatio != 0 else 0)
r.height = height * (fillRatio - 1) / fillRatio + (1 if height % fillRatio != 0 else 0)
mdc.GradientFillLinear(r, gMid, gEnd, wx.SOUTH)
@@ -57,48 +58,51 @@ def DrawGradientBar(width, height, gStart, gEnd, gMid = None, fillRatio = 4):
return canvas
def GetPartialText(dc, text , maxWidth, defEllipsis = "..."):
ellipsis = defEllipsis
def GetPartialText(dc, text, maxWidth, defEllipsis="..."):
ellipsis = defEllipsis
base_w, h = dc.GetTextExtent(ellipsis)
lenText = len(text)
drawntext = text
w, dummy = dc.GetTextExtent(text)
while lenText > 0:
if w + base_w <= maxWidth:
break
w_c, h_c = dc.GetTextExtent(drawntext[-1])
drawntext = drawntext[0:-1]
lenText -= 1
w -= w_c
while len(ellipsis) > 0 and w + base_w > maxWidth:
ellipsis = ellipsis[0:-1]
base_w, h = dc.GetTextExtent(ellipsis)
if len(text) > lenText:
return drawntext + ellipsis
else:
return text
lenText = len(text)
drawntext = text
w, dummy = dc.GetTextExtent(text)
while lenText > 0:
if w + base_w <= maxWidth:
break
w_c, h_c = dc.GetTextExtent(drawntext[-1])
drawntext = drawntext[0:-1]
lenText -= 1
w -= w_c
while len(ellipsis) > 0 and w + base_w > maxWidth:
ellipsis = ellipsis[0:-1]
base_w, h = dc.GetTextExtent(ellipsis)
if len(text) > lenText:
return drawntext + ellipsis
else:
return text
def GetRoundBitmap( w, h, r ):
maskColor = wx.Color(0,0,0)
shownColor = wx.Color(5,5,5)
b = wx.EmptyBitmap(w,h)
def GetRoundBitmap(w, h, r):
maskColor = wx.Color(0, 0, 0)
shownColor = wx.Color(5, 5, 5)
b = wx.EmptyBitmap(w, h)
dc = wx.MemoryDC(b)
dc.SetBrush(wx.Brush(maskColor))
dc.DrawRectangle(0,0,w,h)
dc.DrawRectangle(0, 0, w, h)
dc.SetBrush(wx.Brush(shownColor))
dc.SetPen(wx.Pen(shownColor))
dc.DrawRoundedRectangle(0,0,w,h,r)
dc.DrawRoundedRectangle(0, 0, w, h, r)
dc.SelectObject(wx.NullBitmap)
b.SetMaskColour(maskColor)
return b
def GetRoundShape( w, h, r ):
return wx.RegionFromBitmap( GetRoundBitmap(w,h,r) )
def GetRoundShape(w, h, r):
return wx.RegionFromBitmap(GetRoundBitmap(w, h, r))
def CreateDropShadowBitmap(bitmap, opacity):
img = wx.ImageFromBitmap(bitmap)

View File

@@ -5,8 +5,10 @@ from service.settings import HTMLExportSettings
from service.fit import Fit
from service.market import Market
class exportHtml():
_instance = None
@classmethod
def getInstance(cls):
if cls._instance is None:
@@ -25,6 +27,7 @@ class exportHtml():
self.thread = exportHtmlThread(callback)
self.thread.start()
class exportHtmlThread(threading.Thread):
def __init__(self, callback=False):
@@ -45,35 +48,30 @@ class exportHtmlThread(threading.Thread):
sFit = Fit.getInstance()
settings = HTMLExportSettings.getInstance()
timestamp = time.localtime(time.time())
localDate = "%d/%02d/%02d %02d:%02d" % (timestamp[0], timestamp[1], timestamp[2], timestamp[3], timestamp[4])
minimal = settings.getMinimalEnabled();
minimal = settings.getMinimalEnabled()
dnaUrl = "https://o.smium.org/loadout/dna/"
if minimal:
HTML = self.generateMinimalHTML(sMkt,sFit, dnaUrl)
HTML = self.generateMinimalHTML(sMkt, sFit, dnaUrl)
else:
HTML = self.generateFullHTML(sMkt,sFit, dnaUrl)
HTML = self.generateFullHTML(sMkt, sFit, dnaUrl)
try:
FILE = open(settings.getPath(), "w")
FILE.write(HTML.encode('utf-8'))
FILE.close()
except IOError:
print "Failed to write to " + settings.getPath()
print("Failed to write to " + settings.getPath())
pass
if self.callback:
wx.CallAfter(self.callback, -1)
def generateFullHTML(self,sMkt,sFit,dnaUrl):
def generateFullHTML(self, sMkt, sFit, dnaUrl):
""" Generate the complete HTML with styling and javascript """
timestamp = time.localtime(time.time())
localDate = "%d/%02d/%02d %02d:%02d" % (timestamp[0], timestamp[1], timestamp[2], timestamp[3], timestamp[4])
HTML = """
<!DOCTYPE html>
<html>
@@ -152,7 +150,7 @@ class exportHtmlThread(threading.Thread):
$('a[data-dna]').each(function( index ) {
var dna = $(this).data('dna');
if (typeof CCPEVE !== 'undefined') { // inside IGB
$(this).attr('href', 'javascript:CCPEVE.showFitting("'+dna+'");');}
$(this).attr('href', 'javascript:CCPEVE.showFitting("'+dna+'");');}
else { // outside IGB
$(this).attr('href', '%s'+dna); }
});
@@ -194,8 +192,7 @@ class exportHtmlThread(threading.Thread):
fit = fits[0]
try:
dnaFit = sFit.exportDna(fit[0])
HTMLgroup += (
' <li><a data-dna="' + dnaFit + '" target="_blank">' + ship.name + ": " + fit[1] + '</a></li>\n')
HTMLgroup += ' <li><a data-dna="' + dnaFit + '" target="_blank">' + ship.name + ": " + fit[1] + '</a></li>\n'
except:
pass
finally:
@@ -205,9 +202,10 @@ class exportHtmlThread(threading.Thread):
else:
# Ship group header
HTMLship = (
' <li data-role="collapsible" data-iconpos="right" data-shadow="false" data-corners="false">\n'
' <h2>' + ship.name + ' <span class="ui-li-count">'+str(len(fits))+'</span></h2>\n'
' <ul data-role="listview" data-shadow="false" data-inset="true" data-corners="false">\n')
' <li data-role="collapsible" data-iconpos="right" data-shadow="false" data-corners="false">\n'
' <h2>' + ship.name + ' <span class="ui-li-count">' + str(len(fits)) + '</span></h2>\n'
' <ul data-role="listview" data-shadow="false" data-inset="true" data-corners="false">\n'
)
for fit in fits:
if self.stopRunning:
@@ -227,12 +225,12 @@ class exportHtmlThread(threading.Thread):
if groupFits > 0:
# Market group header
HTML += (
' <li data-role="collapsible" data-iconpos="right" data-shadow="false" data-corners="false">\n'
' <h2>' + group.groupName + ' <span class="ui-li-count">'+str(groupFits)+'</span></h2>\n'
' <ul data-role="listview" data-shadow="false" data-inset="true" data-corners="false">\n'
+ HTMLgroup +
' </ul>\n'
' </li>')
' <li data-role="collapsible" data-iconpos="right" data-shadow="false" data-corners="false">\n'
' <h2>' + group.groupName + ' <span class="ui-li-count">' + str(groupFits) + '</span></h2>\n'
' <ul data-role="listview" data-shadow="false" data-inset="true" data-corners="false">\n' + HTMLgroup +
' </ul>\n'
' </li>'
)
HTML += """
</ul>
@@ -243,7 +241,7 @@ class exportHtmlThread(threading.Thread):
return HTML
def generateMinimalHTML(self,sMkt,sFit,dnaUrl):
def generateMinimalHTML(self, sMkt, sFit, dnaUrl):
""" Generate a minimal HTML version of the fittings, without any javascript or styling"""
categoryList = list(sMkt.getShipRoot())
categoryList.sort(key=lambda ship: ship.name)
@@ -252,7 +250,6 @@ class exportHtmlThread(threading.Thread):
HTML = ''
for group in categoryList:
# init market group string to give ships something to attach to
ships = list(sMkt.getShipList(group.ID))
ships.sort(key=lambda ship: ship.name)
@@ -265,8 +262,8 @@ class exportHtmlThread(threading.Thread):
if self.stopRunning:
return
try:
dnaFit = sFit.exportDna(fit[0])
HTML += '<a class="outOfGameBrowserLink" target="_blank" href="' + dnaUrl + dnaFit + '">'+ship.name +': '+ fit[1]+ '</a><br> \n'
dnaFit = sFit.exportDna(fit[0])
HTML += '<a class="outOfGameBrowserLink" target="_blank" href="' + dnaUrl + dnaFit + '">' + ship.name + ': ' + fit[1] + '</a><br> \n'
except:
continue
finally:

View File

@@ -5,9 +5,11 @@ different wxPython versions
import wx
if 'wxMac' in wx.PlatformInfo:
sizes = (10, 11, 12)
else:
sizes = (7, 8, 9)
SMALL, NORMAL, BIG = sizes

View File

@@ -1,5 +1,6 @@
import math
def formatAmount(val, prec=3, lowest=0, highest=0, currency=False, forceSign=False):
"""
Add suffix to value, transform value to match new suffix and round it.
@@ -34,7 +35,7 @@ def formatAmount(val, prec=3, lowest=0, highest=0, currency=False, forceSign=Fal
for key in posOrders:
# Find first suitable suffix and check if it's not above highest order
if abs(val) >= 10**key and key <= highest:
mantissa, suffix = val/float(10**key), posSuffixMap[key]
mantissa, suffix = val / float(10 ** key), posSuffixMap[key]
# Do additional step to eliminate results like 999999 => 1000k
# If we're already using our greatest order, we can't do anything useful
if posOrders.index(key) == 0:
@@ -53,7 +54,7 @@ def formatAmount(val, prec=3, lowest=0, highest=0, currency=False, forceSign=Fal
# or equal to multiplier
if roundToPrec(mantissa, prec) >= orderDiff:
# Divide mantissa and use suffix of greater order
mantissa, suffix = mantissa/orderDiff, posSuffixMap[prevKey]
mantissa, suffix = mantissa / orderDiff, posSuffixMap[prevKey]
# Otherwise consider current results as acceptable
break
# Take numbers between 0 and 1, and matching/below highest possible negative suffix
@@ -67,7 +68,7 @@ def formatAmount(val, prec=3, lowest=0, highest=0, currency=False, forceSign=Fal
nextKey = 0
# Check if mantissa with next suffix is in range [1, 1000)
if abs(val) < 10**(nextKey) and key >= lowest:
mantissa, suffix = val/float(10**key), negSuffixMap[key]
mantissa, suffix = val / float(10**key), negSuffixMap[key]
# Do additional step to eliminate results like 0.9999 => 1000m
# Check if the key we're potentially switching to is greater than our
# upper boundary
@@ -81,7 +82,7 @@ def formatAmount(val, prec=3, lowest=0, highest=0, currency=False, forceSign=Fal
if roundToPrec(mantissa, prec) >= orderDiff:
# Divide mantissa and use suffix of greater order
# Use special handling of zero key as it's not on the map
mantissa, suffix = mantissa/orderDiff, posSuffixMap[nextKey] if nextKey != 0 else ""
mantissa, suffix = mantissa / orderDiff, posSuffixMap[nextKey] if nextKey != 0 else ""
# Otherwise consider current results as acceptable
break
# Round mantissa according to our prec variable
@@ -91,6 +92,7 @@ def formatAmount(val, prec=3, lowest=0, highest=0, currency=False, forceSign=Fal
result = u"{0}{1}{2}".format(sign, mantissa, suffix)
return result
def roundToPrec(val, prec):
# We're not rounding integers anyway
# Also make sure that we do not ask to calculate logarithm of zero