How to use not_zero method in hypothesis

Best Python code snippet using hypothesis

braveburst.py

Source:braveburst.py Github

copy

Full Screen

1from util import *2skill_level_process_format = {3 '1': ((0, 'bb atk%', int, not_zero),4 (1, 'bb flat atk', int, not_zero),5 (2, 'bb crit%', int, not_zero),6 (3, 'bb bc%', int, not_zero),7 (4, 'bb hc%', int, not_zero),8 (5, 'bb dmg%', int, not_zero)),9 '2': ((0, 'heal low', int),10 (1, 'heal high', int),11 ([2, 3], 'rec added% (heal)',12 lambda x, y: 100 + ((1 + float(x) / 100) *13 (1 + float(y) / 100) * 10))),14 '3': ((0, 'gradual heal low', int),15 (1, 'gradual heal high', int),16 (2, 'rec added% (regen)', lambda x: (1 + float(x) / 100) * 10),17 (3, 'gradual heal turns', int)),18 '4': ((0, 'bb bc fill', int, not_zero),19 (1, 'bb bc fill%', int, not_zero)),20 '5': ((0, 'element buffed', elements.get),21 (1, 'atk% buff', int, not_zero),22 (2, 'def% buff', int, not_zero),23 (3, 'rec% buff', int, not_zero),24 (4, 'crit% buff', int, not_zero),25 (5, 'buff turns', int)),26 '6': ((0, 'bc drop rate% buff', int, not_zero),27 (1, 'hc drop rate% buff', int, not_zero)),28 '7': ((0, 'angel idol effect this turn', True),),29 '10': ((0, 'remove all status ailments', True),),30 '11': (([0, 1], ailments.get, second_int, not_zero),31 ([2, 3], ailments.get, second_int, not_zero),32 ([4, 5], ailments.get, second_int, not_zero),33 ([6, 7], ailments.get, second_int, not_zero)),34 '13': ((0, 'random attack', True),35 (0, 'bb atk%', int, not_zero),36 (1, 'bb flat atk', int, not_zero),37 (2, 'bb crit%', int, not_zero),38 (3, 'bb bc%', int, not_zero),39 (4, 'bb hc%', int, not_zero),40 (5, 'hits', int, not_zero)),41 '14': ((0, 'bb atk%', int, not_zero),42 (1, 'bb flat atk', int, not_zero),43 (2, 'bb crit%', int, not_zero),44 (3, 'bb bc%', int, not_zero),45 (4, 'bb hc%', int, not_zero),46 (5, 'bb dmg%', int, not_zero),47 (6, 'hp drain% low', int),48 (7, 'hp drain% high', int)),49 '17': ((6, 'negate status ails turns', int),),50 '18': ((0, 'dmg% reduction', int),51 (1, 'dmg% reduction turns', int)),52 '19': ((0, 'increase bb gauge gradual', bb_gauge),53 (1, 'increase bb gauge gradual turns', int)),54 '20': ((0, 'bc fill when attacked low', bb_gauge),55 (1, 'bc fill when attacked high', bb_gauge),56 (2, 'bc fill when attacked%', int),57 (3, 'bc fill when attacked turns', int)),58 '22': ((0, 'defense% ignore', int),59 (1, 'defense% ignore turns', int)),60 '23': ((0, 'spark dmg% buff', int),61 (6, 'buff turns', int)),62 '29': (([0, 1, 2], 'bb elements',63 lambda x, y, z: map(elements.get, filter(not_zero, [x, y, z]))),64 (3, 'bb atk%', int, not_zero),65 (4, 'bb flat atk', int, not_zero),66 (5, 'bb crit%', int, not_zero),67 (6, 'bb bc%', int, not_zero),68 (7, 'bb hc%', int, not_zero),69 (8, 'bb dmg%', int, not_zero)),70 '30': (([0, 1, 2], 'elements added',71 lambda x, y, z: map(elements.get, filter(not_zero, [x, y, z]))),72 (6, 'elements added turns', int)),73 '31': ((0, 'increase bb gauge', bb_gauge),)74}75def parse_skill_level_process(process_type, process_info):76 if process_type in skill_level_process_format:77 return handle_format(skill_level_process_format[process_type],78 process_info.split(','))79 return {}80def parse_skill_level_processes(process_types, process_infos):81 level_data = {}82 for process_type, process_info in zip(process_types, process_infos):83 process_data = parse_skill_level_process(process_type,84 process_info)85 if 'elements added' in process_data and 'elements added' in level_data:86 level_data['elements added'] += process_data.pop('elements added')87 if 'bb elements' in process_data and 'bb elements' in level_data:88 level_data['bb elements'] += process_data.pop('bb elements')89 level_data.update(process_data)90 return level_data91def parse_skill_levels(unit_data, skill_data, skill, skill_levels):92 skill_level_format = (93 (1, 'bc cost', bb_gauge),94 lambda lvl: parse_skill_level_processes(95 skill[PROCESS_TYPE].split('@'), lvl[2].split('@')),96 ([], 'max bc generated',97 lambda data: data['hits'] * int(skill[DROP_CHECK_CNT]),98 lambda data: 'hits' in data),99 ([], 'lord damage range',100 lambda data: dmg_str(damage_range_bb(unit_data, skill_data, data)),101 lambda data: 'bb atk%' in data)102 )103 return [handle_format(skill_level_format, level_info.split(':'))104 for level_info in skill_levels[SKILL_LEVELS_PROCESSES].split('|')]105def parse_skill(unit_data, skill, skill_levels, dictionary):106 atk_process_types = {'1', '14', '29'}107 def get_skill_atk_frame(process_types, action_frames):108 for process_type, action_frame in zip(process_types.split('@'),109 action_frames.split('@')):110 if process_type in atk_process_types:111 return action_frame112 skill_format = ((BB_NAME, 'name', get_dict_str(dictionary)),113 (DESC, 'desc', get_dict_str(dictionary)),114 ([PROCESS_TYPE, DMG_FRAME], 'hits',115 lambda p, a: hits(get_skill_atk_frame(p, a)),116 lambda p: not set(p.split('@')).isdisjoint(117 atk_process_types)),118 ([PROCESS_TYPE, DMG_FRAME], 'hit dmg% distribution',119 lambda p, a: hit_dmg_dist(get_skill_atk_frame(p, a)),120 lambda p, a, data: 'hits' in data),121 (DROP_CHECK_CNT, 'max bc generated',122 lambda x, data: data['hits'] * int(x),123 lambda x, data: 'hits' in data),124 ([], 'levels', lambda data: parse_skill_levels(125 unit_data, data, skill, skill_levels)))...

Full Screen

Full Screen

leaderskill.py

Source:leaderskill.py Github

copy

Full Screen

1from util import *2def parse_elements_buffed(process_info):3 buffs = dict()4 if process_info[0] != '0':5 buffs['elements buffed'] = buffs.get('elements buffed', []) + [6 elements[process_info[0]]]7 if process_info[1] != '0':8 buffs['elements buffed'] = buffs.get('elements buffed', []) + [9 elements[process_info[1]]]10 return buffs11def crit_elem_weakness(x):12 return float(x)*10013genders = {'0': 'genderless', '1': 'male', '2': 'female'}14ls_process_format = {15 '1': ((0, 'atk% buff', int, not_zero),16 (1, 'def% buff', int, not_zero),17 (2, 'rec% buff', int, not_zero),18 (3, 'crit% buff', int, not_zero),19 (4, 'hp% buff', int, not_zero)),20 '2': (parse_elements_buffed,21 (2, 'atk% buff', int, not_zero),22 (3, 'def% buff', int, not_zero),23 (4, 'rec% buff', int, not_zero),24 (5, 'crit% buff', int, not_zero),25 (6, 'hp% buff', int, not_zero)),26 '4': ((0, 'poison resist%', int, not_zero),27 (1, 'weaken resist%', int, not_zero),28 (2, 'sick resist%', int, not_zero),29 (3, 'injury resist%', int, not_zero),30 (4, 'curse resist%', int, not_zero),31 (5, 'paralysis resist%', int, not_zero)),32 '5': (([0, 1], lambda el: '%s resist%%' % elements[el], second_int),),33 '9': ((0, 'bc fill per turn', bb_gauge),),34 '10': ((0, 'hc effectiveness%', int),),35 '11': ((0, 'atk% buff', int, not_zero),36 (1, 'def% buff', int, not_zero),37 (2, 'rec% buff', int, not_zero),38 (3, 'crit% buff', int, not_zero),39 ([5, 4], lambda s: 'hp %s %% buff requirement' %40 ('above' if int(s) == 1 else 'below'), second_int, not_zero)),41 '14': ((0, 'dmg reduction%', int),42 (1, 'dmg reduction chance%', int)),43 '17': ((0, 'hp drain% low', int),44 (1, 'hp drain% high', int),45 (2, 'hp drain chance%', int)),46 '19': ((0, 'bc production%', int, not_zero),47 (1, 'hc production%', int, not_zero),48 (2, 'item production%', int, not_zero),49 (3, 'zel production%', int, not_zero),50 (4, 'karma production%', int, not_zero)),51 '20': (([0, 1], ailments.get, second_int, not_zero),52 ([2, 3], ailments.get, second_int, not_zero),53 ([4, 5], ailments.get, second_int, not_zero),54 ([6, 7], ailments.get, second_int, not_zero)),55 '21': ((0, 'first x turns atk%', int, not_zero),56 (1, 'first x turns def%', int, not_zero),57 (2, 'first x turns rec% GUESSED', int, not_zero),58 (3, 'first x turns crit% GUESSED', int, not_zero),59 (4, 'first x turns', int)),60 '23': ((0, 'battle end bc fill low', bb_gauge),61 (1, 'battle end bc fill high', bb_gauge)),62 '25': ((0, 'bc fill when attacked low', bb_gauge),63 (1, 'bc fill when attacked high', bb_gauge),64 (2, 'bc fill when attacked%', int)),65 '29': ((0, 'ignore def%', int),),66 '30': ((0, 'atk% buff', int, not_zero),67 (1, 'def% buff', int, not_zero),68 (2, 'rec% buff', int, not_zero),69 (3, 'crit% buff', int, not_zero),70 ([5, 4], lambda s: 'bb gauge %s %% buff requirement' %71 ('above' if int(s) == 1 else 'below'), int, not_zero)),72 '31': ((0, 'damage% for spark', int, not_zero),73 (1, 'bc drop% for spark', int, not_zero),74 (2, 'hc drop% for spark', int, not_zero),75 (3, 'item drop% for spark GUESSED', int, not_zero),76 (4, 'zel drop% for spark', int, not_zero),77 (5, 'karma drop% for spark', int, not_zero)),78 '32': ((0, 'bb gauge fill rate%', int),),79 '34': ((0, 'dmg% for crits', crit_elem_weakness),),80 '35': ((0, 'bc fill when attacking low', bb_gauge),81 (1, 'bc fill when attacking high', bb_gauge),82 (2, 'bc fill when attacking%', int)),83 '41': ((0, 'unique elements required', int),84 (1, 'atk% buff', int, not_zero),85 (2, 'def% buff', int, not_zero),86 (3, 'rec% buff', int, not_zero),87 (4, 'crit% buff', int, not_zero),88 (5, 'hp% buff', int, not_zero)),89 '42': ((0, 'gender required', lambda s: genders[s[0]]),90 (1, 'atk% buff', int, not_zero),91 (2, 'def% buff', int, not_zero),92 (3, 'rec% buff', int, not_zero),93 (4, 'crit% buff', int, not_zero),94 (5, 'hp% buff', int, not_zero)),95 '43': ((0, 'take 1 dmg%', int),),96 '48': ((0, 'reduced bb bc cost%', int),),97 '50': ((0, lambda el: '%s units do extra elemental weakness dmg' %98 elements[el], True, not_zero),99 (1, lambda el: '%s units do extra elemental weakness dmg' %100 elements[el], True, not_zero),101 (2, lambda el: '%s units do extra elemental weakness dmg' %102 elements[el], True, not_zero),103 (3, lambda el: '%s units do extra elemental weakness dmg' %104 elements[el], True, not_zero),105 (4, lambda el: '%s units do extra elemental weakness dmg' %106 elements[el], True, not_zero),107 (5, lambda el: '%s units do extra elemental weakness dmg' %108 elements[el], True, not_zero),109 (6, 'dmg% for elemental weakness', crit_elem_weakness)),110}111def parse_ls_process(process_type, process_info):112 if process_type in ls_process_format:113 return handle_format(ls_process_format[process_type],114 process_info.split(','))115 return {}116def parse_leader_skill(unit_data, leader_skill, dictionary):117 data = dict()118 data['name'] = dictionary.get(leader_skill[LS_NAME], leader_skill[LS_NAME])119 data['desc'] = dictionary.get(leader_skill[DESC], leader_skill[DESC])120 for process_type, process_info in zip(121 leader_skill[PROCESS_TYPE].split('@'),122 leader_skill[LS_PROCESS].split('@')):123 process_data = parse_ls_process(process_type, process_info)124 if 'elements buffed' in process_data and 'elements buffed' in data:125 data['elements buffed'] += process_data.pop('elements buffed')126 data.update(process_data)...

Full Screen

Full Screen

12100.py

Source:12100.py Github

copy

Full Screen

1import sys2import copy3def plus(boards, not_zero, r, c):4 if boards[r][c] != 0:5 if not_zero == [-1, -1]:6 not_zero = [r, c]7 elif boards[r][c] == boards[not_zero[0]][not_zero[1]]:8 boards[not_zero[0]][not_zero[1]] *= 29 boards[r][c] = 010 not_zero = [-1, -1]11 else:12 not_zero = [r, c]13 return boards, not_zero14def move(boards, d):15 if d % 2 == 0:16 if d == 0:17 r, c = 0, 018 while c < N:19 not_zero = [-1, -1]20 while r < N:21 boards, not_zero = plus(boards, not_zero, r, c)22 r += 123 c += 124 r = 025 elif d == 2:26 r, c = N-1, 027 while c < N:28 not_zero = [-1, -1]29 while r >= 0:30 boards, not_zero = plus(boards, not_zero, r, c)31 r -= 132 c += 133 r = N-134 new_boards = []35 for i in range(N):36 new_boards.append([row[i] for row in boards if row[i] != 0])37 if d == 0:38 new_boards[-1] += [0 for _ in range(N-len(new_boards[-1]))]39 else:40 new_boards[-1] = [0 for _ in range(N-len(new_boards[-1]))] + new_boards[-1]41 boards = [[] for _ in range(N)]42 for i in range(N):43 for j in range(N):44 boards[j % N].append(new_boards[i][j])45 elif d == 1:46 r, c = 0, 047 while r < N:48 not_zero = [-1, -1]49 while c < N:50 boards, not_zero = plus(boards, not_zero, r, c)51 c += 152 r += 153 c = 054 for r in range(N):55 boards[r] = list(filter(lambda x: x != 0, boards[r]))56 boards[r] += [0 for _ in range(N-len(boards[r]))]57 elif d == 3:58 r, c = 0, N-159 while r < N:60 not_zero = [-1, -1]61 while c >= 0:62 boards, not_zero = plus(boards, not_zero, r, c)63 c -=164 r += 165 c = N-166 for r in range(N):67 boards[r] = list(filter(lambda x: x != 0, boards[r]))68 boards[r] = [0 for _ in range(N-len(boards[r]))] + boards[r]69 return boards70def play(boards, rot_cnt, max_value):71 if rot_cnt >= 5:72 now_max = 073 for row in boards:74 now_max = max(now_max, max(row))75 max_value = max(now_max, max_value)76 else:77 direcitions = [[-1,0],[0,1],[1,0],[0,-1]]78 for d_idx in range(4):79 temp = copy.deepcopy(boards)80 temp = move(temp, d_idx)81 max_value = play(temp, rot_cnt + 1, max_value)82 return max_value83N = int(sys.stdin.readline())84boards = []85for _ in range(N):86 boards.append(list(map(int, sys.stdin.readline().split())))...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run hypothesis automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful