Exemple #1
0
    def test_div(self):
        self.assertEqual(main.divide(10, 5), 2)
        self.assertEqual(main.divide(-1, 1), -1)
        self.assertEqual(main.divide(-1, -1), 1)

        with self.assertRaises(ValueError):
            main.divide(10,0)
Exemple #2
0
def generate_output():
    import main
    person = generate_client()
    pesel = general.generate_pesel(person["birthdate"])
    person_rows = [
        pesel,
        main.divide(person["name"])[0],
        main.divide(person["name"])[1], person["mail"],
        person["residence"].replace("\n", " "),
        generate_phone("pl")
    ]
    writer.export_data(person_rows, "output/client.csv")
Exemple #3
0
    def test_divide(self):
        self.assertEqual(divide(10, 5), 2)
        self.assertEqual(divide(-1, 1), -1)
        self.assertEqual(divide(-1, -1), 1)
        self.assertEqual(divide(5, 2), 2.5)

        with self.assertRaises(ValueError):
            divide(10, 0)
Exemple #4
0
 def test_divide_by_zero(self):
     with self.assertRaises(ZeroDivisionError):
         main.divide(6, 0)
Exemple #5
0
 def test_divide(self):
     self.assertEqual(3, main.divide(6, 2))
Exemple #6
0
        res = solve(slideshow, len(slideshow), 10, 30)
        new_slideshow = [slideshow[i] for i in res]
        submit(new_slideshow, fname[:-3] + 'out')


def parse_submit(path):
    with open(path) as f:
        N = int(f.readline())


if __name__ == '__main__':
    path = 'data/c_memorable_moments.txt'
    photos = get_photos(path)

    # Create array of horizontal photos and vertical ones
    verts, slides = divide(photos)

    # Create good pairs of vertical photos
    vert_slides = concat_verts(verts)

    # Add pairs of vertical photos to all slides
    slides.extend(vert_slides)

    res = multiprocess_solve(slides, len(slides), 10, 1000)
    best_res, best_score = None, 0
    for r in res:
        score = fitness(r, slides)
        if score > best_score:
            best_res = r
            best_score = score
    print("Best score:", best_score)
Exemple #7
0
import main
# importing a file to use!
from main import multiply

import shopping.shopping_cart

# here are two ways you can import. The first one import main brings in everything
print(main.divide(33, 5))
print(multiply(3, 5))
print(shopping.shopping_cart.buy("red"))


# print(__name__)
Exemple #8
0
         str(error), "\n"]))
    return error, best


if __name__ == '__main__':
    #graph = Graph(OUTFILE)
    startTime, divisions, loglines = time.time(), 1, []
    error, best = logGuess(loglines, startTime)
    oldError = BIG_FLOAT
    while error < oldError:
        oldError = error
        error, best = logGuess(loglines, startTime)
    for attempt in range(MAX_DIVISIONS):
        if time.time() > (startTime + MAX_TIME):
            break
        divisions, positions, prog = divide(divisions, startTime,
                                            DIVISION_BASE)
        while prog:
            if time.time() > (startTime + MAX_TIME):
                break
            error, prog, oneToMove, placeToGo = moveSingle(
                error, best, positions, loglines, startTime)
            if prog:
                best[oneToMove] = placeToGo
            printIfYappy(", ".join([str(prog), str(error), str(best)]))
            #graph.etch(bestGuess)
            loglines.append("".join(
                [str(time.time() - startTime), ",",
                 str(error), "\n"]))
    with open(LOGFILE, "w") as logfile:
        logfile.writelines(loglines)
Exemple #9
0
def test_divide1():
    arg1 = 3
    arg2 = 2
    expected = 1.5
    actual = divide(arg1, arg2)
    assert expected == actual
Exemple #10
0
def test_divide3():
    arg1 = 10
    arg2 = 0
    expected = 'You cannot divide 0!'
    actual = divide(arg1, arg2)
    assert expected == actual
Exemple #11
0
def test_divide2():
    arg1 = 4
    arg2 = 2
    expected = 2.0
    actual = divide(arg1, arg2)
    assert expected == actual
Exemple #12
0
 def test_divide(self):
     self.assertEqual(main.divide(10, 2), 5)
     self.assertEqual(main.divide(10, 0), 0)