Skip to content

Commit ab51d27

Browse files
committed
Added disclaimer, change links such as to build from top root directory
1 parent 4906a87 commit ab51d27

File tree

7 files changed

+84
-68
lines changed

7 files changed

+84
-68
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,11 @@ This work is licensed under a
55
(http://creativecommons.org/licenses/by/4.0/).
66

77
**Work in progress. No due date yet.**
8+
9+
If you want to contribute to this book, you can:
10+
11+
* Review chapters (please contact me)
12+
* Report issues (https://github.com/rougier/numpy-book/issues)
13+
* Suggest improvements (https://github.com/rougier/numpy-book/pulls)
14+
* Correct English (https://github.com/rougier/numpy-book/issues)
15+
* Design a better and more responsive html template for the book.

book/beyond-numpy.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ specific cases, it might be more powerful than Numpy. Let's consider for
1414
example an interesting exercise that has been proposed by Tucker Balch in his
1515
`Coursera's Computational Investing
1616
<https://www.coursera.org/learn/computational-investing>`_ course. The exercise
17-
can be written as:
17+
is written as:
1818

1919
Write the most succinct code possible to compute all "legal" allocations to 4
2020
stocks such that:

book/book.rst

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@
1616

1717
.. container:: title-logos
1818

19-
.. image:: ../data/cc.large.png
19+
.. image:: data/cc.large.png
2020
:width: 40px
21-
.. image:: ../data/by.large.png
21+
.. image:: data/by.large.png
2222
:width: 40px
23-
.. image:: ../data/sa.large.png
23+
.. image:: data/sa.large.png
2424
:width: 40px
25-
.. image:: ../data/nc.large.png
25+
.. image:: data/nc.large.png
2626
:width: 40px
2727

2828
(J. Kerouac style)
@@ -31,7 +31,7 @@
3131
.. ----------------------------------------------------------------------------
3232
.. container:: title-logos
3333

34-
.. image:: ../data/cubes.png
34+
.. image:: data/cubes.png
3535
:width: 100%
3636

3737
.. ----------------------------------------------------------------------------
@@ -51,6 +51,14 @@ make you acquire experience in the process.
5151
:class: main-content
5252
:depth: 2
5353

54+
|
55+
|
56+
57+
**Disclaimer** All external pictures should have associated credits. If there
58+
are missing credits, please tell me, I will correct it. Similarly, all excerpts
59+
should be sourced (wikipedia mostly). If not, this is an error and I will
60+
correct it as soon as you tell me.
61+
5462
.. ----------------------------------------------------------------------------
5563
.. |WIP| image:: https://img.shields.io/badge/status-WIP-orange.svg?style=flat-square
5664

book/code-vectorization.rst

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ see how to vectorize it.
8585
Conus textile snail exhibits a cellular automaton pattern on its shell.
8686
Image by `Richard Ling <https://commons.wikimedia.org/wiki/File:Textile_cone.JPG>`_, 2005.
8787

88-
.. image:: ../data/Textile-Cone-cropped.jpg
88+
.. image:: data/Textile-Cone-cropped.jpg
8989
:width: 100%
9090
:class: bordered
9191

@@ -191,7 +191,7 @@ discovered by Richard K. Guy in 1970.
191191
The glider pattern is known to replicate itself one step diagonally in 4
192192
iterations.
193193

194-
.. image:: ../data/glider.png
194+
.. image:: data/glider.png
195195
:width: 100%
196196

197197

@@ -287,7 +287,7 @@ cleared it.
287287
.. raw:: html
288288

289289
<video width="100%" controls>
290-
<source src="../data/game-of-life.mp4" type="video/mp4">
290+
<source src="data/game-of-life.mp4" type="video/mp4">
291291
Your browser does not support the video tag. </video>
292292

293293

@@ -358,25 +358,25 @@ The figure below show some animation of the model for a specific set of paramete
358358
.. raw:: html
359359

360360
<video width="33%" controls>
361-
<source src="../data/gray-scott-1.mp4" type="video/mp4">
361+
<source src="data/gray-scott-1.mp4" type="video/mp4">
362362
Your browser does not support the video tag. </video>
363363

364364
<video width="33%" controls>
365-
<source src="../data/gray-scott-2.mp4" type="video/mp4">
365+
<source src="data/gray-scott-2.mp4" type="video/mp4">
366366
Your browser does not support the video tag. </video>
367367

368368
<video width="33%" controls>
369-
<source src="../data/gray-scott-3.mp4" type="video/mp4">
369+
<source src="data/gray-scott-3.mp4" type="video/mp4">
370370
Your browser does not support the video tag. </video>
371371

372372

373373

374374
Sources
375375
+++++++
376376

377-
* `game-of-life-python.py <../code/game-of-life-python.py>`_
378-
* `game-of-life-numpy.py <../code/game-of-life-numpy.py>`_
379-
* `gray-scott.py <../code/gray-scott.py>`_ (solution to the exercise)
377+
* `game-of-life-python.py <code/game-of-life-python.py>`_
378+
* `game-of-life-numpy.py <code/game-of-life-numpy.py>`_
379+
* `gray-scott.py <code/gray-scott.py>`_ (solution to the exercise)
380380

381381

382382
References
@@ -423,7 +423,7 @@ divergent. Of course, the more iteration you do, the more precision you get.
423423
Romanesco broccoli, showing self-similar form approximating a natural fractal.
424424
Image by `Jon Sullivan <https://commons.wikimedia.org/wiki/File:Fractal_Broccoli.jpg>`_, 2004.
425425

426-
.. image:: ../data/Fractal-Broccoli-cropped.jpg
426+
.. image:: data/Fractal-Broccoli-cropped.jpg
427427
:width: 100%
428428
:class: bordered
429429

@@ -561,7 +561,7 @@ and added a power normalized colormap (gamma=0.3) as well as light shading.
561561
The Mandelbrot as rendered by maplotlib using recount normalization, power
562562
normalized colormap (gamma=0.3) and light shading.
563563

564-
.. figure:: ../data/mandelbrot.png
564+
.. figure:: data/mandelbrot.png
565565
:width: 100%
566566
:class: bordered
567567

@@ -590,18 +590,18 @@ normalized (i.e. all values are between 0 and 1).
590590
The Minkowski–Bouligand dimension of the Great Britain coastlines is
591591
approximately 1.24.
592592

593-
.. figure:: ../data/fractal-dimension.png
593+
.. figure:: data/fractal-dimension.png
594594
:width: 100%
595595

596596

597597
Sources
598598
+++++++
599599

600-
* `mandelbrot.py <../code/mandelbrot.py>`_
601-
* `mandelbrot-python.py <../code/mandelbrot-python.py>`_
602-
* `mandelbrot-numpy-1.py <../code/mandelbrot-numpy-1.py>`_
603-
* `mandelbrot-numpy-2.py <../code/mandelbrot-numpy-2.py>`_
604-
* `fractal-dimension.py <../code/fractal-dimension.py>`_ (solution to the exercise)
600+
* `mandelbrot.py <code/mandelbrot.py>`_
601+
* `mandelbrot-python.py <code/mandelbrot-python.py>`_
602+
* `mandelbrot-numpy-1.py <code/mandelbrot-numpy-1.py>`_
603+
* `mandelbrot-numpy-2.py <code/mandelbrot-numpy-2.py>`_
604+
* `fractal-dimension.py <code/fractal-dimension.py>`_ (solution to the exercise)
605605

606606
References
607607
++++++++++
@@ -629,7 +629,7 @@ boids that simulate flocking behaviors.
629629
Flocking birds are an example of self-organization in biology.
630630
Image by `Christoffer A Rasmussen <https://commons.wikimedia.org/wiki/File:Fugle,_ørnsø_073.jpg>`_, 2012.
631631

632-
.. image:: ../data/Fugle-cropped.jpg
632+
.. image:: data/Fugle-cropped.jpg
633633
:width: 100%
634634
:class: bordered
635635

@@ -662,7 +662,7 @@ rules. The rules applied in the simplest Boids world are as follows:
662662
Boids are governed by a set of three local rules (separation, cohesion and
663663
alignment) that serve as computing velocity and acceleration.
664664

665-
.. image:: ../data/boids.png
665+
.. image:: data/boids.png
666666
:width: 100%
667667

668668
Python implementation
@@ -883,7 +883,7 @@ We finally visualize the result using a custom oriented scatter plot.
883883
.. raw:: html
884884

885885
<video width="100%" class="bordered" controls>
886-
<source src="../data/boids.mp4" type="video/mp4">
886+
<source src="data/boids.mp4" type="video/mp4">
887887
Your browser does not support the video tag. </video>
888888

889889

@@ -930,8 +930,8 @@ How would you write the `translate`, `scale` and `rotate` functions ?
930930
Sources
931931
+++++++
932932

933-
* `boid-python.py <../code/boid-python.py>`_
934-
* `boid-numpy.py <../code/boid-numpy.py>`_ (solution to the exercise)
933+
* `boid-python.py <code/boid-python.py>`_
934+
* `boid-numpy.py <code/boid-numpy.py>`_ (solution to the exercise)
935935

936936
References
937937
++++++++++

book/preface.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ About this book
3434
This book has been written in |ReST|_ format and generated using the
3535
`rst2html.py` command line available from the docutils_ python package.
3636

37-
If you want to rebuild the html output, use:
37+
If you want to rebuild the html output, from top direcotry, type:
3838

3939
.. code-block::
4040
4141
$ rst2html.py --link-stylesheet --cloak-email-addresses \
42-
--toc-top-backlinks --stylesheet=book.css \
43-
book.rst book.html
42+
--toc-top-backlinks --stylesheet=book/book.css \
43+
book/book.rst book.html
4444
4545
The sources are available from https://github.com/rougier/numpy-book.
4646

book/problem-vectorization.rst

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ maze. First task is thus to build a maze.
177177
A hedge maze at Longleat stately home in England.
178178
Image by `Prince Rurik <https://commons.wikimedia.org/wiki/File:Longleat_maze.jpg>`_, 2005.
179179

180-
.. image:: ../data//Longleat-maze-cropped.jpg
180+
.. image:: data//Longleat-maze-cropped.jpg
181181
:width: 100%
182182
:class: bordered
183183

@@ -255,7 +255,7 @@ Here is an animation showing the generation process.
255255
.. raw:: html
256256

257257
<video width="100%" controls>
258-
<source src="../data/maze-build.mp4" type="video/mp4">
258+
<source src="data/maze-build.mp4" type="video/mp4">
259259
Your browser does not support the video tag. </video>
260260

261261
Breadth-first
@@ -294,11 +294,11 @@ it into an actual graph as proposed by `Valentin Bryukhanov
294294
shortest path, only to find a path (if it exists).
295295

296296
Once this is done, writing the breadth first algorithm is straightforward. We
297-
start from the starting node and we visit nodes one level (breadth first,
298-
remember?) and we iterate the process until reaching the final node, if
297+
start from the starting node and we visit nodes at current depth only (breadth
298+
first, remember?) and we iterate the process until reaching the final node, if
299299
possible. The question is then, do we get the shortest path exploring the graph
300300
this way? In this specific case yes because we don't have a e-weighted graph,
301-
i.e. all the edges have the same weight (or cost).
301+
i.e. all the edges have the same weight (or cost).
302302

303303
.. code:: python
304304
@@ -334,26 +334,26 @@ done, we can ascent the gradient from the starting node. You can check on the
334334
figure this leads to the shortest path.
335335

336336

337-
.. image:: ../data/value-iteration-1.pdf
337+
.. image:: data/value-iteration-1.pdf
338338
:width: 19%
339-
.. image:: ../data/value-iteration-2.pdf
339+
.. image:: data/value-iteration-2.pdf
340340
:width: 19%
341-
.. image:: ../data/value-iteration-3.pdf
341+
.. image:: data/value-iteration-3.pdf
342342
:width: 19%
343-
.. image:: ../data/value-iteration-4.pdf
343+
.. image:: data/value-iteration-4.pdf
344344
:width: 19%
345-
.. image:: ../data/value-iteration-5.pdf
345+
.. image:: data/value-iteration-5.pdf
346346
:width: 19%
347347

348-
.. image:: ../data/value-iteration-6.pdf
348+
.. image:: data/value-iteration-6.pdf
349349
:width: 19%
350-
.. image:: ../data/value-iteration-7.pdf
350+
.. image:: data/value-iteration-7.pdf
351351
:width: 19%
352-
.. image:: ../data/value-iteration-8.pdf
352+
.. image:: data/value-iteration-8.pdf
353353
:width: 19%
354-
.. image:: ../data/value-iteration-9.pdf
354+
.. image:: data/value-iteration-9.pdf
355355
:width: 19%
356-
.. image:: ../data/value-iteration-10.pdf
356+
.. image:: data/value-iteration-10.pdf
357357
:width: 19%
358358

359359
We start by setting the exit node to the value 1 while every other nodes are
@@ -424,16 +424,16 @@ illustrated on the figure below:
424424
propagated values from the end-point of the maze (bottom-right). Path is
425425
found by ascending gradient from the goal.
426426

427-
.. image:: ../data/maze.png
427+
.. image:: data/maze.png
428428
:width: 100%
429429

430430

431431

432432
Sources
433433
+++++++
434434

435-
* `maze-build.py <../code/maze-build.py>`_
436-
* `maze-numpy.py <../code/maze-numpy.py>`_
435+
* `maze-build.py <code/maze-build.py>`_
436+
* `maze-numpy.py <code/maze-numpy.py>`_
437437

438438
References
439439
++++++++++
@@ -455,7 +455,7 @@ Fluid Dynamics
455455
Germany. Image by `Steven Mathey
456456
<https://commons.wikimedia.org/wiki/File:Self_Similar_Turbulence.png>`_, 2012.
457457

458-
.. image:: ../data/Self-similar-turbulence.png
458+
.. image:: data/Self-similar-turbulence.png
459459
:width: 100%
460460

461461

@@ -530,25 +530,25 @@ using this technique.
530530
.. raw:: html
531531

532532
<video width="33%" controls>
533-
<source src="../data/smoke-1.mp4" type="video/mp4">
533+
<source src="data/smoke-1.mp4" type="video/mp4">
534534
Your browser does not support the video tag. </video>
535535

536536
<video width="33%" controls>
537-
<source src="../data/smoke-2.mp4" type="video/mp4">
537+
<source src="data/smoke-2.mp4" type="video/mp4">
538538
Your browser does not support the video tag. </video>
539539

540540
<video width="33%" controls>
541-
<source src="../data/smoke-gpu.mp4" type="video/mp4">
541+
<source src="data/smoke-gpu.mp4" type="video/mp4">
542542
Your browser does not support the video tag. </video>
543543

544544

545545
Sources
546546
+++++++
547547

548-
* `smoke-1.py <../code/smoke-1.py>`_
549-
* `smoke-2.py <../code/smoke-2.py>`_
550-
* `smoke_solver.py <../code/smoke_solver.py>`_
551-
* `smoke-interactive.py <../code/smoke-interactive.py>`_
548+
* `smoke-1.py <code/smoke-1.py>`_
549+
* `smoke-2.py <code/smoke-2.py>`_
550+
* `smoke_solver.py <code/smoke_solver.py>`_
551+
* `smoke-interactive.py <code/smoke-interactive.py>`_
552552

553553

554554
References
@@ -569,7 +569,7 @@ Blue noise
569569

570570
Detail of "The Starry Night", Vincent van Gogh, 1889.
571571

572-
.. image:: ../data/mosaic.png
572+
.. image:: data/mosaic.png
573573
:width: 100%
574574
:class: bordered
575575

@@ -587,15 +587,15 @@ Numpy implementation
587587
Comparison of uniform, grid-jittered and Poisson disc sampling.
588588

589589

590-
.. image:: ../data/sampling.png
590+
.. image:: data/sampling.png
591591
:width: 100%
592592

593593
Sources
594594
+++++++
595595

596-
* `sampling.py <../code/sampling.py>`_
597-
* `mosaic.py <../code/mosaic.py>`_
598-
* `voronoi.py <../code/voronoi.py>`_
596+
* `sampling.py <code/sampling.py>`_
597+
* `mosaic.py <code/mosaic.py>`_
598+
* `voronoi.py <code/voronoi.py>`_
599599

600600
References
601601
++++++++++

code/random_walk.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@ def find_crossing_2(seq, subseq):
5050

5151

5252
if __name__ == "__main__":
53-
from tools import print_timeit
53+
from tools import timeit
5454

55-
print_timeit("random_walk_1(n=10000)", globals())
56-
print_timeit("random_walk_2(n=10000)", globals())
57-
print_timeit("random_walk_3(n=10000)", globals())
55+
timeit("random_walk_1(n=10000)", globals())
56+
timeit("random_walk_2(n=10000)", globals())
57+
timeit("random_walk_3(n=10000)", globals())
5858
print()
5959
W = random_walk_3(n=1000)
60-
print_timeit("find_crossing_1(list(W), [+1,0,-1])", globals())
61-
print_timeit("find_crossing_2(W, [+1,0,-1])", globals())
60+
timeit("find_crossing_1(list(W), [+1,0,-1])", globals())
61+
timeit("find_crossing_2(W, [+1,0,-1])", globals())

0 commit comments

Comments
 (0)