Example #1
0
 def test_is_busy_after_proc_finish(self):
     p = Processor('test', 10)
     work_time = p.add_process(12313)
     for w in range(work_time - 1):
         p.process()
         #  self.assertEqual(p.is_busy(), True)
     self.assertEqual(p.is_busy(), False)
Example #2
0
File: load.py Project: hsm207/ecg
def load_train(params):
    assert ('data_path' in params)
    processor = Processor(**params)
    loader = Loader(processor, **params)

    print("Length of training set {}".format(len(loader.x_train)))
    print("Length of test set {}".format(len(loader.x_test)))
    return loader, processor
Example #3
0
 def test_buffer_limit(self):
     ''' Adds more processes than process can handle till buffer overflow '''
     b = Buffer(2)
     p = Processor('rtt', 40, b)
     p.add_process(123)
     p.add_process(1231231)
     p.add_process(87)
     self.assertEqual(0, p.add_process(666))
Example #4
0
def test_camera(index=0):
    processor = Processor()
    cap = cv2.VideoCapture(index)
    while True:
        ret, img = cap.read()
        if not ret:
            break
        show = processor.RecogAndDraw(img)
        cv2.imshow('py_face_recognition', show)
        cv2.waitKey(1)
Example #5
0
    def test_processing_flow(self):
        # create a process
        p = Processor('tt', 40)
        till_free = p.add_process(123)
        current_state = till_free

        # check if process reduces till free timer with each call
        # to process method
        for i in range(till_free):
            self.assertEqual(p.process(), current_state - 1)
            current_state -= 1

        # check that in the end of process till free is set to 0
        self.assertEqual(0, p.process())
Example #6
0
File: load.py Project: hsm207/ecg
def load_test(test_params,
              train_params=None,
              split='test',
              fit_processor=False):
    if train_params is None:
        processor = Processor(**test_params)
    else:
        _, processor = load_train(train_params)
    x, y, dl = load_x_y_with_processor(test_params,
                                       processor,
                                       split=split,
                                       fit_processor=fit_processor)
    gt = np.array([np.argmax(y, axis=-1)])
    return x, gt, processor, dl
Example #7
0
    def __init__(self, baseUrl, initParams, formatter=Formatter()):

        #initializing the queryContainer with parameters and initial request
        self.query = QueryContainer(baseUrl)
        self.params = initParams
        self.query.setParameters(self.params)
        self.query.setRequest()

        #initialize Formatter object
        #this object converts responses to Sumit's json format
        self.formatter = formatter

        #initialize the processor
        self.query.getResponse()
        self.processor = Processor(self.query.response,
                                   'xml', soupifyResponse=True)
Example #8
0
    def test_queue_empting(self):
        p = Processor('test', 10, Buffer(1))
        work_time = p.add_process(14)
        p.add_process(789)
        self.assertEqual(1, p.get_queue_len())
        # the queue length should stay 1 after additinal push
        p.add_process(444)
        self.assertEqual(1, p.get_queue_len())

        # this is one more `work` than needed to finish process
        for i in range(work_time):
            p.process()

        # the process should take the next element from the buffer
        self.assertEqual(p.get_queue_len(), 0)
        # the process should take the next element from buffer
        # and continue working
        self.assertNotEqual(p.process(), 0)
Example #9
0
    def __init__(self, config, model=None, retrieve=None):
        self.config = config
        self.processor = Processor(config)
        if model is None:
            bert = load_bert_from_ckpt(self.config.bert_dir,
                                       transformer_num=self.config.n_layers,
                                       trainable=True)
            self.model = get_mrc_model(bert, self.config)
        else:
            self.model = model

        if retrieve is not None:
            self.retrieve = keras.models.Model(retrieve.inputs,
                                               retrieve.outputs[0])
        else:
            self.retrieve = None

        start = keras.layers.Input(shape=(config.seq_maxlen, ),
                                   dtype='float32')
        end = keras.layers.Input(shape=(config.seq_maxlen, ), dtype='float32')
        decoded = Answer(config.ans_maxlen)([start, end])
        self.decoder = keras.models.Model([start, end], decoded)
Example #10
0
 def test_keyphrases3(self):
     processor = Processor()
     self.assertTrue("boring workshop" in processor.textKeyPhrases(
         "This was an boring workshop."))
Example #11
0
 def test_keyphrases2(self):
     processor = Processor()
     self.assertTrue("great event" in processor.textKeyPhrases(
         "This was a great event."))
Example #12
0
 def test_adjective_sentiment1(self):
     processor = Processor()
     self.assertEqual(
         processor.textAdjectives("This was a horrific project.")[1], -1)
Example #13
0
 def test_adjectives2(self):
     processor = Processor()
     self.assertTrue("interesting" in processor.textAdjectives(
         "I found this project to be very interesting.")[0])
Example #14
0
 def test_sentiment_empty(self):
     processor = Processor()
     self.assertEqual(round(processor.textSentiment("")), 0)
Example #15
0
 def test_sentiment_negative(self):
     processor = Processor()
     self.assertLessEqual(
         processor.textSentiment("This project was the worst."), -0.5)
Example #16
0
 def test_avg_unsafe_count(self):
     processor = Processor()
     self.assertEqual(processor.runningAvg(5, 3, -10), 3)
Example #17
0
 def test_sentiment_positive(self):
     processor = Processor()
     self.assertGreaterEqual(
         processor.textSentiment("This workshop was incredible."), 0.5)
Example #18
0
from aiohttp import web
import socketio
import asyncio
import time, os, base64, sys

socketio = socketio.AsyncServer()
app = web.Application()
socketio.attach(app)

loop = asyncio.get_event_loop()

config = Config()
users = Users()

processor = Processor(config.songcacheDir, socketio, loop, config)

playlist = Playlist(config, socketio, loop, processor)
playlistlist = PlaylistList(config, socketio, loop, processor)
player = Player(config, socketio, loop)

main = mainNamespace(playlist, player, playlistlist, config, loop, users,
                     '/main')
admin = adminNamespace(config, users, loop, '/admin')

socketio.register_namespace(main)
socketio.register_namespace(admin)


async def index(request):
    peername = request.transport.get_extra_info('peername')
Example #19
0
 def test_sentiment_neutral(self):
     processor = Processor()
     self.assertEqual(
         round(processor.textSentiment("This event was okay.")), 0)
Example #20
0
from flask import Flask, request
from datetime import datetime, timezone
from process import Processor

app = Flask(__name__)

processor = Processor()


@app.route('/', methods=['GET', 'POST'])
def index():
    return "WORKING"


@app.route('/emoji', methods=['POST'])
def emoji():
    data = request.json
    newValue = data["value"]
    field = data["field"]
    startTime = data["startTime"]

    curUTC = datetime.now(timezone.utc)
    field["data"]["average"] = processor.runningAvg(newValue,
                                                    field["data"]["average"],
                                                    field["data"]["num"])
    field["data"]["timeSeries"] = processor.timeSeries(
        newValue, field["data"]["timeSeries"], 30, startTime)
    field["data"]["num"] += 1

    return {"field": field}
Example #21
0
 def test_adjectives1(self):
     processor = Processor()
     self.assertTrue("cheerful" in processor.textAdjectives(
         "The host was cheerful.")[0])
Example #22
0
 def __init__(self):
     self.queue = Queue.Queue()
     self.processor = Processor('catch_upload processor', self.queue)
     self.processor.start()
Example #23
0
 def test_adjective_sentiment1(self):
     processor = Processor()
     self.assertEqual(
         processor.textAdjectives("This was a great experience.")[1], 1)
Example #24
0
 def test_time_unsafe(self):
     processor = Processor()
     start = datetime(2000, 12, 11, 11, 11, 11)
     current = datetime(2000, 12, 11, 11, 45, 11)
     self.assertEqual(processor.getIntervalTime(start, current, 0), current)
Example #25
0
 def test_keyphrases1(self):
     processor = Processor()
     self.assertTrue("technical issues" in processor.textKeyPhrases(
         "The host had lots of technical issues."))
Example #26
0
 def test_avg_increase_avg(self):
     processor = Processor()
     self.assertEqual(processor.runningAvg(5, 1, 500), 505 / 501)
Example #27
0
 def test_avg_decrease_avg(self):
     processor = Processor()
     self.assertEqual(processor.runningAvg(2, 5, 100), 502 / 101)
Example #28
0
 def test_avg_same_avg(self):
     processor = Processor()
     self.assertEqual(processor.runningAvg(3, 3, 1000), 3)
Example #29
0
 def test_time_2(self):
     processor = Processor()
     start = datetime(2000, 12, 11, 11, 11, 00)
     current = datetime(2000, 12, 12, 11, 00, 47)
     self.assertEqual(processor.getIntervalTime(start, current, 150),
                      datetime(2000, 12, 12, 10, 58, 30))
Example #30
0
 def test_avg_first_element(self):
     processor = Processor()
     self.assertEqual(processor.runningAvg(2, 0, 0), 2)