<commit_before># -*- coding: utf-8 -*-
from __future__ import print_function

import sys
import time

import numpy as np

from ...pyqtgraph import PlotWindow

sys.path.append('../../util')
sys.path.append('../..')
from .nidaq import NiDAQ
from acq4.pyqtgraph.functions import mkPen, mkColor

pw = PlotWindow()


time.clock()
sr = 100000
dur = 2.0
data = np.zeros(int(sr*dur))
dlen = len(data)
xVals = np.linspace(0, dur, dlen)

data += np.random.normal(size=dlen) + 20.
data[dlen*0.102:dlen*0.3] += 20
data[dlen*0.3:dlen*0.5] += 30
data[dlen*0.4]+= 1000
data += np.sin(xVals*40677*2.0*np.pi)*4.
#data = sin(linspace(0, dur, sr*dur)* linspace(0, sr*2, sr*dur))

methods = ['subsample', 'mean', 'fourier', 'bessel_mean', 'butterworth_mean']

colors = [mkColor((255,0,0)), mkColor((0,255,0)), mkColor((0,0,255)), mkColor((255,0,255)), mkColor((255,255,0))]
def run(ds):
    pw.plot(data, clear=True)
    for m, c in zip(methods, colors):
        d1 = data.copy()
        t = time.clock()
        d2 = NiDAQ.downsample(d1, ds, method=m)
        print("Method %d: %f" % (m, time.clock()-t))
        p = pw.plot(y=d2, x=np.linspace(0, len(d2)*ds, len(d2)), pen=mkPen(c))
        p.setZValue(10000)
        #pw.plot(d2, pen=mkPen(colors[i-1]))
    
def showDownsample(**kwargs):
    d1 = data.copy()
    d2 = NiDAQ.downsample(d1, **kwargs)
    xv2 = xVals[::kwargs['ds']][:len(d2)]
    pw.plot(y=d1, x=xVals, clear=True)
    pw.plot(y=d2[:len(xv2)], x=xv2, pen=mkPen((255, 0, 0)))
    


def showTransfer(**kwargs):<commit_msg>integers needed for index slicing, so make sure it looks int-y<commit_after># -*- coding: utf-8 -*-
from __future__ import print_function

import sys
import time

import numpy as np

from ...pyqtgraph import PlotWindow

sys.path.append('../../util')
sys.path.append('../..')
from .nidaq import NiDAQ
from acq4.pyqtgraph.functions import mkPen, mkColor

pw = PlotWindow()


time.clock()
sr = 100000
dur = 2.0
data = np.zeros(int(sr*dur))
dlen = len(data)
xVals = np.linspace(0, dur, dlen)

data += np.random.normal(size=dlen) + 20.
data[round(dlen*0.102):round(dlen*0.3)] += 20
data[round(dlen*0.3):round(dlen*0.5)] += 30
data[round(dlen*0.4)]+= 1000
data += np.sin(xVals*40677*2.0*np.pi)*4.
#data = sin(linspace(0, dur, sr*dur)* linspace(0, sr*2, sr*dur))

methods = ['subsample', 'mean', 'fourier', 'bessel_mean', 'butterworth_mean']

colors = [mkColor((255,0,0)), mkColor((0,255,0)), mkColor((0,0,255)), mkColor((255,0,255)), mkColor((255,255,0))]
def run(ds):
    pw.plot(data, clear=True)
    for m, c in zip(methods, colors):
        d1 = data.copy()
        t = time.clock()
        d2 = NiDAQ.downsample(d1, ds, method=m)
        print("Method %d: %f" % (m, time.clock()-t))
        p = pw.plot(y=d2, x=np.linspace(0, len(d2)*ds, len(d2)), pen=mkPen(c))
        p.setZValue(10000)
        #pw.plot(d2, pen=mkPen(colors[i-1]))
    
def showDownsample(**kwargs):
    d1 = data.copy()
    d2 = NiDAQ.downsample(d1, **kwargs)
    xv2 = xVals[::kwargs['ds']][:len(d2)]
    pw.plot(y=d1, x=xVals, clear=True)
    pw.plot(y=d2[:len(xv2)], x=xv2, pen=mkPen((255, 0, 0)))
    


def showTransfer(**kwargs):
{'fraction_non_alphanumeric': 0.20998719590268886, 'fraction_numerical': 0.0646606914212548, 'mean_word_length': 3.9135220125786163, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5089748', 'n_tokens_mistral': 1442, 'n_tokens_neox': 1335, 'n_words': 261}