def test_can_have_more_women_than_men(self):
     women = [1, 2, 3]
     men = [1, 2]
     try:
         matchmaker = Matchmaker(men, women, lambda x, y: 0)
         matchmaker.marry()
     except ValueError:
         self.fail()
        def compute_and_check(msg=None):
            matchmaker = Matchmaker(
                men,
                women,
                absolute_length_difference,
            )
            results = matchmaker.marry()

            self.assertCountEqual(results, expected, msg=msg)
    def test_match_on_number_difference(self):
        women = [1, 100, 1000]
        men = [5, 90, 10000]

        expected = [(5, 1, 4), (90, 100, 10), (10000, 1000, 9000)]

        matchmaker = Matchmaker(men, women, lambda x, y: abs(x - y))
        results = matchmaker.marry()

        self.assertCountEqual(results, expected)
Beispiel #4
0
def login():

    if request.method == 'POST':
        apid = api.API(debug=True)
        try:
            toke = utils.get_tinder_access_token(request.form['username'],
                                                 request.form['password'])
            apid.set_auth(request.form['username'], toke)
            print(apid.authorize())
            m.update(m, apid=apid)
            return redirect('/questions')
        except Exception as e:
            return render_template('login.html', error=e)
Beispiel #5
0
def main():
    import sys
    max_lines = int(sys.argv[1])

    lines = []

    wordlist_fn = '/usr/share/dict/words'
    import subprocess
    proc = subprocess.Popen(['cat', wordlist_fn], stdout=subprocess.PIPE)
    for index, line in enumerate(proc.stdout):
        lines.append(line.decode('utf-8').rstrip())
        if index == max_lines:
            break
    proc.kill()

    from Matchmaker import Matchmaker
    from stringdist import levenshtein

    matchmaker = Matchmaker(lines[:max_lines // 2], lines[max_lines // 2:],
                            levenshtein)
    matchmaker.marry()
Beispiel #6
0
def get_results():
    if request.method == 'GET':
        return render_template('results.html')
    if request.method == 'POST':
        print("distance pref: " + request.form['form-days-per-week'])
        social_prefs = request.form["social-rankings"].replace(
            'ranking[]=', '').split('&')
        # print("social ranks pref: " + str(social_prefs))
        m.calculate_social_rankings(m, social_prefs)
        m.calculate_distance_ranking(m, request.form['form-days-per-week'])
        print("argument pref: " + request.form['argumentsRadio'])
        m.calculate_argument_ranking(m, request.form['argumentsRadio'])

        best_matches = m.get_best_matches(m)
        return render_template('results.html', bestmatches=best_matches)
 def test_cant_have_fewer_women_than_men(self):
     women = [1, 2]
     men = [1, 2, 3]
     with self.assertRaises(ValueError):
         matchmaker = Matchmaker(men, women, lambda x, y: 0)
         matchmaker.marry()