コード例 #1
0
 def testLetsUpTo5PercentWhen20Countries(self):
     testData = np.array([[int(675000*0.025) for r in range(20)] for k in range(15)], dtype=np.int64)
     waitlist, admitted = sevenPcntRuleWaitlist(testData)
     for elem in waitlist.flatten():
         self.assertEqual(0, elem)
     for elem in admitted.flatten():
         self.assertEqual(int(675000*0.025), elem)
コード例 #2
0
 def testIdentifiesNoWaitlistAsHavingWaitOfZeroToZeroYears(self):
     testData = np.array([[int(675000*0.05) for r in range(10)] for k in range(15)], dtype=np.int64)
     waitlist, admitted = sevenPcntRuleWaitlist(testData)
     waitTimes = computeExpectedAdmissionYear(admitted, waitlist)
     self.assertTrue(np.all(waitlist == 0))
     self.assertTrue(np.all(waitTimes[:,:,0] == 0))
     self.assertTrue(np.all(waitTimes[:,:,1] == 0))
コード例 #3
0
 def testLetsUpTo47KWhenFewerThan15Countries(self):
     testData = np.array([[int(675000*0.07) for r in range(10)] for k in range(15)], dtype=np.int64)
     waitlist, admitted = sevenPcntRuleWaitlist(testData)
     for elem in waitlist.flatten():
         self.assertEqual(0, elem)
     for elem in admitted.flatten():
         self.assertEqual(int(675000*0.07), elem)
コード例 #4
0
 def testIdentifiesNoWaitlistAsHavingWaitOfZeroToZeroYears(self):
     testData = np.array([[int(675000*0.1) for r in range(15)] for k in range(15)], dtype=np.int64)
     waitlist, admitted = sevenPcntRuleWaitlist(testData)
     waitTimes = computeExpectedAdmissionYear(admitted, waitlist)
     self.confirmDidNotAdmitMoreThanApplied(testData, waitlist, admitted)
     self.confirmObeysSevenPercentRuleAnd675KCap(testData, waitlist, admitted)
     self.assertTrue(np.all(waitlist > 0))
     self.assertTrue(np.all(waitTimes[:,:,0] >= 0))
     self.assertTrue(np.all(waitTimes[:,:,1] >= 1))
コード例 #5
0
 def testLimitsEntryTo5PercentWhenExcessApplicantsAccross20Countries(self):
     testData = np.array([[int(675000*0.1) for r in range(20)] for k in range(15)], dtype=np.int64)
     expectedWaitlist = np.array([[int(675000*0.05)*k for r in range(20)] for k in range(16)], dtype=np.int64)
     expectedWaitlist[:15,:] += np.int64(675000*0.05)
     waitlist, admitted = sevenPcntRuleWaitlist(testData, 1)
     for elem in admitted.flatten():
         self.assertEqual(int(675000*0.05), elem)
     for e, g in zip(waitlist.flatten(), expectedWaitlist.flatten()):
         self.assertEqual(e, g)
コード例 #6
0
 def __init__(self, parser):
     headers = [s for s in next(parser)]
     listTable = [[
         cell for ind, cell in enumerate(row) if 'Total' not in headers[ind]
     ] for row in parser][::-1]
     self.headers = [
         s for s in headers if 'Total' not in s and 'Year' not in s
     ]
     table = np.array(listTable, dtype=float).astype(int)
     self.years = table[:, 0]
     self._table = table[:, 1:]
     self._waitlist, self._accepted = sevenPcntRuleWaitlist(self._table)
     self._expectedWaitTime = computeExpectedAdmissionYear(
         self._accepted, self._waitlist)
     self._countryLookup = {
         h: ind - 1
         for ind, h in enumerate(self.headers)
     }
     self._yearLookup = {year: ind for ind, year in enumerate(self.years)}
コード例 #7
0
 def testDoesNotCrashWhileComputingExpectedWaitimes(self):
     testData = np.array([[0, 0, 0, 0] + [(r+1)*10000 for r in range(25)] for k in range(25)], dtype=np.int64)
     waitlist, admitted = sevenPcntRuleWaitlist(testData)
     waitTimes = computeExpectedAdmissionYear(admitted, waitlist)
     self.assertTrue(True)
コード例 #8
0
 def testDoesNotFailOnCountryContributingZeroImmigrants(self):
     testData = np.array([[0, 0, 0, 0] + [(r+1)*10000 for r in range(25)] for k in range(15)], dtype=np.int64)
     waitlist, admitted = sevenPcntRuleWaitlist(testData)
     self.confirmDidNotAdmitMoreThanApplied(testData, waitlist=waitlist, admitted=admitted)
     self.confirmObeysSevenPercentRuleAnd675KCap(testData, waitlist, admitted)
コード例 #9
0
 def testDoesNotAllowMoreThan7PercentOfASingleCountry(self):
     testData = np.array([[(r+1)*10000 for r in range(25)] for k in range(15)], dtype=np.int64)
     waitlist, admitted = sevenPcntRuleWaitlist(testData)
     self.confirmDidNotAdmitMoreThanApplied(testData, waitlist=waitlist, admitted=admitted)
     self.confirmObeysSevenPercentRuleAnd675KCap(testData, waitlist, admitted)