コード例 #1
0
ファイル: iterators.py プロジェクト: karobokk/ex-lab4
 def __init__(self, items, **kwargs):
     # Нужно реализовать конструктор
     # В качестве ключевого аргумента, конструктор должен принимать bool-параметр ignore_case,
     # в зависимости от значения которого будут считаться одинаковые строки в разном регистре
     # Например: ignore_case = True, Aбв и АБВ разные строки
     #           ignore_case = False, Aбв и АБВ одинаковые строки, одна из них удалится
     # По-умолчанию ignore_case = False
     if kwargs.get('ignore_case', False):
         self._items = list(unique_everseen(items, str.lower))
     else:
         self._items = list(unique_everseen(items))
     self._counter = -1
コード例 #2
0
    def create_new_partition(self, event):
        from gui.viewer import PALMS
        vb = self.vbs[self.selected_view()]
        click_x = vb.mapSceneToView(event.pos()).x()
        menu = QtWidgets.QMenu()
        existing_partition_names = list(
            unique_everseen(PALMS.config['default_partition_labels'] +
                            Partitions.unique_labels()))
        menu.addActions([menu.addAction(n) for n in existing_partition_names])
        menu.addSeparator()
        menu.addAction('New Partition')
        new_partition_name = menu.exec_(event.globalPos().__add__(
            QtCore.QPoint(10, 10)))
        if new_partition_name is not None:
            new_name = new_partition_name.text()
            if new_name == 'New Partition':
                new_name, accepted = QInputDialog.getText(
                    self, 'Partition name input', 'Enter new partition name:')
                if not accepted:
                    qWarning('Incorrect name')
                    return

            if Partitions.find_partition_by_point(click_x) is not None:
                qWarning('Choose different place or delete existing region')
            else:
                p = SinglePartition.from_click(new_name, click_x=click_x)
                vb.addItem(p)
                vb.addItem(p.label)
        event.accept()
コード例 #3
0
def main_fun(append_list):
    mid_list1 = list()
    for ins in range(len(append_list)):
        appended = str(append_list[ins])
        add0 = appended + '0'
        add1 = appended + '1'
        mid_list1.append(add0)
        mid_list1.append(add1)
    return list(unique_everseen(mid_list1))
コード例 #4
0
ファイル: clistats.py プロジェクト: andreaskern/simcoin
    def __collect_forks_form_getchaintips(node_values, writer):
        logging.info('Collecting forks.csv from getchaintips')

        tips = []
        for node in node_values:
            tips.extend(
                    [
                        Tip.from_dict(
                                node.name,
                                chain_tip
                        )
                        for chain_tip
                        in node.execute_rpc('getchaintips')
                    ]
            )

        '''
    
        Possible values for status:
        1.  "invalid"         branch contains invalid blocks
        2.  "headers-only"    Not all blocks for this branch are available, but the headers are valid
        3.  "valid-headers"   All blocks are available for this branch, but they were never fully validated
        4.  "valid-fork"            This branch is not part of the active chain, but is fully validated
        5.  "active"                This is the tip of the active main chain, which is certainly valid
        
        fork life cycle
        
        headers-only -> valid.headers -> {invalid, valid-fork -> active -> [REC:valid-fork]}
    
        '''
        forks = []

        '''select height, status '''
        for tip in tips:
            forks.extend([
                tip._height,
                tip._status
            ])

        '''filter status != valid-fork'''
        forks = [tip for tip in tips if tip.is_valid_fork()]

        '''aggregate by hash # fold status '''
        forks = unique_everseen(forks, key=attrgetter('_hash'))

        '''sort by tag, height'''
        forks = sorted(forks, key=attrgetter('_height'))
        # sorted(forks, key=attrgetter('_tag')) # tag is added later

        writer.write_csv(
                "forks.csv",
                ['node','status','length','height', 'tag'],
                forks
        )
コード例 #5
0
def checker(liter):
    check_list = list()
    for im in range(len(liter)):
        af = str(liter[im])
        mid_list = af
        for xx in range(len(mid_list)):
            for ro in range(len(mid_list)):
                if mid_list[ro] == mid_list[xx]:
                    continue
                else:
                    alp = str(xx + 1) + str(ro + 1)
                    check_list.append(alp)
            check_list = list(unique_everseen(check_list))
            check_list.sort()
    return check_list
コード例 #6
0
def mini(test_patterns):
    #print test_patterns
    test_pattern = list()

    for l in range(len(test_patterns)):
        test_pattern.append(str(test_patterns[l]))

    test_set = []
    permutations = list()
    # Generate possible Faults
    line_num = lines_count()
    for lines in range(1, line_num + 1):
        permutations.append(lines)

    permutations = list(itertools.permutations(permutations, 2))
    for i in range(len(permutations)):
        var1 = str(permutations[i][0])
        for j in range(1, len(permutations[i])):
            var1 += str(permutations[i][j])
        permutations[i] = var1
    permutations = list(unique_everseen(permutations))
    permutations.sort()
    combs = []
    # Generate Sets from Test-Pattern
    for length_pattern in range(len(test_pattern)):
        for combination in range(length_pattern, len(test_pattern) + 1):
            pattern = [
                list(x)
                for x in itertools.combinations(test_pattern, combination)
            ]
            combs.extend(pattern)
    # Check Faults Covered By Sets of Test-Pattern
    for combinations in range(len(combs)):
        test_result = checker(combs[combinations])
        test_result.sort()
        if str(test_result) == str(permutations):
            #print test_result

            # If all Faults are covered, Print The Test Set
            test_set = combs[combinations]
            break
    #print test_set
    return test_set
コード例 #7
0
if num_lines > 2:
    for line_num in range(3, num_lines + 1):
        test_set = []
        length_pattern = len(test_pattern)
        permutations = list()
        # Generate possible Faults
        for lines in range(1, line_num + 1):
            permutations.append(lines)
        permutations = list(itertools.permutations(permutations, 2))

        for i in range(len(permutations)):
            var1 = str(permutations[i][0])
            for j in range(1, len(permutations[i])):
                var1 += str(permutations[i][j])
            permutations[i] = var1
        permutations = list(unique_everseen(permutations))
        permutations.sort()

        test_pattern = main_fun(test_pattern)
        combs = []
        # Generate Sets from Test-Pattern
        for combination in range(length_pattern, len(test_pattern) + 1):
            pattern = [list(x) for x in itertools.combinations(test_pattern, combination)]
            combs.extend(pattern)
        # Check Faults Covered By Sets of Test-Pattern
        for combinations in range(len(combs)):
            test_result = checker(combs[combinations])
            test_result.sort()
            if str(test_result) == str(permutations):
                # If all Faults are covered, Print The Test Set
                if num_lines == line_num:
コード例 #8
0
def test_case_generator(num_lines_main):
    # Take Input
    num_lines = num_lines_main

    def checker(liter):
        check_list = list()
        for im in range(len(liter)):
            af = str(liter[im])
            mid_list = af
            for xx in range(len(mid_list)):
                for ro in range(len(mid_list)):
                    if mid_list[ro] == mid_list[xx]:
                        continue
                    else:
                        alp = str(xx + 1) + str(ro + 1)
                        check_list.append(alp)
                check_list = list(unique_everseen(check_list))
                check_list.sort()
        return check_list

    # Embeds alternating 1's and 0's
    def main_fun(append_list):
        mid_list1 = list()
        for ins in range(len(append_list)):
            appended = str(append_list[ins])
            add0 = appended + '0'
            add1 = appended + '1'
            mid_list1.append(add0)
            mid_list1.append(add1)
        return list(unique_everseen(mid_list1))

    test_pattern = ['10']

    # Check Number of Lines
    if num_lines == 1:
        print('Invalid Input')
    if num_lines == 2:
        print('Test Pattern for Bridging fault', test_pattern)

    if num_lines > 2:
        for line_num in range(3, num_lines + 1):
            # test_set_1 = []
            length_pattern = len(test_pattern)
            permutations = list()
            # Generate possible Faults
            for lines in range(1, line_num + 1):
                permutations.append(lines)
            permutations = list(itertools.permutations(permutations, 2))

            for i in range(len(permutations)):
                var123 = str(permutations[i][0])
                for j in range(1, len(permutations[i])):
                    var123 += str(permutations[i][j])
                permutations[i] = var123
            permutations = list(unique_everseen(permutations))
            permutations.sort()

            test_pattern = main_fun(test_pattern)
            combs = []
            # Generate Sets from Test-Pattern
            for combination in range(length_pattern, len(test_pattern) + 1):
                pattern = [
                    list(x)
                    for x in itertools.combinations(test_pattern, combination)
                ]
                combs.extend(pattern)
            # Check Faults Covered By Sets of Test-Pattern
            for combinations in range(len(combs)):
                test_result = checker(combs[combinations])
                test_result.sort()
                if str(test_result) == str(permutations):
                    # If all Faults are covered, Print The Test Set
                    if num_lines == line_num:
                        print('Test Pattern for Bridging fault with lines',
                              line_num, combs[combinations])
                        return combs[combinations]
                    break
コード例 #9
0
ファイル: xys.py プロジェクト: joinalahmed/RC-tool
            asd1 = str(asd)
            #print asd1
            break
    ff = open('main.txt', 'w')
    ff.write(bb)
    ff.write('\n')
    ff.close()
with open('/home/joy/Desktop/final.csv', 'r') as f:
    reader = csv.reader(f)
    your_list = list(reader)

del (your_list[0])
del (your_list[0])

your_list = sum(your_list, [])
test_set = list(unique_everseen(your_list))
test_set.sort()

with open('/home/joy/Desktop/test/rev.tfc', 'r') as datafile:
    dis = list(datafile)
    #print dis
    for line in datafile:
        line1 = line.strip()
        if '.v' in line1:
            aa = line1
            bb = aa
            bb = bb[3:]
            cc = re.split(',', bb)
            asd = len(cc)
            asd1 = str(asd)
            break
コード例 #10
0
 def unique_labels():
     return list(unique_everseen(Partitions.all_labels()))