Skip to content

Commit ee9f306

Browse files
committed
Major code cleaning/formatting
1 parent 26be38a commit ee9f306

35 files changed

Lines changed: 2969 additions & 2344 deletions

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
each tick type (minor, medium, major) -- this feature is used with the new
1414
flatStyle option
1515
- Fixed obvious errors (+ poor implementations) in untested code parts
16+
- Major code cleaning and formatting
1617

1718

1819
### Version 0.6.2 ###

qwt/_math.py

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,64 +5,74 @@
55
# Copyright (c) 2015 Pierre Raybaut, for the Python translation/optimization
66
# (see LICENSE file for more details)
77

8+
from __future__ import division
9+
810
from .qt.QtCore import qFuzzyCompare
911

10-
import numpy as np
12+
import math
1113

1214

1315
def qwtFuzzyCompare(value1, value2, intervalSize):
14-
eps = abs(1.e-6*intervalSize)
16+
eps = abs(1.0e-6 * intervalSize)
1517
if value2 - value1 > eps:
1618
return -1
1719
elif value1 - value2 > eps:
1820
return 1
1921
else:
2022
return 0
2123

24+
2225
def qwtFuzzyGreaterOrEqual(d1, d2):
2326
return (d1 >= d2) or qFuzzyCompare(d1, d2)
2427

28+
2529
def qwtFuzzyLessOrEqual(d1, d2):
2630
return (d1 <= d2) or qFuzzyCompare(d1, d2)
2731

32+
2833
def qwtSign(x):
29-
if x > 0.:
34+
if x > 0.0:
3035
return 1
31-
elif x < 0.:
36+
elif x < 0.0:
3237
return -1
3338
else:
3439
return 0
3540

41+
3642
def qwtSqr(x):
37-
return x**2
43+
return x ** 2
44+
3845

3946
def qwtFastAtan(x):
40-
if x < -1.:
41-
return -.5*np.pi - x/(x**2 + .28)
42-
elif x > 1.:
43-
return .5*np.pi - x/(x**2 + .28)
47+
if x < -1.0:
48+
return -0.5 * math.pi - x / (x ** 2 + 0.28)
49+
elif x > 1.0:
50+
return 0.5 * math.pi - x / (x ** 2 + 0.28)
4451
else:
45-
return x/(1. + x**2*.28)
52+
return x / (1.0 + x ** 2 * 0.28)
53+
4654

4755
def qwtFastAtan2(y, x):
4856
if x > 0:
49-
return qwtFastAtan(y/x)
57+
return qwtFastAtan(y / x)
5058
elif x < 0:
51-
d = qwtFastAtan(y/x)
59+
d = qwtFastAtan(y / x)
5260
if y >= 0:
53-
return d + np.pi
61+
return d + math.pi
5462
else:
55-
return d - np.pi
56-
elif y < 0.:
57-
return -.5*np.pi
58-
elif y > 0.:
59-
return .5*np.pi
63+
return d - math.pi
64+
elif y < 0.0:
65+
return -0.5 * math.pi
66+
elif y > 0.0:
67+
return 0.5 * math.pi
6068
else:
61-
return 0.
69+
return 0.0
70+
6271

6372
def qwtRadians(degrees):
64-
return degrees * np.pi/180.
73+
return degrees * math.pi / 180.0
74+
6575

6676
def qwtDegrees(radians):
67-
return radians * 180./np.pi
77+
return radians * 180.0 / math.pi
6878

0 commit comments

Comments
 (0)