N
Nicolas Rougier
labri.fr · Personal blog · on HN since 2011
Nicolas Rougier, a researcher at a French computing lab, writes free books and tutorials on Python, NumPy, Matplotlib, and scientific visualization.
What HN saysHN commenters praise his open books, especially From Python to Numpy, calling it the best NumPy tutorial they have read, and thank him for sharing.
29HN people shared it
16linked it in comments
14stories submitted
1.1Kstory points
2 years agolast shared
2011people per year2026
Most-shared posts
- 1From Python to Numpy13 people · 512 points · first shared 2016 · 73 comments on HN
- 2Python and OpenGL for Scientific Visualization5 people · 273 points · first shared 2018 · 24 comments on HN
- 3Matplotlib tutorial3 people · 2 points · first shared 2015 · discussion on HN
- 4Get things done with Emacs2 people · 298 points · first shared 2021 · 80 comments on HN
- 5Stunning figures from newly released book on matplotlib (open access)1 people · 2 points · first shared 2021 · 1 comments on HN
- 6Matplotlib tutorial1 people · 2 points · first shared 2016 · discussion on HN
- 7CoqArt1 people · first shared 2015
- 8Trees.pdf1 people · first shared 2022
- 9GTD.css1 people · first shared 2022
- 10Index1 people · first shared 2011
- 11RecTutorial.pdf1 people · first shared 2015
What HN people wrote when they linked it
jszymborski · 2024-09-22
Love Mr. Rougier's open books. I supported this one while it was in development and I wasn't disappointment by the final product.
I've long awaited for him to finish "Python & OpenGL for Scientific Visualization" [0] but I'll take this in the mean time :P
[0] https://www.labri.fr/perso/nrougier/python-opengl/#python-opengl-for-s…
jointpdf · 2021-11-15
This person is prolific and has a ton of great tutorials, free books, and more in their repo (I like the numpy book: https://www.labri.fr/perso/nrougier/from-python-to-numpy/). Major thanks to the author for sharing all this knowledge.
oliverx0 · 2020-02-02
You are gonna love this: https://www.labri.fr/perso/nrougier/from-python-to-numpy/#code-vectori…
avshyz · 2019-10-27
Jesus, I've just realized it's the author of the best numpy tutorial I've ever read!
https://www.labri.fr/perso/nrougier/from-python-to-numpy/
thijsvandien · 2017-12-23
Here's a great mini-book that explains how NumPy can improve efficiency, at an appropriate level of detail for what you're asking: http://www.labri.fr/perso/nrougier/from-python-to-numpy/
seanwilson · 2015-02-12
I could recommend Coq Art: http://www.labri.fr/perso/casteran/CoqArt/ Unfortunately, formal proofs are very theoretical and there's a lot of concepts to learn that aren't found in regular programming. This book eases you into things though.
stralep · 2011-01-03
I'm also currently interested in this area, and I would recommend Interactive Theorem Proving and Program Development. At the same time, it is practical and theoretical.
http://www.labri.fr/perso/casteran/CoqArt/index.html
cs702 · 2017-08-29
If you really care about extracting every possible ounce of performance out of Python's scientific stack, which relies extensively on Numpy, the best practical guide I have found for doing that is "From Python to Numpy," by Nicolas P. Rougier of Inria: https://www.labri.fr/perso/nrougier/from-python-to-numpy/
Here's a typical example of the kinds of optimizations this guide teaches you, in this case by avoiding the creation of temporary copies of Numpy arrays in memory:
# Create two int arrays, each filled with with one billion 1's.
X = np.ones(1000000000, dtype=np.int)
Y = np.ones(1000000000, dtype=np.int)
# Add 2 * Y to X, element by element:
# Slowest
%time X = X + 2.0 * Y
100 loops, best of 3: 3.61 ms per loop
# A bit faster
%time X = X + 2 * Y
100 loops, best of 3: 3.47 ms per loop
# Much faster
%time X += 2 * Y
100 loops, best of 3: 2.79 ms per loop
# Fastest
%time np.add(X, Y, out=X); np.add(X, Y, out=X)
100 loops, best of 3: 1.57 ms per loop
That's a 2.3x speed improvement (from 3.61 ms to 1.57 ms) on a simple vector operation (your mileage will vary!).[1] This only scratches the surface. The guide goes into quite a bit of explicit detail about how Numpy arrays are constructed and stored in memory and always explains the underlying reasons why some operations are faster than others. In addition, the guide has a section titled "Beyond Numpy" that points to even more ways of improving performance, e.g., by using Cython,…
danso · 2016-09-16
I actually have no idea about that. I don't think there's an equivalent to R's base graphics, so that would seem to make matplotlib the closest thing to a standard -- seaborn [0], which I've seen used a lot lately for more advanced dataviz, lives atop it, but it's also relatively new.
People seem to have conflicted feelings about matplotlib, maybe because of its origin in MATLAB? Not that Matlab itself is bad, but I think the decision to make matplotlib's API comfortable for MATLAB users seems to cause confusion to contemporary users, even before the usual 2.x vs 3.x issues (matplotlib ported to 3.x a few years ago but many users still write Python in the 2.x style.)
Anecdotally, I feel like I see advice like "Just use plotly" more than I see recommendations to actually learn matplotlib. I actually gave up on matplotlib until I stumbled upon this comprehensive tutorial, which covers the basics and many elaborate use cases. If there's a book that does it better, I haven't heard about it:
http://www.labri.fr/perso/nrougier/teaching/matplotlib/
The matplotlib site itself is chockful of well-documented examples, but some of them seem to be significantly more verbose than they need to be. My impression is that the library is stable/ubiquitous enough that there isn't a big movement to overhaul things. Last time I looked at the API changes for v2.0 [1] (1.5.3 is stable), most of the changes had to do with default styles and stylesheets, which is non-trivial given the number of…
douglasdrumz · 2022-10-07
At section 0.3, the author links to his CSS file: https://www.labri.fr/perso/nrougier/GTD/GTD.css
It seems to be of his own authorship, not a framework.
karmickoala · 2020-02-12
From Python to Numpy
https://www.labri.fr/perso/nrougier/from-python-to-numpy/
A book teaching Numpy vectorization.
tu7001 · 2017-01-11
I just check the first example from introduction to vectorization: http://www.labri.fr/perso/nrougier/from-python-to-numpy/#id5, (add_python and add_numpy) and benchmark results are nearly the same: 75.4ns and 77.7ns accordingly.
simonh · 2015-09-03
Modern computer operating systems won't let you arbitrarily switch pixels on the screen on or off, so you'd need to either write a program that uses a GUI library to create a window, controls, etc, or generate an image file you can open in a viewer.
For Python, matplotlib(1) will let you generate plots and graphs, including simple x/y graphs, or you could use the built-in TkInter(2) library to do a simple GUI with a drawing canvas.
(1)http://www.labri.fr/perso/nrougier/teaching/matplotlib/
(2) http://www.python-course.eu/tkinter_canvas.php
goldenkey · 2022-07-28
This work is subtly related to chaos theory.
The nth coefficient of the ith Mandelbrot polynomial lemniscate [3] is equal to the number of possible binary trees with n nodes of height i or less. This is because z -> z^2 + c reflects coefficients recursively produced by repeated applications of the binomial theorem.
When n becomes <= i, the nth coefficient stabilizes, converging to the nth Catalan number, which is the number of possible binary trees with n nodes. The nth Catalan number is also the number of triangulations of an n+2-gon.
https://en.m.wikipedia.org/wiki/Catalan_number#Applications_in_combina…
Now, there is a 1-to-1 bijective mapping between binary trees of height n and node count i, and n+2 sided polygon triangulations with i segments.
https://www.r-bloggers.com/2015/07/catalan-numbers-fortriangulationsga…
In fact, the same associahedron in "Flipping until you are lost" is mentioned here:
https://www.researchgate.net/figure/The-bijection-between-binary-plane…
What is the significance of all of this? There is currently no closed form approximation for these numbers. As simple as it might sound, we have no closed form for the number of binary trees with i nodes of height <= n. If we did, we could approximate the Mandelbrot and it would unlock new frontiers of understanding chaos theory.
Philippe Flajolet, a now-deceased titan of analytic combinatorics [2] wrote some papers on the…
danblick · 2015-06-08
The article isn't loading for me right now, but I thought I'd mention co-inductive types and how they relate to "interaction".
In Coq, co-inductive types are used to model infinite objects like (never-ending) streams or (non-terminating) program executions.
Inductive List (A: Set): Set :=
| Nil: List A
| Cons : A -> List A -> List A.
CoInductive Stream (A: Set): Set :=
| SCons: A -> Stream A -> Stream A.
Fixpoint len {A: Set} (x: List A): nat :=
match x with
| Nil => 0
| Cons _ y => 1 + len y
end.
CoFixpoint ones : Stream nat :=
SCons nat 1 ones.
If you want to talk about how systems interact with the world, you can use bisimilarity relations to prove "these two systems interact with the world in the same way".
You can also use co-inductive types to embed the temporal logic of actions (TLA) in Coq; TLA is the language Leslie Lamport works with for "Specifying Systems".
* http://www.labri.fr/perso/casteran/RecTutorial.pdf
* http://www.amazon.com/Specifying-Systems-Language-Hardware-Engineers/d…
* http://en.wikipedia.org/wiki/Bisimulation
asicsp · 2021-01-08
Here's more awesome resources:
* Pandas: https://pandas.pydata.org/docs/getting_started/index.html
* DSP: https://greenteapress.com/thinkdsp/html/index.html
* Numpy: https://www.labri.fr/perso/nrougier/from-python-to-numpy/
* Data Carpentry: https://datacarpentry.org/lessons/
* Data science path: https://github.com/ossu/data-science