text
stringlengths
0
828
self.tracePlot.setWindowSize(winsz)
self.stimPlot.setWindowSize(winsz)"
49,"def addPlot(self, xdata, ydata, xlabel=None, ylabel=None, title=None, xunits=None, yunits=None):
""""""Adds a new plot for the given set of data and/or labels, Generates a SimplePlotWidget
:param xdata: index values for data, plotted on x-axis
:type xdata: numpy.ndarray
:param ydata: value data to plot, dimension must match xdata
:type ydata: numpy.ndarray
""""""
p = SimplePlotWidget(xdata, ydata)
p.setLabels(xlabel, ylabel, title, xunits, yunits)
# self.plots.append(p)
self.stacker.addWidget(p)"
50,"def addSpectrogram(self, ydata, fs, title=None):
""""""Adds a new spectorgram plot for the given image. Generates a SpecWidget
:param ydata: 2-D array of the image to display
:type ydata: numpy.ndarray
:param fs: the samplerate of the signal in the image, used to set time/ frequency scale
:type fs: int
:param title: Plot title
:type title: str
""""""
p = SpecWidget()
p.updateData(ydata, fs)
if title is not None:
p.setTitle(title)
self.stacker.addWidget(p)"
51,"def nextPlot(self):
""""""Moves the displayed plot to the next one""""""
if self.stacker.currentIndex() < self.stacker.count():
self.stacker.setCurrentIndex(self.stacker.currentIndex()+1)"
52,"def prevPlot(self):
""""""Moves the displayed plot to the previous one""""""
if self.stacker.currentIndex() > 0:
self.stacker.setCurrentIndex(self.stacker.currentIndex()-1)"
53,"def most_even_chunk(string, group):
""""""Divide a string into a list of strings as even as possible.""""""
counts = [0] + most_even(len(string), group)
indices = accumulate(counts)
slices = window(indices, 2)
return [string[slice(*one)] for one in slices]"
54,"def most_even(number, group):
""""""Divide a number into a list of numbers as even as possible.""""""
count, rest = divmod(number, group)
counts = zip_longest([count] * group, [1] * rest, fillvalue=0)
chunks = [sum(one) for one in counts]
logging.debug('chunks: %s', chunks)
return chunks"
55,"def window(seq, count=2):
""""""Slide window.""""""
iseq = iter(seq)
result = tuple(islice(iseq, count))
if len(result) == count:
yield result
for elem in iseq:
result = result[1:] + (elem,)
yield result"
56,"def _get_modules(path):
""""""Finds modules in folder recursively
:param path: directory
:return: list of modules
""""""
lst = []
folder_contents = os.listdir(path)
is_python_module = ""__init__.py"" in folder_contents
if is_python_module:
for file in folder_contents:
full_path = os.path.join(path, file)
if is_file(full_path):
lst.append(full_path)
if is_folder(full_path):
lst += _get_modules(full_path) # recurse in folder
return list(set(lst))"
57,"def get_modules(folder, include_meta=False):
""""""Finds modules (recursively) in folder
:param folder: root folder
:param include_meta: whether include meta files like (__init__ or
__version__)
:return: list of modules
""""""
files = [
file
for file in _get_modules(folder)
if is_file(file) # just files
]
if not include_meta:
files = [
file
for file in files
if not Document(file).name.startswith(""__"")
]