Python 3.5.2 |Anaconda 4.1.1 (x86_64)| (default, Jul 2 2016, 17:52:12)

Type "copyright", "credits" or "license" for more information.


IPython 4.2.0 -- An enhanced Interactive Python.

? -> Introduction and overview of IPython's features.

%quickref -> Quick reference.

help -> Python's own help system.

object? -> Details about 'object', use 'object??' for extra details.

%guiref -> A brief reference about the graphical user interface.


In [1]: runfile('/Users/progprim/Desktop/code/fifoqueue-alternative.py', wdir='/Users/progprim/Desktop/code')


In [2]: runfile('/Users/progprim/Desktop/code/fifoqueueOO.py', wdir='/Users/progprim/Desktop/code')

3 customers in queue1:

waiting customer: Takeda

waiting customer: Fangohr

waiting customer: Spearing

2 customers in queue2:

waiting customer: Peter

waiting customer: John


In [3]: q1

Out[3]: <__main__.Fifoqueue at 0x119ff1908>


In [4]: runfile('/Users/progprim/Desktop/code/fifoqueueOO.py', wdir='/Users/progprim/Desktop/code')

3 customers in queue1:

waiting customer: Takeda

waiting customer: Fangohr

waiting customer: Spearing

2 customers in queue2:

waiting customer: Peter

waiting customer: John


In [5]: q1

Out[5]: <__main__.Fifoqueue at 0x118d24a90>


In [6]: str(q1)

Out[6]: 'I am a queue'


In [7]: repr(q1)

Out[7]: '<__main__.Fifoqueue object at 0x118d24a90>'


In [8]: runfile('/Users/progprim/Desktop/code/fifoqueueOO.py', wdir='/Users/progprim/Desktop/code')

3 customers in queue1:

waiting customer: Takeda

waiting customer: Fangohr

waiting customer: Spearing

2 customers in queue2:

waiting customer: Peter

waiting customer: John


In [9]: q1

Out[9]: I am a queue


In [10]: runfile('/Users/progprim/Desktop/code/fifoqueueOO.py', wdir='/Users/progprim/Desktop/code')

3 customers in queue1:

waiting customer: Takeda

waiting customer: Fangohr

waiting customer: Spearing

2 customers in queue2:

waiting customer: Peter

waiting customer: John


In [11]: q1

Out[11]: I am a queue with 3 customers


In [12]: runfile('/Users/progprim/Desktop/code/mexhat-numpy.py', wdir='/Users/progprim/Desktop/code')

File "/Users/progprim/Desktop/code/mexhat-numpy.py", line 34

print "error:", deviation

^

SyntaxError: Missing parentheses in call to 'print'



In [13]: runfile('/Users/progprim/Desktop/code/mexhat-numpy.py', wdir='/Users/progprim/Desktop/code')

File "/Users/progprim/Desktop/code/mexhat-numpy.py", line 78

print "Numpy version is %.1f times faster" %\

^

SyntaxError: Missing parentheses in call to 'print'



In [14]: runfile('/Users/progprim/Desktop/code/mexhat-numpy.py', wdir='/Users/progprim/Desktop/code')

error: 2.223029320536979e-16

Numpy version is 91.5 times faster


In [15]: runfile('/Users/progprim/Desktop/code/mexhat-numpy.py', wdir='/Users/progprim/Desktop/code')

error: 2.223029320536979e-16

Numpy version is 112.2 times faster


In [16]: runfile('/Users/progprim/Desktop/code/mexhat-numpy.py', wdir='/Users/progprim/Desktop/code')

error: 2.223029320536979e-16

Numpy version is 173.9 times faster


In [17]: runfile('/Users/progprim/Desktop/code/mexhat-numpy.py', wdir='/Users/progprim/Desktop/code')

error: 2.223029320536979e-16

Numpy version is 135.0 times faster


In [18]: runfile('/Users/progprim/Desktop/code/mexhat-numpy.py', wdir='/Users/progprim/Desktop/code')

error: 2.223029320536979e-16

Numpy version is 113.9 times faster


In [19]: runfile('/Users/progprim/Desktop/code/mexhat-numpy.py', wdir='/Users/progprim/Desktop/code')

error: 2.223029320536979e-16

Numpy version is 38.5 times faster


In [20]: runfile('/Users/progprim/Desktop/code/mexhat-numpy.py', wdir='/Users/progprim/Desktop/code')

error: 2.223029320536979e-16

Numpy version is 66.3 times faster


In [21]: runfile('/Users/progprim/Desktop/code/mexhat-numpy.py', wdir='/Users/progprim/Desktop/code')

error: 2.223029320536979e-16

Numpy version is 158.8 times faster


In [22]: runfile('/Users/progprim/Desktop/code/mexhat-numpy.py', wdir='/Users/progprim/Desktop/code')

error: 2.223029320536979e-16

Numpy version is 173.4 times faster


In [23]: runfile('/Users/progprim/Desktop/code/mexhat-numpy.py', wdir='/Users/progprim/Desktop/code')

error: 2.223029320536979e-16

Numpy version is 121.8 times faster


In [24]: runfile('/Users/progprim/Desktop/code/mexhat-numpy.py', wdir='/Users/progprim/Desktop/code')

error: 2.223029320536979e-16

Numpy version is 115.3 times faster


In [25]: runfile('/Users/progprim/Desktop/code/mexhat-numpy.py', wdir='/Users/progprim/Desktop/code')

error: 3.2512825073745733e-15

Traceback (most recent call last):


File "<ipython-input-25-0edb81dc7dd4>", line 1, in <module>

runfile('/Users/progprim/Desktop/code/mexhat-numpy.py', wdir='/Users/progprim/Desktop/code')


File "/Users/progprim/anaconda/lib/python3.5/site-packages/spyderlib/widgets/externalshell/sitecustomize.py", line 714, in runfile

execfile(filename, namespace)


File "/Users/progprim/anaconda/lib/python3.5/site-packages/spyderlib/widgets/externalshell/sitecustomize.py", line 89, in execfile

exec(compile(f.read(), filename, 'exec'), namespace)


File "/Users/progprim/Desktop/code/mexhat-numpy.py", line 82, in <module>

main()


File "/Users/progprim/Desktop/code/mexhat-numpy.py", line 74, in main

test_is_really_the_same()


File "/Users/progprim/Desktop/code/mexhat-numpy.py", line 35, in test_is_really_the_same

assert deviation < 1e-15


AssertionError



In [26]: %debug

> /Users/progprim/Desktop/code/mexhat-numpy.py(35)test_is_really_the_same()

33 deviation = math.sqrt(sum((ys1 - ys2) ** 2))

34 print("error:", deviation)

---> 35 assert deviation < 1e-15

36

37



ipdb> p deviation

3.2512825073745733e-15


ipdb> exit


In [27]: runfile('/Users/progprim/Desktop/code/mexhat-numpy.py', wdir='/Users/progprim/Desktop/code')

error: 3.2512825073745733e-15

Numpy version is 71.7 times faster


In [28]: runfile('/Users/progprim/Desktop/code/mexhat-numpy.py', wdir='/Users/progprim/Desktop/code')

error: 3.2512825073745733e-15

Numpy version is 71.5 times faster


In [29]: runfile('/Users/progprim/Desktop/code/mexhat-numpy.py', wdir='/Users/progprim/Desktop/code')

error: 0.0

Numpy version is 1.6 times faster


In [30]: runfile('/Users/progprim/Desktop/code/mexhat-numpy.py', wdir='/Users/progprim/Desktop/code')

error: 0.0

Numpy version is 1.3 times faster


In [31]: runfile('/Users/progprim/Desktop/code/mexhat-numpy.py', wdir='/Users/progprim/Desktop/code')

error: 0.0

Numpy version is 1.3 times faster


In [32]: runfile('/Users/progprim/Desktop/code/mexhat-numpy.py', wdir='/Users/progprim/Desktop/code')

error: 0.0

Numpy version is 1.5 times faster


In [33]: %timeit loop1

10000000 loops, best of 3: 22.4 ns per loop


In [34]: %timeit loop2

10000000 loops, best of 3: 24.6 ns per loop


In [35]: runfile('/Users/progprim/Desktop/code/mexhat-numpy.py', wdir='/Users/progprim/Desktop/code')

error: 2.223029320536979e-16

Numpy version is 110.4 times faster


In [36]: %timeit loop1

The slowest run took 69.54 times longer than the fastest. This could mean that an intermediate result is being cached.

10000000 loops, best of 3: 24.4 ns per loop


In [37]: %timeit loop2

10000000 loops, best of 3: 26.2 ns per loop


In [38]: """

    ...: Demo of image that's been clipped by a circular patch.

    ...: """

    ...: import matplotlib.pyplot as plt

    ...: import matplotlib.patches as patches

    ...: import matplotlib.cbook as cbook

    ...:

    ...:

    ...: image_file = cbook.get_sample_data('grace_hopper.png')

    ...: image = plt.imread(image_file)

    ...:

    ...: fig, ax = plt.subplots()

    ...: im = ax.imshow(image)

    ...: patch = patches.Circle((260, 200), radius=200, transform=ax.transData)

    ...: im.set_clip_path(patch)

    ...:

    ...: plt.axis('off')

    ...: plt.show()

    ...:



In [39]: