def fake_candidate(self): fake = Faker('es_MX') select = ( "SELECT electoral_key FROM user WHERE electoral_key NOT IN (SELECT electoral_key FROM voter) LIMIT 5" ) self.cursor.execute(select) candidates = self.cursor.fetchall() select = ("SELECT _id FROM party") self.cursor.execute(select) parties = self.cursor.fetchall() i = 0 for row in candidates: create_candidate = Candidate(self.connection, self.cursor) electoral_key = row[0] election_id = 2 party = parties[i][0] name = fake.first_name() middle_name = fake.first_name() flastname = fake.last_name() mlastname = fake.last_name() create_candidate.create(electoral_key, election_id, name, middle_name, flastname, mlastname, party) i += 1 return ('Ok')
def link(self, context, phrases): # link tags = self._entity_link(context) # assign tags to phrases linked_phrases = [] for phrase in phrases: # try to assign the phrase from the tagged output assigned_phrase = False for tag in tags: for tag_beg, tag_end in tag.offsets: if phrase.beg >= tag_end: intersect = phrase.beg - tag_beg < tag_end - tag_beg else: intersect = tag_beg - phrase.beg < phrase.end - phrase.beg if intersect: wiki_uri = self._find_wiki_uri(tag.uris) link = self._get_dbpedia_uri(wiki_uri, tag.uris) c = Candidate(tag.score, tag.text, link, wiki_uri, [], [], tag.uris, tag.text, tag.id) linked_phrases.append((phrase, c)) assigned_phrase = True # if nothing found assign to the phrase something still if not assigned_phrase: linked_phrases.append((phrase, Candidate())) return linked_phrases
def calculate(self): """Calculates the final winning candidate of the election and total vote counts for all candidates.""" winner = None # Allocate first preferences by moving ballots to candidates' counts for ballot in self.ballots: cand = Candidate.find_by_id(ballot.get_candidate()) cand.add_ballot(ballot) while winner is None: # Check if a winner exists by majority of votes for candidate in self.candidates: if candidate.vote_count() > self.turnout / 2: winner = candidate # Find and eliminate the candidate with the least votes last_candidate = sorted(self.candidates, key=Candidate.vote_count)[0] ballots_to_eliminate = last_candidate.get_ballots() print('eliminating {}'.format(ballots_to_eliminate)) for ballot in ballots_to_eliminate: # Update ballot's preferences to reflect the eliminated candidate ballot.eliminate() print(ballot) # Remove ballot from their votes last_candidate.remove_ballot(ballot) # Find the ballot's next preference and allocate the vote to them next_preference = Candidate.find_by_id(ballot.get_candidate()) next_preference.add_ballot(ballot)
def cross(self, parents): x1 = parents[0].weights x2 = parents[1].weights d = (x1 - x2) / 3 x3 = self.mutate(x1 + d) x4 = self.mutate(x1 - d) x5 = self.mutate(x2 + d) x6 = self.mutate(x2 - d) return sorted(self.judge_candidates([ parents[0], parents[1], Candidate(x3, portfolioUtilities.calculate_return(x3, self.returns), portfolioUtilities.calculate_std(x3, self.cov_matrix)), Candidate(x4, portfolioUtilities.calculate_return(x4, self.returns), portfolioUtilities.calculate_std(x4, self.cov_matrix)), Candidate(x5, portfolioUtilities.calculate_return(x5, self.returns), portfolioUtilities.calculate_std(x5, self.cov_matrix)), Candidate(x6, portfolioUtilities.calculate_return(x6, self.returns), portfolioUtilities.calculate_std(x6, self.cov_matrix)) ]), key=lambda x: x.expected_return, reverse=True)[:2]
def link(self, context, phrases): linked_phrases = [] context_vector = self._vectorizer.transform([context]) for phrase in phrases: try: dphrase = self._default_phrase(phrase) if dphrase in self._phrase2candidates: # get the candidates candidates = list( self._phrase2candidates[dphrase]) # to remove indices = [] for candidate in candidates: if candidate in self._candidate2index: indices.append(self._candidate2index[candidate]) else: print("Warning: candidate '{}' is not indexed". format(candidate)) indices.append( 0) # just to make sure lengths are equal dense_candidate_vectors = self._dense_vectors[indices] # check if candidates are correct print("Retrieved {} candidates for '{}'".format( len(indices), phrase.text)) dense_context_vector = self._get_dense_vector( context_vector, dphrase.text) # rank the candidates sims = dot(dense_candidate_vectors, dense_context_vector.T) if self._params["use_overlap"]: overlap_scores = zeros(sims.shape) for i, candidate in enumerate(candidates): overlap_scores[i] = overlap( candidate.name, phrase.text) else: overlap_scores = ones(sims.shape) scores = multiply(sims, overlap_scores) best_index = argmax(scores) best_candidate = candidates[best_index] best_candidate.score = scores[best_index] best_candidate.link = self._get_dbpedia_uri( best_candidate.wiki, best_candidate.uris) linked_phrases.append((phrase, best_candidate)) else: print( "Warning: phrase '{}' is not found in the vocabulary of the model" .format(phrase)) linked_phrases.append((phrase, Candidate())) except: print("Error while processing phrase '{}':") print(format_exc()) linked_phrases.append((phrase, Candidate())) return linked_phrases
def main(_): # create log dir but not used FLAGS.log_dir += "cifar/" FLAGS.log_dir += str(int(time.time())) if tf.gfile.Exists(FLAGS.log_dir): tf.gfile.DeleteRecursively(FLAGS.log_dir) tf.gfile.MakeDirs(FLAGS.log_dir) # read cifar10 dataset tr_data_cifar10, tr_label_cifar10, data_num_len_cifar10 = load_cifar10_data( ) # ceate inti candidates candidate = Candidate() # set your structurs here candidate.feature_layer_num = 3 candidate.feature_layer_array = [1, 0, 1] candidate.fc_layer_num = 0 candidate.module_num = 2 candidate.filter_num = 10 final_acc = train(tr_data_cifar10, tr_label_cifar10, data_num_len_cifar10, candidate, FLAGS.max_step) print("best structure avg_acc " + str(final_acc)) candidate.display_structure()
def read_candidate(): candidate = Candidate() candidate.name = input("Enter candidate first name and last name: ") candidate.title = input("Enter candidate latest title: ") candidate.address = input("Enter candidate address: ") candidate.phone = input("Enter candidate phone number: ") candidate.email = input("Enter candidate email address: ") candidate.hobbies = input("Enter candidates hobbies: ") choice = input("Add education? (y/n): ") if choice == "y": choice = "" while choice == "" or choice == "y": education = read_education() candidate.education.append(education) choice = input("Add additional education? (y/n): ") choice = input("Add experience? (y/n): ") if choice == "y": choice = "" while choice == "" or choice == "y": experience = read_experience() candidate.experience.append(experience) choice = input("Add additional experience? (y/n): ") choice = input("Add recruiter note (y/n): ") if choice == "y": note = read_note() candidate.note = note return candidate
def get_anaphoras(self): pronouns = self.get_pronouns() # code.interact(local=dict(globals(), **locals())) for pronoun in pronouns: anaphora = AnaphoraCandidates(pronoun) recent_count = 0 preceding_sentences = 0 pronoun_found = False first_sentence = True for sentence in self.sentences: if pronoun_found: preceding_sentences += 1 if preceding_sentences > 0: #pronoun already found, don't go further in th text. This is just anaphora. break for phrase in sentence.phrases.values(): # code.interact(local=dict(globals(), **locals())) if phrase.type == WordType.NOUN: at_least_one_found = False for word in phrase.words: word.pattern = sentence.get_colocation_pattern() if word.type == WordType.NOUN and anaphora.agrees( word): at_least_one_found = True reiteration = self.get_reiteration_count(word) self.compute_after_verb(word) distance = self.get_distance(pronoun, word) prev_word = self.get_previous_word(word) candidate = Candidate(word, first_sentence, reiteration, distance, recent_count, prev_word) anaphora.add_candidate(candidate) recent_count += 1 if not at_least_one_found: #no specific word agrees with pronoun, try whole phrase phrase.compute_phrase_gender_number() if anaphora.agrees(phrase): recent_count += 1 for word in phrase.words: if word.type == WordType.NOUN: reiteration = self.get_reiteration_count( word) self.compute_after_verb(word) distance = self.get_distance( pronoun, word) prev_word = self.get_previous_word( word) # candidate with multiple candidate = Candidate( word, first_sentence, reiteration, distance, recent_count, prev_word, True) anaphora.add_candidate(candidate) first_sentence = False self.anaphoras.append(anaphora)
def main(_): # clear save files shutil.rmtree(FLAGS.save_dir) os.mkdir(FLAGS.save_dir) shutil.rmtree("./tmp/") os.mkdir("./tmp/") #os.remove("/dataset/svhn/svhn_train.tfrecords") seed_network = Candidate() seed_network.set_empty_prefix() structure1 = task(data_set='cifar20', prefix_structure=seed_network) structure2 = task(data_set='cifar10', prefix_structure=structure1) structure3 = task(data_set='svhn', prefix_structure=structure2)
def main(_): # create log dir but not used FLAGS.log_dir += "cifar/" FLAGS.log_dir += str(int(time.time())) if tf.gfile.Exists(FLAGS.log_dir): tf.gfile.DeleteRecursively(FLAGS.log_dir) tf.gfile.MakeDirs(FLAGS.log_dir) # read cifar10 dataset # read cifar10 dataset tr_data_cifar10, tr_label_cifar10, data_num_len_cifar10, ts_data_cifar10, ts_label_cifar10, ts_num_len_cifar10 = load_cifar10_data( ) # # ceate inti candidates # candidate1 = Candidate() # # set your structurs here # candidate1.feature_layer_num = 3 # candidate1.feature_layer_array = [1, 0, 1] # candidate1.fc_layer_num = 0 # candidate1.module_num = 2 # candidate1.filter_num = 10 # compurtation_of_network_1 = candidate1.compurtation_of_network() # print("===========================================================") # print("compurtation_of_network_1 : " + str( )+ str(compurtation_of_network_1)) # final_acc = train(tr_data_cifar10, tr_label_cifar10, data_num_len_cifar10, candidate1, FLAGS.max_step) # print("best structure1 avg_acc "+ str(final_acc)) # candidate1.display_structure() # ceate inti candidates candidate2 = Candidate() # set your structurs here candidate2.feature_layer_num = 4 candidate2.feature_layer_array = [1, 0, 0, 0] candidate2.fc_layer_num = 1 candidate2.module_num = 4 candidate2.filter_num = 20 compurtation_of_network_2 = candidate2.compurtation_of_network() print("===========================================================") print("compurtation_of_network_2 : " + str() + str(compurtation_of_network_2)) final_acc = train(tr_data_cifar10, tr_label_cifar10, data_num_len_cifar10, ts_data_cifar10, ts_label_cifar10, ts_num_len_cifar10, candidate2, FLAGS.max_step) print("best structure2 avg_acc " + str(final_acc)) candidate2.display_structure()
def add_candidate(dbh, proto_id, params): db_proto = queryPrototype(dbh, proto_id) new_cand = Candidate( test_id=params["Test"], proto_id=proto_id, template_version="swfa_v1", jcl_version="swfa_v2", strategy_file="", strategy_name="", status="new", status_state="pending", bt_start_dt=db_proto.bt_start_dt, bt_end_dt=db_proto.bt_end_dt, ) dbh.add(new_cand) dbh.commit() updates = { "strategy_name": f"proto_{proto_id}_strat_{new_cand.id}", "wfa_file": f"cand_{new_cand.id}", } dbUpdateCandidate(dbh, new_cand.id, updates) add_candidate_settings(dbh, new_cand.id, proto_id, params) add_candidate_parameters(dbh, new_cand.id, proto_id, params) """
def read_candidates_from_file(file_name: str): candidate_list = [] with open(file_name, 'r') as f: contents = f.readlines() for i in contents: candidate_list.append(Candidate(i.replace('\n', ''))) return candidate_list
def gen_commit(self) -> bool: if self.node_id != self.get_next_block_node_id(): # logging.error("Node #{} tried to generate a commit, while it should have been generated by {}".format( # self.node_id, # self.get_next_block_node_id(), # )) return False # Create a new block. block = Block( block_id=self.get_next_block_id(), node_id=self.node_id, body="Block is generated by N{}.".format( self.node_id), # TODO: Replace with something meaningful. ) self.add_candidate(Candidate(block)) # Gen broadcast message. message = Message( node_id=self.node_id, message_type=Message.TYPE_COMMIT, block=block, ) self.broadcast(message) return True
def predict(self): """ Runs the neural network """ # Check if cached if self._face_candidates is None or not self._caching: # Run neural network results = self._net.detect(Image(self._image)) # Init lists self._face_candidates = [] # Go through results for out in results: # Get class id class_id = out[0] # Get confidence confidence = out[1] if confidence > self._confidence_threshold: # Get candidate position and size x, y, w, h = out[2] x = x - int(w // 2) y = y - int(h // 2) # Create candidate c = Candidate(int(x), int(y), int(w), int(h), confidence) # Append candidate to the right list depending on the class if class_id == b"face": self._face_candidates.append(c)
def __main__(): parser = OptionParser() parser.add_option("-t", "--train", dest="train", help="write report to FILE", metavar="FILE") parser.add_option("-a", "--algorithm", dest="algorithm", help="write report to FILE", metavar="FILE") parser.add_option("-u", "--url", dest="url", help="write report to FILE", metavar="FILE") options, arguments = parser.parse_args() algo_cls = get_algo_from_name(options.algorithm) if options.algorithm else DecisionTree detector = AuthorDetector(FeatureExtractor(), algo_cls) options.train = True # options.url = 'http://venturebeat.com/2013/05/19/biolite-stoves/' if options.train: sampler = SampleGenerator(urls_path='urls/small.txt') detector.train(sampler) # train from saved results # detector.train() detector.classifier.draw_tree(column_names=Candidate.get_labels()) if options.url: detector.train() # restore last training data detector.predict(options.url)
def assign_ballots_to_candidates(ballots: List[Ballot], candidate_names: str) -> Dict[str, Candidate]: candidates = {name: Candidate(name) for name in candidate_names} for ballot in ballots: top_candidate = get_highest_ranked_candidate(ballot) candidates[top_candidate].add_ballot(ballot) return candidates
def from_json(cls, filepath): """Instantiates an Election with candidates and ballots loaded from a local JSON file.""" with open(filepath) as file: filecontents = file.read() data = json.loads(filecontents) date = data['date'] type = data['type'] name = data['name'] enrolled = data['enrolled'] turnout = len(data['ballots']) # Number of votes received election = Election(date, type, name, enrolled, turnout) for candidate_dict in data['candidates']: candidate = Candidate( candidate_dict['id'], candidate_dict['name'], candidate_dict['party'] ) election.candidates.append(candidate) for preferences_list in data['ballots']: election.ballots.append(Ballot(preferences_list)) return election
def get_today(): # connect to snowflake. ret = [] conn = snowflake.connector.connect( user=config.get('api', 'user'), password=config.get('api', 'pwd'), account=config.get('api', 'account'), ) cur = conn.cursor() cur.execute("USE WAREHOUSE LOAD_WH") cur.execute("USE DATABASE PC_FIVETRAN_DB") cur.execute("USE SCHEMA GREENHOUSE") # execute sql with today_ish's date # sql = config.get('sql', 'todays_applications').format('2019-11-01') today_ish = (datetime.date.today() - datetime.timedelta(days=7)).strftime('%Y-%m-%d') sql = config.get('sql', 'todays_applications').format(today_ish) logging.info('greenhouse query %s', sql) cur.execute(sql) # return candidates in a list of objects to decouple data storage implementation from the rest of the app. for (ID, CANDIDATE_ID, FIRST_NAME, LAST_NAME, APPLIED_AT, COMPANY, TITLE, JOB_NAME, FILE_NAME, RESUME_URL) \ in cur: ret.append( Candidate(ID, CANDIDATE_ID, FIRST_NAME, LAST_NAME, APPLIED_AT, COMPANY, TITLE, JOB_NAME, FILE_NAME, RESUME_URL)) cur.close() return ret
def get_smartlist_ids_in_talent_pools(cls, user_id, talentpool_names=None): """ This returns smartlist Ids in a pipeline which is in specified talentpool :param positive user_id: User Id :param list|None talentpool_names: Talent pool names :rtype: list """ talent_pools = TalentPool.get_by_user_id_and_name( user_id, talentpool_names) talent_pool_ids = [talent_pool.id for talent_pool in talent_pools ] # Extracting data on 0th index from tuple candidate_ids = TalentPoolCandidate.query.with_entities(TalentPoolCandidate.candidate_id). \ filter(TalentPoolCandidate.talent_pool_id.in_(talent_pool_ids)).distinct().all() """ candidate_ids is a list of tuple [(358L,), (1005L,), (1054L,), (1055L,)] when we zip it "zip(*candidate_ids)". It makes pairs of 1st-to-1st and 2nd-to-2nd elements of tuples. Since second element is empty so it gets skipped and candidate_ids changes into [(358L, 1005L, 1054L, 1055L)] And then we use * to extract elements of list of tuple and pass them to list() function and receive [358L, 1005L, 1054L, 1055L] """ candidate_ids = list(*zip(*candidate_ids)) # Converting tuple to list candidates = Candidate.get_by_id(candidate_ids, False) candidate_ids = [candidate.id for candidate in candidates] smartlist_ids = SmartlistCandidate.query.with_entities(SmartlistCandidate.smartlist_id). \ filter(SmartlistCandidate.candidate_id.in_(candidate_ids)).distinct().all() smartlist_ids = [smartlist_id[0] for smartlist_id in smartlist_ids ] # Extracting data on 0th index from tuple # Checking if any of the selected smartlists is hidden smartlists = Smartlist.get_by_ids(smartlist_ids, False) smartlist_ids = [smartlist.id for smartlist in smartlists] return smartlist_ids
def generate_solutions(self): solutions = [] best_solution = [] best_return = float("-inf") best_std = 0 seed = 42 counter = 0 attempts = 0 while counter < self.num_solutions and attempts < 1000: random.seed(seed) seed += 1 weights = self.generate_random_weights() solution = Candidate( weights, portfolioUtilities.calculate_return(weights, self.returns), portfolioUtilities.calculate_std(weights, self.cov_matrix)) if (solution.std <= self.max_risk): attempts = 0 counter += 1 solutions.append(solution) if (solution.expected_return > best_return): best_return = solution.expected_return best_solution = solution best_std = solution.std else: attempts += 1 return solutions, best_solution, best_return, best_std
def pop_initialise(population_size, candidate_length): population = [] for i in range(population_size): value = np.random.randint(2, size=[candidate_length]) population.append(Candidate(candidate_length, value=value)) return np.array(population)
def setUp(self): dict = Dictionary() state = Follower() self.node = Node(0, state, [], dict, []) dict2 = Dictionary() state2 = Candidate() self.node2 = Node(1, state2, [], dict2, [self.node]) self.node2.neighbors.append(self.node2)
def load_cands(cand_fname, sncut=10): if cand_fname is None: return [] lines = filter(lambda x: len(x) > 0, map(str.strip, file(cand_fname).readlines())) cands = [Candidate(line) for line in lines] cands = filter(lambda c: c.sn >= sncut, cands) return sorted(cands, key=lambda c: c.i0)
def main(): # Will hold all candidates and respective skills... skills_dict = {} all_candidates = [] # Reads CSV and creates dictionary of technical skills and their skills type. with open('../techskills.csv', 'r') as ts: for skill in ts: line = skill.split(',') skills_dict[line[1].replace('\r\n', '')] = line[0] del skills_dict[''] # Parse each candidate's resume. for f in os.listdir('uploads'): if f != '.DS_Store': # Convert to raw text; Store information text = convert(f) name = extract_name(text).rstrip() text = text.lower().replace(',', '') sites = re.findall('https?://(?:[-\w.]|(?:%[\da-fA-F]{2}))+', text) if not sites: sites = ['N/A'] c = Candidate(name, sites[0], re.findall('\S+@\S+', text)[0], extract_skills(skills_dict, text), random.randint(0, 100)) # Add new candidate to list all_candidates.append(c) # Sort candidates all_candidates.sort(key=lambda x: x.get_score(), reverse=True) # Print candidate information... for candidate in all_candidates: print '<p id="rcorners2">' print '<b>Name: </b>' + candidate.get_name() + '<br>' # Grab website url and email address site = candidate.get_site() mail = candidate.get_email() # Configure email print '<b>Email: </b><a href="mailto:' + mail + \ '" target="_blank">' + mail + '</a><br>' if site == 'N/A': print '<b>Site: </b>' + site + '<br>' else: print '<b>Site: </b><a href="' + site + '" target="_blank">' + site + '<a><br>' print '<b>Technical skills:</b>' print candidate.get_skills() print '<br><b>Match: </b>' + \ str(candidate.get_score()) + '%<br></p><br><br>' # Clear directory myutils.cleardir()
def getCandidates(self): candidates = self.fileHandler.readLine() candidateNames = candidates.split(",") for candidateName in candidateNames: candidateName = candidateName.strip() cName = candidateName[:-3] cParty = candidateName[-2] candidateInstance = Candidate(cName, cParty) self.candidates[cName] = candidateInstance self.candidateNames.append(cName)
def index(): if request.method == "POST": new_candidate = Candidate( request.form['cnc-c-name-input'], request.form['cnc-c-age-input'], request.form['cnc-c-language-input']) CANDIDATES.append(new_candidate) print(new_candidate) return redirect(url_for("index")) return render_template('index.html', Candidate=CANDIDATES)
def read_candidate(): name = input('name = ') surname = input('surname = ') middle_name = input('middle name = ') birthdate = input('birthdate (Y-m-d) = ') district_num = int(input('district_nummber = ')) people_count = int(input('people_count = ')) voters_count = int(input('voters_count = ')) party = input('paty = ') return Candidate(name, surname, middle_name, birthdate, district_num, people_count, voters_count, party)
def generate_candidates(self, nr): rnd_fn = self.generate_first_names(nr) rnd_ln = self.generate_last_names(nr) result = [] for x in range(nr): experience = self.generate_experience(random.randint(1, 4), False) candidate = Candidate(rnd_fn[x], rnd_ln[x], experience) result.append(candidate) return [cand.serialize() for cand in result]
def dispersythread_data_came_in(self, packets, timestamp): # iterator = ((self._dispersy.get_candidate(sock_addr), data.startswith(TUNNEL_PREFIX), sock_addr, data) for sock_addr, data in packets) # self._dispersy.on_incoming_packets([(candidate if candidate else self._dispersy.create_candidate(WalkCandidate, sock_addr, tunnel), data[4:] if tunnel else data) # for candidate, tunnel, sock_addr, data # in iterator], # True, # timestamp) iterator = ((data.startswith(TUNNEL_PREFIX), sock_addr, data) for sock_addr, data in packets) self._dispersy.on_incoming_packets( [(Candidate(sock_addr, tunnel), data[4:] if tunnel else data) for tunnel, sock_addr, data in iterator], True, timestamp)
def link(self, context, phrases): linked_phrases = list() for phrase in phrases: score, predicted_url = self.evaluator.get_random_pred(context, phrase) c = Candidate(score=score, link=predicted_url) linked_phrases.append((phrase, c)) return linked_phrases
class TestCandidate(unittest.TestCase): def setUp(self): self.enough_year = Candidate( 2, 499, ["Ruby", "Python"], False, 15) self.enough_github = Candidate( 1, 500, ["Ruby", "Python"], False, 15) self.no_year_github = Candidate( 1, 499, ["Ruby", "Python"], False, 15) self.no_python = Candidate( 2, 499, ["Ruby"], False, 15) self.applied = Candidate( 1, 500, ["Python"], True, 15) self.no_age = Candidate( 2, 499, ["Python"], False, 14) def tearDown(self): pass def test_candidate(self): self.assertTrue(self.enough_year.experienced_programmer()) self.assertTrue(self.enough_github.experienced_programmer()) self.assertFalse(self.no_year_github.experienced_programmer()) self.assertFalse(self.no_python.experienced_programmer()) self.assertFalse(self.applied.experienced_programmer()) self.assertFalse(self.no_age.experienced_programmer())
def link(self, context, phrases): linked_phrases = list() #file = open('/Users/sevgili/Desktop/context-phrase-nif.txt', 'a') for phrase in phrases: #file.write(str(context) + '\t' + str(phrase.text) + '\t' + str(phrase.beg) + '\t' + str(phrase.end) + '\n') score, predicted_url = self.evaluator.get_best_pred(context, phrase) print('******', context, phrase, score, predicted_url) c = Candidate(score=score, link=predicted_url) linked_phrases.append((phrase, c)) return linked_phrases
def setUp(self): self.enough_year = Candidate( 2, 499, ["Ruby", "Python"], False, 15) self.enough_github = Candidate( 1, 500, ["Ruby", "Python"], False, 15) self.no_year_github = Candidate( 1, 499, ["Ruby", "Python"], False, 15) self.no_python = Candidate( 2, 499, ["Ruby"], False, 15) self.applied = Candidate( 1, 500, ["Python"], True, 15) self.no_age = Candidate( 2, 499, ["Python"], False, 14)
def add_candidate(self, first_name, last_name): cand = Candidate(first_name, last_name, []) self.CANDIDATES.append(cand.serialize()) return str(cand.id)
def __init__(self, line, field, match, generator_id, num, label_line): """Store the label line and call parent constructor.""" self.label_line = label_line Candidate.__init__(self, line, field, match, generator_id, num)