Skip to content

Commit 77962c9

Browse files
committed
Remove matplotlib dependency
1 parent 7e1d2dd commit 77962c9

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

waveform_analysis/_common.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env python
22

33
from numpy import array_equal, polyfit, sqrt, mean, absolute, log10, arange
4+
import numpy as np
45
from scipy.stats import gmean
56

67
try:
@@ -110,13 +111,21 @@ def analyze_channels(filename, function):
110111
function(channel, sample_rate)
111112

112113

114+
# Copied from matplotlib.mlab:
115+
113116
def rms_flat(a):
114117
"""
115118
Return the root mean square of all the elements of *a*, flattened out.
116119
"""
117120
return sqrt(mean(absolute(a)**2))
118121

119122

123+
def find(condition):
124+
"Return the indices where ravel(condition) is true"
125+
res, = np.nonzero(np.ravel(condition))
126+
return res
127+
128+
120129
def dB(q):
121130
"""
122131
Return the level of a field quantity in decibels.

waveform_analysis/freq_estimation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from waveform_analysis._common import parabolic
44
from numpy.fft import rfft
55
from numpy import asarray, argmax, mean, diff, log, copy
6-
from matplotlib.mlab import find
6+
from waveform_analysis._common import find
77
from scipy.signal import correlate, kaiser, decimate
88

99

0 commit comments

Comments
 (0)