def setup_inst(): instlist =[] for qualty in [100,20,90,80,50,30,40,10,70,60]: name = Inst() name.quality = qualty name.observed_1 = 1 name.observed_2 = 1.25 name.name = 'i'+str(qualty) instlist.append(name) return instlist
def setup_inst(): instlist = [] for qualty in [100, 20, 90, 80, 50, 30, 40, 10, 70, 60]: name = Inst() name.quality = qualty name.observed_1 = 1 name.observed_2 = 1.25 name.name = 'i' + str(qualty) instlist.append(name) return instlist
def __init__(self, name, infec_prob=0.0, posn=(0, 0, 0, 0), door_posns=[], opening_time=0, closing_time=0): Institution.__init__(self, name, infec_prob, posn) self.door_posns = door_posns self.opening_time = opening_time self.closing_time = closing_time self.classrooms = []
def test_lawInstitution_fields(): # Verify, upon instantiation, that all fields of the law and institution # classes are of the type they should be. society = Society(population_size=10) institution = Institution(society) laws = institution._generate_laws(society) assert isinstance(institution.get_affiliation(), float) for law in laws: for person_id in range(society.population_size): assert isinstance(law.affected_persons[person_id], int) assert isinstance(law.mean, float) assert isinstance(law.law_type, str) assert isinstance(law.actual_value, float)
def read_institutions(program:str): db = dfsapi.get_db() institutions = list() keys = db.child(program).child("institutions").shallow().get() if keys.val() == None: return False recentdb = max(keys.val()) data = db.child(program).child("institutions").child(recentdb).get() for i in data.each(): institution = i.val() Name = institution["Name"] Address = institution["Address"] County = institution["County"] Instructors = institution["Instructors"] Schedule = manageinstructors.schedule_to_dict(institution["Schedule"]) institutions.append(Institution(Name, Address, County, Instructors, Schedule)) return institutions
def from_config(c): institution = Institution.from_config(Settings.banks(c['institution'])) return Account( institution = institution, guid = c['guid'], description = c['description'], routing_number = c['routing_number'], account_type = c['account_type'], broker_id = c['broker_id'] )
def make_institution_list(info: dict, program: str): institutions = list() for school in info: new_schedule = schedule_to_dict(info[school]['Schedule']) institutions.append( Institution(info[school]['Name'], info[school]['Address'], info[school]['County'], info[school]['Instructors'], new_schedule)) return institutions
def get_or_create_placeholder_institution(): display_name = 'placeholder, see prepared_demo_publisher.py' institution = Institution.query.filter( Institution.display_name == display_name).scalar() if not institution: institution = Institution(display_name=display_name, is_consortium=False, is_demo_institution=True) db.session.add(institution) return institution
def add_institution(institution_name, old_username, ror_id_list, is_consortium=False): logger.info(u"initializing institution {}".format(institution_name)) my_institutions = db.session.query(Institution).filter( Institution.display_name == institution_name, Institution.id.notlike('%jisc%')).all() if my_institutions: my_institution = my_institutions[0] logger.info( u" *** using existing institution {} ***".format(my_institution)) if is_consortium: print "SETTING UP AS A CONSORTIUM ACCOUNT" else: my_institution = Institution() my_institution.display_name = institution_name my_institution.old_username = old_username my_institution.is_demo_institution = False my_institution.is_consortium = is_consortium db.session.add(my_institution) logger.info(u" adding {}".format(my_institution)) if not ror_id_list: return for ror_id in ror_id_list: add_ror(ror_id, my_institution.id)
def test_Proposed_applicant_1(self): """Proposed_applicant_1: Institution has room (is not filled) accepts applicant """ apps = setup_app() #setup institution inst = Inst() inst.matched_to = [apps[5], apps[3]] #inst.rank_list = apps Next line takes care of this inst.inst_rank_app(apps) inst.bumped_applicants = [apps[1]] inst.ranked_to_low = [] inst.openings = 5 results = inst.Proposed_applicant(apps[6]) self.assertEqual( (results[0] and results[1] is None), True, 'There was room, applicant should have been accepted' + str(results[0]) + ' ' + str(results[1]))
def test_Proposed_applicant_3(self): """Proposed_applicant_3: Institution is filled applicant can NOT bump """ apps = setup_app() #setup institution inst = Inst() #inst.rank_list = apps Next line takes care of this inst.inst_rank_app(apps) inst.matched_to = [ inst.rank_list[0], inst.rank_list[1], inst.rank_list[2], inst.rank_list[3] ] inst.bumped_applicants = [inst.rank_list[9]] inst.ranked_to_low = [] inst.openings = 4 results = inst.Proposed_applicant(inst.rank_list[4]) self.assertEqual((not (results[0]) and results[1] is None), True, ('Applicant should have matched ' + str(results[0]) + ' ' + str(results[1])))
def test_Proposed_applicant_2(self): """Proposed_applicant_2: Institution is filled applicant can bump lowest ranked applicant """ apps = setup_app() #setup institution inst = Inst() #inst.rank_list = apps Next line takes care of this inst.inst_rank_app(apps) inst.matched_to = [ inst.rank_list[0], inst.rank_list[2], inst.rank_list[4], inst.rank_list[6] ] inst.bumped_applicants = [inst.rank_list[9]] inst.ranked_to_low = [] inst.openings = 4 results = inst.Proposed_applicant(inst.rank_list[1]) self.assertEqual((results[0] and results[1] == inst.rank_list[6]), True, 'Applicant should have bumped a10 ' + str(results[0]) + ' ' + str(results[1].name))
def test_interview_few(self): """ Interview selection Test 1: , number that apply < number to interview """ inst = Inst() inst.quality = 50 inst.number_to_interview = 10 inst.applied = setup_app()[:5] inst.interview() desired = {'a20', 'a90', 'a100', 'a50', 'a80'} actual = set([app.name for app in inst.invite_interview]) self.assertEqual(desired, actual, 'desired '+str(desired)+' != '+ 'Actual '+str(actual))
def test_Proposed_applicant_1(self): """Proposed_applicant_1: Institution has room (is not filled) accepts applicant """ apps = setup_app() #setup institution inst = Inst() inst.matched_to = [apps[5], apps[3]] #inst.rank_list = apps Next line takes care of this inst.inst_rank_app(apps) inst.bumped_applicants = [apps[1]] inst.ranked_to_low = [] inst.openings = 5 results = inst.Proposed_applicant(apps[6]) self.assertEqual((results[0] and results[1] is None), True, 'There was room, applicant should have been accepted' + str(results[0]) + ' ' + str(results[1]))
def test_Proposed_applicant_3(self): """Proposed_applicant_3: Institution is filled applicant can NOT bump """ apps = setup_app() #setup institution inst = Inst() #inst.rank_list = apps Next line takes care of this inst.inst_rank_app(apps) inst.matched_to = [inst.rank_list[0], inst.rank_list[1], inst.rank_list[2], inst.rank_list[3]] inst.bumped_applicants = [inst.rank_list[9]] inst.ranked_to_low = [] inst.openings = 4 results = inst.Proposed_applicant(inst.rank_list[4]) self.assertEqual((not(results[0]) and results[1] is None), True, ('Applicant should have matched '+ str(results[0]) + ' ' +str(results[1])))
def test_interview_few(self): """ Interview selection Test 1: , number that apply < number to interview """ inst = Inst() inst.quality = 50 inst.number_to_interview = 10 inst.applied = setup_app()[:5] inst.interview() desired = {'a20', 'a90', 'a100', 'a50', 'a80'} actual = set([app.name for app in inst.invite_interview]) self.assertEqual( desired, actual, 'desired ' + str(desired) + ' != ' + 'Actual ' + str(actual))
def read_institutions(program: str): db = dfsapi.get_db() institutions = list() keys = db.child(program).child("institutions").shallow().get() recentdb = max(keys.val()) data = db.child(program).child("institutions").child(recentdb).get() for i in data.each(): institution = i.val() Name = institution["Name"] Address = institution["Address"] County = institution["County"] Program = institution["Program"] Instructors = institution["Instructors"] Mon = dbtools.minute_range(institution["Monday"]) Tue = dbtools.minute_range(institution["Tuesday"]) Wed = dbtools.minute_range(institution["Wednesday"]) Thurs = dbtools.minute_range(institution["Thursday"]) Fri = dbtools.minute_range(institution["Friday"]) Schedule = defaultdict(list) if Mon != None: Schedule[1].append(Mon) if Tue != None: Schedule[2].append(Tue) if Wed != None: Schedule[3].append(Wed) if Thurs != None: Schedule[4].append(Thurs) if Fri != None: Schedule[5].append(Fri) institutions.append( Institution(Name, Address, County, Program, Instructors, Schedule)) return institutions
def test_Proposed_applicant_2(self): """Proposed_applicant_2: Institution is filled applicant can bump lowest ranked applicant """ apps = setup_app() #setup institution inst = Inst() #inst.rank_list = apps Next line takes care of this inst.inst_rank_app(apps) inst.matched_to = [inst.rank_list[0], inst.rank_list[2], inst.rank_list[4], inst.rank_list[6]] inst.bumped_applicants = [inst.rank_list[9]] inst.ranked_to_low = [] inst.openings = 4 results = inst.Proposed_applicant(inst.rank_list[1]) self.assertEqual((results[0] and results[1]==inst.rank_list[6]), True, 'Applicant should have bumped a10 '+ str(results[0]) + ' ' +str(results[1].name))
def test_inst_rank_app(self): """ Rank selection Test 1: """ inst = Inst() inst.quality = 50 inst.num_to_rank = 5 inst.accept_range = [.5, 1000] #TODO: need to filter based on inst.accept_range inst.inst_rank_app(setup_app()) #order matters on rank_list # TODO # Need to determin the right answer desired = ['a100', 'a90', 'a80', 'a70', 'a60', 'a50', 'a40', 'a30', 'a20', 'a10'] # Need to determin the right answer actual = [app.name for app in inst.rank_list] print('actual 2',actual) self.assertEqual(desired, actual, 'desired '+str(desired)+' != '+ 'Actual '+str(actual))
def test_inst_rank_app(self): """ Rank selection Test 1: """ inst = Inst() inst.quality = 50 inst.num_to_rank = 5 inst.accept_range = [.5, 1000] #TODO: need to filter based on inst.accept_range inst.inst_rank_app(setup_app()) #order matters on rank_list # TODO # Need to determin the right answer desired = [ 'a100', 'a90', 'a80', 'a70', 'a60', 'a50', 'a40', 'a30', 'a20', 'a10' ] # Need to determin the right answer actual = [app.name for app in inst.rank_list] print('actual 2', actual) self.assertEqual( desired, actual, 'desired ' + str(desired) + ' != ' + 'Actual ' + str(actual))
def login( self, institution_cnpj, password ): new_institution = Institution( institution_cnpj, password )
def removeInstitution( self, institution_cnpj, password ): institution = Institution( institution_cnpj, password ) institution.deleteFromStorage()
def registerInstitution( self, institution_name, cnpj, address, phone_number, email, access_password ): new_institution = Institution( cnpj, access_password, address, phone_number, email, institution_name ) new_institution.registerToStorage( access_password )
def __init__(self, name, infec_prob=0.0, posn=(0, 0, 0, 0), door_posns=[]): Institution.__init__(self, name, infec_prob, posn) self.door_posns = door_posns
# Import institution mAtch data # Make the list of Institutions print('importing institution data') data2008 = InstitutionData('/Users/vmd/Dropbox/Match/residency-match-simulation/matchdata2008.csv', 140, 'C', 1) data2008.read_data_file() data2008.prep_data() data2008.select_data() print('Setting Institution Attributes') all_institutions = [] for x in data2008.finaldata: #TODO: how to name the instances tname = x[1] # the Code is set as the object instance name, (I don't think this really works) tname = Institution() # the Code is set as the object instance name tname.name = x[1] #The name attribute is also set as the Code tname.openings = x[6] #Set the number of openings, comes from quota in the data file tname.prog_type = x[4] #Set the Type, for example 'C' is categorical tname.specialty = x[3] #Set the specialty, for example 140 is internal medicine tname.institution = x[2] #Set the institution number, basicly the name without the prog_type and specialty info tname.specialty_name = x[0] #This is the Speacialty name rather then code tname.obs_match = x[7] # The is the number that matched in the actual data set # Comment out the Following to use defualt tname.quality = max(min(r.gauss(50, 30), 100), 1) # on a scale 0-100 tname.number_to_interview = 10 * tname.openings tname.observe_1 = r.gauss(1, .2) tname.observe_2 = tname.observe_2 = (r.gauss(1, .1)- tname.observe_1) tname.observed_1 = r.gauss(1, .2) tname.observed_2 = (r.gauss(1, .1)- tname.observed_1) # based on applicant interviewed, percentage
def parse(self, token): self.parsed = json.loads(self.data) # print formatted received json # print(json.dumps(self.parsed, indent=4, sort_keys=True)) db = DataBase() self.institutions = [] for row in self.parsed["data"]: new_institution = Institution() new_institution.id = row["id"] new_institution.address = self.try_figure_out(row, "address") new_institution.benefit = self.try_figure_out(row, "benefit") new_institution.car_park = self.try_figure_out(row, "car-park") new_institution.locality = self.try_figure_out(row, "locality") new_institution.phone = self.try_figure_out(row, "phone") new_institution.place = self.try_figure_out(row, "place") new_institution.provider = self.try_figure_out(row, "provider") new_institution.regon = self.try_figure_out(row, "regon-provider") if token is not None: new_institution.is_fav = db.is_fav(token, row["id"]) # new_institution.p_print() self.institutions.append(new_institution) self.create_response_dict()
def parse_id_response(self): self.parsed = json.loads(self.data) new_institution = Institution() new_institution.id = self.parsed["data"]["id"] new_institution.address = self.try_figure_out(self.parsed["data"], "address") new_institution.benefit = self.try_figure_out(self.parsed["data"], "benefit") new_institution.car_park = self.try_figure_out(self.parsed["data"], "car-park") new_institution.locality = self.try_figure_out(self.parsed["data"], "locality") new_institution.phone = self.try_figure_out(self.parsed["data"], "phone") new_institution.place = self.try_figure_out(self.parsed["data"], "place") new_institution.provider = self.try_figure_out(self.parsed["data"], "provider") new_institution.regon = self.try_figure_out(self.parsed["data"], "regon-provider") new_institution.is_fav = True self.institutions = [new_institution] self.create_response_dict()
def __init__(self, name, infec_prob=0.0, posn=(0, 0, 0, 0)): Institution.__init__(self, name, infec_prob, posn)
def __init__(self, name, infec_prob=0.0, posn=(0, 0, 0, 0), door_posns=[]): Institution.__init__(self, name, infec_prob, posn) self.door_posns = door_posns PROB_STUDENT_BOARDS = 0.50 # TODO: reconsider this constant