Example #1
0
def test_equality(n):
    I_cy = numpy.array(mandel.mandel_cy(n, 100, -2, .5, -1.25, 1.25))
    I_py = numpy.array(mandel_py(n, 100, -2, .5, -1.25, 1.25))

    diff = I_cy - I_py
    if max(numpy.abs(diff.flat)) > 0:
        print("Something bifferent. Difference is")
        print(diff)
        print("Cython matrix:")
        print(I_cy)
        print("Python matrix:")
        print(I_py)
    else:
        print("Python and Cython results agree for n={}".format(n))
Example #2
0
def demo_save_png(n):
    print("Computing {} x {} matrix".format(n, n))

    # try to use cython version
    if hasattr(mandel, "mandel_cy"):
        print("Using Cython version to compute")
        I = mandel.mandel_cy(n, 100, -2, .5, -1.25, 1.25)
    else:
        print("Using Python version to compute")
        I = mandel_py(n, 100, -2, .5, -1.25, 1.25)
    I = numpy.array(I)
    img = pylab.imshow(I.T, origin='lower left')
    print("Writing data to 'mandel.png'")
    img.write_png('mandel.png', noscale=True)
    pylab.show()
Example #3
0
def demo_save_png(n):
    print("Computing {} x {} matrix".format(n, n))

    # try to use cython version
    if hasattr(mandel, "mandel_cy"):
        print("Using Cython version to compute")
        I = mandel.mandel_cy(n, 100, -2, .5, -1.25, 1.25)
    else:
        print("Using Python version to compute")
        I = mandel_py(n, 100, -2, .5, -1.25, 1.25)
    I = numpy.array(I)
    img = pylab.imshow(I.T, origin='lower left')
    print("Writing data to 'mandel.png'")
    img.write_png('mandel.png', noscale=True)
    pylab.show()
Example #4
0
def test_equality(n):
    I_cy = numpy.array(mandel.mandel_cy(n, 100, -2, .5, -1.25, 1.25))
    I_py = numpy.array(mandel_py(n, 100, -2, .5, -1.25, 1.25))


    diff = I_cy - I_py
    if max(numpy.abs(diff.flat)) > 0:
        print("Something bifferent. Difference is")
        print(diff)
        print("Cython matrix:")
        print(I_cy)
        print("Python matrix:")
        print(I_py)
    else:
        print("Python and Cython results agree for n={}".format(n))