Skip to content

Commit

Permalink
pylint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
aewallin committed Aug 3, 2019
1 parent 89f0ad5 commit d5a6c7f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 27 deletions.
44 changes: 22 additions & 22 deletions allantools/allantools.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
Version history
---------------
**2019.07**
**2019.07** 2019 August 3
- move edf-functions and noise-ID functions to ci.py
- mtotdev() htotdev() speed improvements
- save dataset results to text file
- real-time adev/mdev/hdev
- travis testing on Lniux, OSX, and Windows
- travis testing on Linux, OSX, and Windows
**2018.03** 2018 March 27
- change license to LGPL v3 or later
Expand Down Expand Up @@ -718,17 +718,18 @@ def calc_mtotdev_phase(phase, rate, m):
""" PRELIMINARY - REQUIRES FURTHER TESTING.
calculation of mtotdev for one averaging factor m
tau = m*tau0
NIST [SP1065]_ Eqn (27), page 25.
Computed from a set of N - 3m + 1 subsequences of 3m points.
1. A linear trend (frequency offset) is removed from the subsequence
by averaging the first and last halves of the subsequence and dividing by half the interval.
1. A linear trend (frequency offset) is removed from the subsequence
by averaging the first and last halves of the subsequence and
dividing by half the interval.
2. The offset-removed subsequence is extended at both ends
by uninverted, even reflection.
[Howe1999]_
D.A. Howe and F. Vernotte, "Generalization of the Total Variance
D.A. Howe and F. Vernotte, "Generalization of the Total Variance
Approach to the Modified Allan Variance," Proc.
31 st PTTI Meeting, pp. 267-276, Dec. 1999.
"""
Expand Down Expand Up @@ -765,10 +766,10 @@ def calc_mtotdev_phase(phase, rate, m):
# remove the linear trend
x0 = [x - slope*idx*tau0 for (idx, x) in enumerate(xs)]
x0_flip = x0[::-1] # left-right flipped version of array

# Step 2.
# extend sequence, by uninverted even reflection
# extended sequence xstar, of length 9m,
# extended sequence xstar, of length 9m,
xstar = np.concatenate((x0_flip, x0, x0_flip))
assert len(xstar) == 9*m

Expand All @@ -778,8 +779,7 @@ def calc_mtotdev_phase(phase, rate, m):
# one term in the 6m sum: [ x_i - 2 x_i+m + x_i+2m ]^2
squaresum = 0.0
#print('m=%d 9m=%d maxj+3*m=%d' %( m, len(xstar), 6*int(m)+3*int(m)) )



# below we want the following sums (averages, see squaresum where we divide by m)
# xmean1=np.sum(xstar[j : j+m])
# xmean2=np.sum(xstar[j+m : j+2*m])
Expand All @@ -790,16 +790,16 @@ def calc_mtotdev_phase(phase, rate, m):
# faster inner sum, based on Stable32 MTC.c code
if j == 0:
# intialize the sum
xmean1 = np.sum( xstar[0:m] )
xmean2 = np.sum( xstar[m:2*m] )
xmean3 = np.sum( xstar[2*m:3*m] )
xmean1 = np.sum(xstar[0:m])
xmean2 = np.sum(xstar[m:2*m])
xmean3 = np.sum(xstar[2*m:3*m])
else:
# j>=1, subtract old point, add new point
xmean1 = xmean1 - xstar[j-1] + xstar[j+m-1] #
xmean2 = xmean2 - xstar[m+j-1] + xstar[j+2*m-1] #
xmean3 = xmean3 - xstar[2*m+j-1] + xstar[j+3*m-1] #

squaresum += pow( (xmean1 - 2.0*xmean2 + xmean3)/float(m), 2)
squaresum += pow((xmean1 - 2.0*xmean2 + xmean3)/float(m), 2)

squaresum = (1.0/(6.0*m)) * squaresum
dev += squaresum
Expand All @@ -817,7 +817,7 @@ def htotdev(data, rate=1.0, data_type="phase", taus=None):
""" PRELIMINARY - REQUIRES FURTHER TESTING.
Hadamard Total deviation.
Better confidence at long averages for Hadamard deviation
Computed for N fractional frequency points y_i with sampling
period tau0, analyzed at tau = m*tau0
1. remove linear trend by averaging first and last half and divide by interval
Expand Down Expand Up @@ -941,17 +941,17 @@ def calc_htotdev_freq(freq, m):
# new faster way of doing the sums
if j == 0:
# intialize the sum
xmean1 = np.sum( xstar[0:m] )
xmean2 = np.sum( xstar[m:2*m] )
xmean3 = np.sum( xstar[2*m:3*m] )
xmean1 = np.sum(xstar[0:m])
xmean2 = np.sum(xstar[m:2*m])
xmean3 = np.sum(xstar[2*m:3*m])
else:
# j>=1, subtract old point, add new point
xmean1 = xmean1 - xstar[j-1] + xstar[j+m-1] #
xmean2 = xmean2 - xstar[m+j-1] + xstar[j+2*m-1] #
xmean3 = xmean3 - xstar[2*m+j-1] + xstar[j+3*m-1] #

squaresum += pow( (xmean1 - 2.0*xmean2 + xmean3)/float(m), 2)
squaresum += pow((xmean1 - 2.0*xmean2 + xmean3)/float(m), 2)

k = k+1
assert k == 6*m # check number of terms in the sum
squaresum = (1.0/(6.0*k)) * squaresum
Expand Down Expand Up @@ -1097,7 +1097,7 @@ def mtie_rolling_window(a, window):
-------
Array that is a view of the original array with a added dimension
of size window.
Note
----
This may consume large amounts of memory. See discussion:
Expand Down
2 changes: 1 addition & 1 deletion allantools/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from . import allantools


class Dataset():
class Dataset(object):
""" Dataset class for Allantools
:Example:
Expand Down
10 changes: 6 additions & 4 deletions allantools/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"""


class Plot():
class Plot(object):
""" A class for plotting data once computed by Allantools
:Example:
Expand Down Expand Up @@ -67,7 +67,7 @@ def plot(self, atDataset,
errorbars=False,
grid=False,
**kwargs
):
):
""" Use matplotlib methods for plotting
Additional keywords arguments are passed to
Expand All @@ -88,12 +88,12 @@ def plot(self, atDataset,
atDataset.out["stat"],
yerr=atDataset.out["stat_err"],
**kwargs
)
)
else:
self.ax.plot(atDataset.out["taus"],
atDataset.out["stat"],
**kwargs
)
)
self.ax.set_xlabel("Tau")
self.ax.set_ylabel(atDataset.out["stat_id"])
self.ax.grid(grid, which="minor", ls="-", color='0.65')
Expand All @@ -108,4 +108,6 @@ def show(self):
self.plt.show()

def save(self, f):
"""Save figure to file
"""
self.plt.savefig(f)

0 comments on commit d5a6c7f

Please sign in to comment.