Esempio n. 1
0
 def click_func_key():
     if src == "=":
         try:
             self.val_ans = count(self.answerLabel.text(), self.val_ans)
         except Exception as e:
             QtWidgets.QMessageBox.critical(
                 self, "MyCalculator", "Error Happened!\n" + str(e))
             self.answerLabel.clear()
             return
         self.answerLabel.setText(str(self.val_ans))
         return
     if src == "AC":
         self.answerLabel.clear()
         return
     if src == "Del":
         s = self.answerLabel.text()
         try:
             s = s[:-2]
         except IndexError:
             pass
         self.answerLabel.setText(s)
         return
     if src == "Insert Function":
         ans = QtWidgets.QInputDialog.getItem(self, "MyCalculator",
                                              "Choice A Function:",
                                              FUNCTIONS)
         if not ans[1]:
             return
         text = self.answerLabel.text() + str(ans[0]) + "("
         self.answerLabel.setText(text)
         return
     text = self.answerLabel.text() + SYMBOLS_INPUT[src]
     self.answerLabel.setText(text)
Esempio n. 2
0
def count_helper(fds):
    fds['count_fd'], fds['control_fd'] = counter.open_counter(args.tdc)
    count = counter.count(fds['control_fd'], fds['count_fd'], args.tdc)
    counter.close(fds['control_fd'], fds['count_fd'])
    if count!=None:
        return count
    else:
        return count_helper(fds)
Esempio n. 3
0
    def show_result(name, counter, signal, do_print=False, plot=True):   
        count_result = counter.count(signal)
        format_str = "{}:\nunified_count: {}, sub_counts:{}\nnn_count:{}, nn_sub_count:{}\n"
        to_print = format_str.format(name, count_result['unified_count'], count_result['max_counts'], count_result['unified_marked_count'], count_result['max_marked_counts'])       
        print(to_print)

        if plot==True: 
            plotting.plot_extrema_df_marked(signal, name, count_result)
def objects(examID,exam_loc):
    """
    Uses the Series class to make an object for each series found in the local
    computer's files.
    Takes in examID and exam_loc as strings.
    Returns a list of Series's objects. 
    """
    series,filenames,user=query.harddrive(exam_loc) #needs dicom files only
    objects=[]
    
    print 'Creating objects...'
    j=0
    while j<len(series):
        objects.append(Series(series[j],filenames[j],examID,exam_loc))
        j+=1
    
    counter.count(objects,exam_loc,user)
    counter.size(objects)
    return objects
Esempio n. 5
0
def objects(examID, exam_loc):
    """
    Uses the Series class to make an object for each series found in the local
    computer's files.
    Takes in examID and exam_loc as strings.
    Returns a list of Series's objects. 
    """
    series, filenames, user = query.harddrive(
        exam_loc)  #needs dicom files only
    objects = []

    print 'Creating objects...'
    j = 0
    while j < len(series):
        objects.append(Series(series[j], filenames[j], examID, exam_loc))
        j += 1

    counter.count(objects, exam_loc, user)
    counter.size(objects)
    return objects
 def test_two_trigrams(self):
     test_input = "this has two trigrams"
     output = counter.count([test_input])
     self.assertTrue("this has two" in output)
     self.assertTrue("has two trigrams" in output)
     self.assertEqual(output["this has two"], 1)
     self.assertEqual(output["has two trigrams"], 1)
     # negative tests to make sure our gram "window" isn't sliding too far
     self.assertTrue("two trigrams" not in output)
     self.assertTrue("trigrams" not in output)
     self.assertEqual(len(output.keys()), 2)
    def test_extremely_large_input(self):
        """ This was for doing a convenient in-memory stress test without having to
            gather real files """
        test_input = ""

        # This will produce a string the size of just over 54 copies of Origin of Species
        total_occurrences = 5000000

        for i in range(total_occurrences):
            test_input += "big text here "

        output = counter.count([test_input])
        self.assertTrue("big text here" in output)
        self.assertEqual(output["big text here"], total_occurrences)
Esempio n. 8
0
    def images_handler(self):
        image_path = QFileDialog.getExistingDirectory(self, "Select Image Directory")

        # image_path = input("Enter Image Path:")
        imag = os.listdir(image_path)
        images = [os.path.join(image_path, t) for t in imag]
        # pprint(images)
        # images = self.get_frame(images)
        self.frame_counter = count()

        # images = sorted(images, key=lambda x: int(x[6]))
        for image in images:
            self.frame_counter.set(image)
        self.frame_counter.set_target_as_zero()
        # self.frame_counter.sort_dict()
        # pprint(self.frame_counter.display_all())

        return self.frame_counter
Esempio n. 9
0
 def test_2(self):
     result = count('MyHeartWillGoOn')
     self.assertEqual(
         result, {
             'M': 1,
             'y': 1,
             'H': 1,
             'e': 1,
             'a': 1,
             'r': 1,
             't': 1,
             'W': 1,
             'i': 1,
             'l': 2,
             'G': 1,
             'o': 1,
             'O': 1,
             'n': 1
         })
Esempio n. 10
0
 def test_strip_special_chars(self):
     test_input = r"super,simple.test:a;few!more&words\"here'and?there"
     output = counter.count([test_input])
     self.assertTrue("super simple test" in output)
     self.assertEqual(output["super simple test"], 1)
     self.assertTrue("simple test a" in output)
     self.assertEqual(output["simple test a"], 1)
     self.assertTrue("test a few" in output)
     self.assertEqual(output["test a few"], 1)
     self.assertTrue("a few more" in output)
     self.assertEqual(output["a few more"], 1)
     self.assertTrue("few more words" in output)
     self.assertEqual(output["few more words"], 1)
     self.assertTrue("more words here" in output)
     self.assertEqual(output["more words here"], 1)
     self.assertTrue("words here and" in output)
     self.assertEqual(output["words here and"], 1)
     self.assertTrue("here and there" in output)
     self.assertEqual(output["here and there"], 1)
Esempio n. 11
0
def assess_data(input_file='data.json'):
    """Assessment of source data acquired from Docker Hub API"""
    counter.count(input_file)
Esempio n. 12
0
def count_in_cython(arr):
    return counter.count(arr)
Esempio n. 13
0
import counter as c
import time
start = time.clock()
for x in range(0, 100):
    count_fd, control_fd = c.open_counter(10)
    print c.count(control_fd, count_fd, 10)
    time.sleep(10.0 / 1000)
    c.close(control_fd, count_fd)
print time.clock() - start
Esempio n. 14
0
import struct

import counter

for i in range(0, 10):
    counter.count()

with open(counter.file_name, 'rb') as count_file:
    num = count_file.read(counter.chunk_size)
    while num:
        print(struct.unpack('i', num)[0])
        num = count_file.read(counter.chunk_size)
Esempio n. 15
0
    positions.append([pos_x, pos_y, radius])
    dot_mask[pos_x - int(radius / 2):pos_x + int(radius / 2),
             pos_y - int(radius / 2):pos_y + int(radius / 2)] = 255

dot_mask = cv2.erode(dot_mask, None, iterations=10)
dot_mask = cv2.dilate(dot_mask, None, iterations=15)
cv2.imshow('this', dot_mask)
num_dot, markers = cv2.connectedComponents(dot_mask)
for dot in range(num_dot - 1):

    index = np.where(markers == dot + 1)
    this_mask = np.zeros((markers.shape[0], markers.shape[1], 3), np.uint8)
    this_mask[markers == dot + 1] = 255
    this_mask = cv2.bitwise_and(this_mask, img)
    # cv2.imshow(str(dot),this_mask)
    # cv2.waitKey()
    dot_img = np.zeros(
        (index[0].max() - index[0].min(), index[1].max() - index[1].min(), 3),
        np.uint8)
    dot_img = this_mask[index[0].min():index[0].max(),
                        index[1].min():index[1].max()]

    img = count(img, this_mask, index[0].min(), index[1].min())
    # cv2.imshow(str(dot),dot_img)
    # cv2.waitKey()

print(num_dot)
cv2.imshow('num', img)

cv2.waitKey(0)
Esempio n. 16
0
 def test_number(self):
     text = '1 2 3'
     result = counter.count(text)
     self.assertEqual(result, {'quantity': 3, 'distinct': 3})
Esempio n. 17
0
 def test_empty_string_should_return_empty_dict(self):
     output = counter.count([""])
     self.assertEqual({}, output)
Esempio n. 18
0
 def test_4(self):
     result = count('12341234')
     self.assertEqual(result, {'1': 2, '2': 2, '3': 2, '4': 2})
Esempio n. 19
0
 def test_super_simple_three_word_input(self):
     test_input = "super simple test"
     output = counter.count([test_input])
     self.assertTrue("super simple test" in output)
     self.assertEqual(output["super simple test"], 1)
     self.assertEqual(len(output.keys()), 1)  # total trigrams expected
Esempio n. 20
0
 def test_simple_repeated_trigram(self):
     test_input = "apples are tasty and also apples are tasty"
     output = counter.count([test_input])
     self.assertTrue("apples are tasty" in output)
     self.assertEqual(output["apples are tasty"], 2)
     self.assertEqual(len(output.keys()), 5)
Esempio n. 21
0
 def test_super_simple_mixed_case(self):
     test_input = "super simple test SUPER SIMPLE TEST"
     output = counter.count([test_input])
     self.assertTrue("super simple test" in output)
     self.assertEqual(output["super simple test"], 2)
     self.assertEqual(len(output.keys()), 3)
Esempio n. 22
0
 def test_3(self):
     result = count('HAHAHAHAHAHAHA')
     self.assertEqual(result, {'H': 7, 'A': 7})
Esempio n. 23
0
def test3():
    assert student.count(0, 10, -1) == ""
Esempio n. 24
0
 def test_1(self):
     result = count('')
     self.assertEqual(result, {})
Esempio n. 25
0
def test4():
    assert student.count(10, 0, -1) == "10 9 8 7 6 5 4 3 2 1 0 "
Esempio n. 26
0
END_DLY = 70
FILENAME = 'dll_swp_5ps.csv'

datalist = []

delay_fd = Gpib(name=DEVICE_NAME, pad=PRIMARY_ADDR)

delay_fd.write("DLY {}".format(INIT_DLY))
time.sleep(3)
start = time.clock()

delay_fd.write("DLY {}".format(END_DLY))

for i in range(0, LOOPTILL):
    count_fd, control_fd = c.open_counter(INT_TIME)
    count = c.count(control_fd, count_fd, INT_TIME)
    datalist.append([count, time.clock() - start + 0.001 * (i + 1)])
    c.close(control_fd, count_fd)
    #print('{},{}'.format(count,time.clock()-start))

print(time.clock() - start)
save = open(FILENAME, 'w+')
save.write('count, time\n')

for data in datalist:
    out = '{}, {}\n'.format(data[0], data[1])
    print out
    save.write(out)

save.close()
Esempio n. 27
0
def test5():
    assert student.count(0, 100,
                         7) == "0 7 14 21 28 35 42 49 56 63 70 77 84 91 98 "
Esempio n. 28
0
def count(string):
    return counter.count(string)
Esempio n. 29
0
def test1():
    assert student.count(1, 10, 2) == "1 3 5 7 9 "
Esempio n. 30
0
 def test_base(self):
     text = 'one two three'
     result = counter.count(text)
     self.assertEqual(result, {'quantity': 3, 'distinct': 3})
Esempio n. 31
0
def test2():
    assert student.count(0, 10, 2) == "0 2 4 6 8 10 "