How to use add_category method in hypothesis

Best Python code snippet using hypothesis

income.py

Source:income.py Github

copy

Full Screen

...145 nb.add_response(negative) # <=50K146 nb.add_response(positive) # >50K147 num_of_responses = 2148 age = Feature("age", num_of_responses)149 age.add_category("0") # <=20150 age.add_category("1") # 21-25151 age.add_category("2") # 26-30152 age.add_category("3") # 31-35153 age.add_category("4") # 36-40154 age.add_category("5") # 41-45155 age.add_category("6") # 46-50156 age.add_category("7") # 51-55157 age.add_category("8") # 56-60158 age.add_category("9") # 61-65159 age.add_category("10") # 66+160 nb.add_feature(age)161 workclass = Feature("workclass", num_of_responses)162 workclass.add_category("Private")163 workclass.add_category("Self-emp-not-inc")164 workclass.add_category("Self-emp-inc")165 workclass.add_category("Federal-gov")166 workclass.add_category("Local-gov")167 workclass.add_category("State-gov")168 workclass.add_category("Without-pay")169 workclass.add_category("Never-worked")170 nb.add_feature(workclass)171 education = Feature("education", num_of_responses)172 education.add_category("Bachelors")173 education.add_category("Some-college")174 education.add_category("11th")175 education.add_category("HS-grad")176 education.add_category("Prof-school")177 education.add_category("Assoc-acdm")178 education.add_category("Assoc-voc")179 education.add_category("9th")180 education.add_category("7th-8th")181 education.add_category("12th")182 education.add_category("Masters")183 education.add_category("1st-4th")184 education.add_category("10th")185 education.add_category("Doctorate")186 education.add_category("5th-6th")187 education.add_category("Preschool")188 nb.add_feature(education)189 marital_status = Feature("marital_status", num_of_responses)190 marital_status.add_category("Married-civ-spouse")191 marital_status.add_category("Divorced")192 marital_status.add_category("Never-married")193 marital_status.add_category("Separated")194 marital_status.add_category("Widowed")195 marital_status.add_category("Married-spouse-absent")196 marital_status.add_category("Married-AF-spouse")197 nb.add_feature(marital_status)198 occupation = Feature("occupation", num_of_responses)199 occupation.add_category("Tech-support")200 occupation.add_category("Craft-repair")201 occupation.add_category("Other-service")202 occupation.add_category("Sales")203 occupation.add_category("Exec-managerial")204 occupation.add_category("Prof-specialty")205 occupation.add_category("Handlers-cleaners")206 occupation.add_category("Machine-op-inspct")207 occupation.add_category("Adm-clerical")208 occupation.add_category("Farming-fishing")209 occupation.add_category("Transport-moving")210 occupation.add_category("Priv-house-serv")211 occupation.add_category("Protective-serv")212 occupation.add_category("Armed-Forces")213 nb.add_feature(occupation)214 relationship = Feature("relationship", num_of_responses)215 relationship.add_category("Wife")216 relationship.add_category("Own-child")217 relationship.add_category("Husband")218 relationship.add_category("Not-in-family")219 relationship.add_category("Other-relative")220 relationship.add_category("Unmarried")221 nb.add_feature(relationship)222 race = Feature("race", num_of_responses)223 race.add_category("White")224 race.add_category("Asian-Pac-Islander")225 race.add_category("Amer-Indian-Eskimo")226 race.add_category("Other")227 race.add_category("Black")228 nb.add_feature(race)229 sex = Feature("sex", num_of_responses)230 sex.add_category("Female")231 sex.add_category("Male")232 nb.add_feature(sex)233 hours_per_week = Feature("hours_per_week", num_of_responses)234 hours_per_week.add_category("0") # <5235 hours_per_week.add_category("1") # 5-14236 hours_per_week.add_category("2") # 15-24237 hours_per_week.add_category("3") # 25-34238 hours_per_week.add_category("4") # 35-44239 hours_per_week.add_category("5") # 45-54240 hours_per_week.add_category("6") # 55-64241 hours_per_week.add_category("7") # 65-74242 hours_per_week.add_category("8") # 75-84243 hours_per_week.add_category("9") # 85-94244 hours_per_week.add_category("10") # 95+245 nb.add_feature(hours_per_week)...

Full Screen

Full Screen

mushroom.py

Source:mushroom.py Github

copy

Full Screen

...39 nb.add_response(negative) # poisonous/unknown edibility/not recommended40 nb.add_response(positive) # edible41 num_of_responses = 242 cap_shape = Feature("cap_shape", num_of_responses)43 cap_shape.add_category("b") # bell44 cap_shape.add_category("c") # conical45 cap_shape.add_category("x") # convex46 cap_shape.add_category("f") # flat47 cap_shape.add_category("k") # knobbed48 cap_shape.add_category("s") # sunken49 nb.add_feature(cap_shape)50 cap_surface = Feature("cap_surface", num_of_responses)51 cap_surface.add_category("f") # fibrous52 cap_surface.add_category("g") # grooves53 cap_surface.add_category("y") # scaly54 cap_surface.add_category("s") # smooth55 nb.add_feature(cap_surface)56 cap_color = Feature("cap_color", num_of_responses)57 cap_color.add_category("n") # brown58 cap_color.add_category("b") # buff59 cap_color.add_category("c") # cinnamon60 cap_color.add_category("g") # gray61 cap_color.add_category("r") # green62 cap_color.add_category("p") # pink63 cap_color.add_category("u") # purple64 cap_color.add_category("e") # red65 cap_color.add_category("w") # white66 cap_color.add_category("y") # yellow67 nb.add_feature(cap_color)68 bruises = Feature("bruises", num_of_responses)69 bruises.add_category("t") # bruises70 bruises.add_category("f") # no bruises71 nb.add_feature(bruises)72 odor = Feature("odor", num_of_responses)73 odor.add_category("a") # almond74 odor.add_category("l") # anise75 odor.add_category("c") # creosote76 odor.add_category("y") # fishy77 odor.add_category("f") # foul78 odor.add_category("m") # musty79 odor.add_category("n") # none80 odor.add_category("p") # pungent81 odor.add_category("s") # spicy82 nb.add_feature(odor)83 gill_attachment = Feature("gill_attachment", num_of_responses)84 gill_attachment.add_category("a") # attached85 gill_attachment.add_category("d") # descending86 gill_attachment.add_category("f") # free87 gill_attachment.add_category("n") # notched88 nb.add_feature(gill_attachment)89 gill_spacing = Feature("gill_spacing", num_of_responses)90 gill_spacing.add_category("c") # close91 gill_spacing.add_category("w") # crowded92 gill_spacing.add_category("d") # distant93 nb.add_feature(gill_spacing)94 gill_size = Feature("gill_size", num_of_responses)95 gill_size.add_category("b") # broad96 gill_size.add_category("n") # narrow97 nb.add_feature(gill_size)98 gill_color = Feature("gill_color", num_of_responses)99 gill_color.add_category("k") # black100 gill_color.add_category("n") # brown101 gill_color.add_category("b") # buff102 gill_color.add_category("h") # chocolate103 gill_color.add_category("g") # gray104 gill_color.add_category("r") # green105 gill_color.add_category("o") # orange106 gill_color.add_category("p") # pink107 gill_color.add_category("u") # purple108 gill_color.add_category("e") # red109 gill_color.add_category("w") # white110 gill_color.add_category("y") # yellow111 nb.add_feature(gill_color)112 stalk_shape = Feature("stalk_shape", num_of_responses)113 stalk_shape.add_category("e") # enlarging114 stalk_shape.add_category("t") # tapering115 nb.add_feature(stalk_shape)116 stalk_root = Feature("stalk_root", num_of_responses)117 stalk_root.add_category("b") # bulbous118 stalk_root.add_category("c") # club119 stalk_root.add_category("u") # cup120 stalk_root.add_category("e") # equal121 stalk_root.add_category("z") # rhizomorphs122 stalk_root.add_category("r") # rooted123 stalk_root.add_category("?") # missing124 nb.add_feature(stalk_root)125 stalk_surface_above_ring = Feature("stalk_surface_above_ring", num_of_responses)126 stalk_surface_above_ring.add_category("f") # fibrous127 stalk_surface_above_ring.add_category("y") # scaly128 stalk_surface_above_ring.add_category("k") # silky129 stalk_surface_above_ring.add_category("s") # smooth130 nb.add_feature(stalk_surface_above_ring)131 stalk_surface_below_ring = Feature("stalk_surface_below_ring", num_of_responses)132 stalk_surface_below_ring.add_category("f") # fibrous133 stalk_surface_below_ring.add_category("y") # scaly134 stalk_surface_below_ring.add_category("k") # silky135 stalk_surface_below_ring.add_category("s") # smooth136 nb.add_feature(stalk_surface_below_ring)137 stalk_color_above_ring = Feature("stalk_color_above_ring", num_of_responses)138 stalk_color_above_ring.add_category("n") # brown139 stalk_color_above_ring.add_category("b") # buff140 stalk_color_above_ring.add_category("c") # cinnamon141 stalk_color_above_ring.add_category("g") # gray142 stalk_color_above_ring.add_category("o") # orange143 stalk_color_above_ring.add_category("p") # pink144 stalk_color_above_ring.add_category("e") # red145 stalk_color_above_ring.add_category("w") # white146 stalk_color_above_ring.add_category("y") # yellow147 nb.add_feature(stalk_color_above_ring)148 stalk_color_below_ring = Feature("stalk_color_below_ring", num_of_responses)149 stalk_color_below_ring.add_category("n") # brown150 stalk_color_below_ring.add_category("b") # buff151 stalk_color_below_ring.add_category("c") # cinnamon152 stalk_color_below_ring.add_category("g") # gray153 stalk_color_below_ring.add_category("o") # orange154 stalk_color_below_ring.add_category("p") # pink155 stalk_color_below_ring.add_category("e") # red156 stalk_color_below_ring.add_category("w") # white157 stalk_color_below_ring.add_category("y") # yellow158 nb.add_feature(stalk_color_below_ring)159 veil_type = Feature("veil_type", num_of_responses)160 veil_type.add_category("p") # partial161 veil_type.add_category("u") # universal162 nb.add_feature(veil_type)163 veil_color = Feature("veil_color", num_of_responses)164 veil_color.add_category("n") # brown165 veil_color.add_category("o") # orange166 veil_color.add_category("w") # white167 veil_color.add_category("y") # yellow168 nb.add_feature(veil_color)169 ring_number = Feature("ring_number", num_of_responses)170 ring_number.add_category("n") # none171 ring_number.add_category("o") # one172 ring_number.add_category("t") # two173 nb.add_feature(ring_number)174 ring_type = Feature("ring_type", num_of_responses)175 ring_type.add_category("c") # cobwebby176 ring_type.add_category("e") # evanescent177 ring_type.add_category("f") # flaring178 ring_type.add_category("l") # large179 ring_type.add_category("n") # none180 ring_type.add_category("p") # pendant181 ring_type.add_category("s") # sheathing182 ring_type.add_category("z") # zone183 nb.add_feature(ring_type)184 spore_print_color = Feature("spore_print_color", num_of_responses)185 spore_print_color.add_category("k") # black186 spore_print_color.add_category("n") # brown187 spore_print_color.add_category("b") # buff188 spore_print_color.add_category("h") # chocolate189 spore_print_color.add_category("r") # green190 spore_print_color.add_category("o") # orange191 spore_print_color.add_category("u") # purple192 spore_print_color.add_category("w") # white193 spore_print_color.add_category("y") # yellow194 nb.add_feature(spore_print_color)195 population = Feature("population", num_of_responses)196 population.add_category("a") # abundant197 population.add_category("c") # clustered198 population.add_category("n") # numerous199 population.add_category("s") # scattered200 population.add_category("v") # several201 population.add_category("y") # solitary202 nb.add_feature(population)203 habitat = Feature("habitat", num_of_responses)204 habitat.add_category("g") # grasses205 habitat.add_category("l") # leaves206 habitat.add_category("m") # meadows207 habitat.add_category("p") # paths208 habitat.add_category("u") # urban209 habitat.add_category("w") # waste210 habitat.add_category("d") # woods211 nb.add_feature(habitat)...

Full Screen

Full Screen

scores.py

Source:scores.py Github

copy

Full Screen

...11 self.points = points12 self.categories = {}13 self.lcategories = []14 15 def add_category(self, cid, name, points):16 self.categories[cid] = (name, points)17 self.lcategories.append(cid)18 19PROJ_1A = Project("Project 1a", 50) 20PROJ_1B = Project("Project 1b", 100) 21PROJ_1C = Project("Project 1c", 100) 22PROJECTS = [PROJ_1A, PROJ_1B, PROJ_1C]23PROJ_1A.add_category("BASIC_CONNECTION", "Basic Connection", 50)24PROJ_1B.add_category("CONNECTION_REGISTRATION", "Connection Registration", 40)25PROJ_1B.add_category("PRIVMSG_NOTICE", "PRIVMSG and NOTICE", 30)26PROJ_1B.add_category("PING_PONG", "PING and PONG", 2.5)27PROJ_1B.add_category("MOTD", "MOTD", 5) 28PROJ_1B.add_category("LUSERS", "LUSERS", 10)29PROJ_1B.add_category("WHOIS", "WHOIS", 10)30PROJ_1B.add_category("ERR_UNKNOWN", "ERR_UNKNOWN", 2.5)31PROJ_1B.add_category("ROBUST", "Robustness", 0)32 33PROJ_1C.add_category("CHANNEL_JOIN", "JOIN", 15)34PROJ_1C.add_category("CHANNEL_PRIVMSG_NOTICE", "PRIVMSG and NOTICE to channels", 15)35PROJ_1C.add_category("CHANNEL_PART", "PART", 10)36PROJ_1C.add_category("CHANNEL_TOPIC", "TOPIC", 10)37PROJ_1C.add_category("MODES", "User and channel modes", 25)38PROJ_1C.add_category("AWAY", "AWAY", 5)39PROJ_1C.add_category("NAMES", "NAMES", 5)40PROJ_1C.add_category("LIST", "LIST", 5)41PROJ_1C.add_category("WHO", "WHO", 5)...

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