@@ -699,16 +699,15 @@ def entropy(y, bins):
699
699
x = mu + sigma * randn(200000)
700
700
Sanalytic = 0.5 * ( 1.0 + log(2*pi*sigma**2.0) )
701
701
"""
702
- n ,bins = np .histogram (y , bins )
702
+ n , bins = np .histogram (y , bins )
703
703
n = n .astype (np .float_ )
704
704
705
705
n = np .take (n , np .nonzero (n )[0 ]) # get the positive
706
706
707
707
p = np .divide (n , len (y ))
708
708
709
- delta = bins [1 ]- bins [0 ]
710
- S = - 1.0 * np .sum (p * log (p )) + log (delta )
711
- #S = -1.0*np.sum(p*log(p))
709
+ delta = bins [1 ] - bins [0 ]
710
+ S = - 1.0 * np .sum (p * np .log (p )) + np .log (delta )
712
711
return S
713
712
714
713
def normpdf (x , * args ):
@@ -722,22 +721,20 @@ def levypdf(x, gamma, alpha):
722
721
723
722
N = len (x )
724
723
725
- if N % 2 != 0 :
724
+ if N % 2 != 0 :
726
725
raise ValueError ('x must be an event length array; try\n ' + \
727
726
'x = np.linspace(minx, maxx, N), where N is even' )
728
727
728
+ dx = x [1 ] - x [0 ]
729
729
730
- dx = x [ 1 ] - x [ 0 ]
730
+ f = 1 / ( N * dx ) * np . arange ( - N / 2 , N / 2 , np . float_ )
731
731
732
+ ind = np .concatenate ([np .arange (N / 2 , N , int ),
733
+ np .arange (0 , N / 2 , int )])
734
+ df = f [1 ] - f [0 ]
735
+ cfl = np .exp (- gamma * np .absolute (2 * np .pi * f ) ** alpha )
732
736
733
- f = 1 / (N * dx )* np .arange (- N / 2 , N / 2 , np .float_ )
734
-
735
- ind = np .concatenate ([np .arange (N / 2 , N , int ),
736
- np .arange (0 , N / 2 , int )])
737
- df = f [1 ]- f [0 ]
738
- cfl = exp (- gamma * np .absolute (2 * pi * f )** alpha )
739
-
740
- px = np .fft .fft (np .take (cfl ,ind )* df ).astype (np .float_ )
737
+ px = np .fft .fft (np .take (cfl , ind ) * df ).astype (np .float_ )
741
738
return np .take (px , ind )
742
739
743
740
@@ -1458,7 +1455,6 @@ def splitfunc(x):
1458
1455
else :
1459
1456
row = [converterseq [j ](val )
1460
1457
for j ,val in enumerate (splitfunc (line ))]
1461
- thisLen = len (row )
1462
1458
X .append (row )
1463
1459
1464
1460
X = np .array (X , dtype )
@@ -1511,7 +1507,6 @@ def splitfunc(x):
1511
1507
1512
1508
"""
1513
1509
1514
- import operator
1515
1510
import math
1516
1511
1517
1512
@@ -1533,7 +1528,7 @@ def exp_safe(x):
1533
1528
"""
1534
1529
1535
1530
if type (x ) is np .ndarray :
1536
- return exp (np .clip (x ,exp_safe_MIN ,exp_safe_MAX ))
1531
+ return np . exp (np .clip (x ,exp_safe_MIN ,exp_safe_MAX ))
1537
1532
else :
1538
1533
return math .exp (x )
1539
1534
@@ -1817,7 +1812,6 @@ def rec_drop_fields(rec, names):
1817
1812
"""
1818
1813
1819
1814
names = set (names )
1820
- Nr = len (rec )
1821
1815
1822
1816
newdtype = np .dtype ([(name , rec .dtype [name ]) for name in rec .dtype .names
1823
1817
if name not in names ])
@@ -2146,8 +2140,6 @@ def csv2rec(fname, comments='#', skiprows=0, checkrows=0, delimiter=',',
2146
2140
2147
2141
import dateutil .parser
2148
2142
import datetime
2149
- parsedate = dateutil .parser .parse
2150
-
2151
2143
2152
2144
fh = cbook .to_filehandle (fname )
2153
2145
@@ -2938,7 +2930,6 @@ def stineman_interp(xi,x,y,yp=None):
2938
2930
x = np .asarray (x , np .float_ )
2939
2931
y = np .asarray (y , np .float_ )
2940
2932
assert x .shape == y .shape
2941
- N = len (y )
2942
2933
2943
2934
if yp is None :
2944
2935
yp = slopes (x ,y )
0 commit comments