Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add jupyter book version #104

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
205 changes: 205 additions & 0 deletions 01-preface-with-jupyter-book.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
Preface
===============================================================================

.. contents:: **Contents**
:local:


About the author
----------------

`Nicolas P. Rougier`_ is a full-time research scientist at Inria_ which is the
French national institute for research in computer science and control. This is
a public scientific and technological establishment (EPST) under the double
supervision of the Research & Education Ministry, and the Ministry of Economy
Finance and Industry. Nicolas P. Rougier is working within the Mnemosyne_
project which lies at the frontier between integrative and computational
neuroscience in association with the `Institute of Neurodegenerative
Diseases`_, the Bordeaux laboratory for research in computer science
(LaBRI_), the `University of Bordeaux`_ and the national center for scientific
research (CNRS_).

He has been using Python for more than 15 years and NumPy for more than 10
years for modeling in neuroscience, machine learning and for advanced
visualization (OpenGL). Nicolas P. Rougier is the author of several online
resources and tutorials (Matplotlib, NumPy, OpenGL) and he's teaching Python,
NumPy and scientific visualization at the University of Bordeaux and in various
conferences and schools worldwide (SciPy, EuroScipy, etc). He's also the author
of the popular article `Ten Simple Rules for Better Figures`_ and a popular
`matplotlib tutorial
<http://www.labri.fr/perso/nrougier/teaching/matplotlib/matplotlib.html>`_.


About this book
---------------

This book has been written in |ReST|_ format and generated using the
`rst2html.py` command line available from the docutils_ python package.

If you want to rebuild the html output, from the top directory, type:

.. code-block::

$ rst2html.py --link-stylesheet --cloak-email-addresses \
--toc-top-backlinks --stylesheet=book.css \
--stylesheet-dirs=. book.rst book.html

The sources are available from https://github.com/rougier/from-python-to-numpy.

.. |ReST| replace:: restructured text
.. _ReST: http://docutils.sourceforge.net/rst.html
.. _docutils: http://docutils.sourceforge.net/


About the Jupyter Book
++++++++++++++++++++++

**html version**

To generate the `Jupyter Book`_ from the top directory:

1. Install the most up to date version of jupyter-book:

.. code-block::

$ pip install -U jupyter-book

2. Go to the root directory of the repository and run:

.. code-block::

$ jupyter-book build . --path-output jupyter-book/.

3. Copy the data folder into the html directory:

.. code-block::

$ cp -r data jupyter-book/_build/html/.

4. Open Jupyter-book at: `jupyter-book/_build/html/index.html`


**pdf version**

To generate a pdf version of the book, you will need pyppeteer_ installed,
then in the top directory, run:

.. code-block::

$ jupyter-book build . --builder pdfhtml --path-output jupyter-book/.

The pdf version of the book is available at `jupyter-book/_build/pdf/book.pdf`


**Publish using GiHub Pages**

You can automatically push the build files using `ghp-import package`_. ghp-import
is a lightweight Python package that makes it easy to push HTML content to a GitHub repository.

More info on how to publish a jupyter-book with gh-page can be found here:
https://jupyterbook.org/publish/gh-pages.html.

More info on how to publish on a custom (sub)domain can be found on
https://stackoverflow.com/questions/46455900/subdomain-of-website-for-github-pages-project


.. _Jupyter Book: https://jupyterbook.org
.. _pyppeteer: https://pypi.org/project/pyppeteer/
.. _ghp-import package: https://github.com/davisp/ghp-import



Prerequisites
+++++++++++++

This is not a Python beginner guide and you should have an intermediate level in
Python and ideally a beginner level in NumPy. If this is not the case, have
a look at the bibliography_ for a curated list of resources.


Conventions
+++++++++++

We will use usual naming conventions. If not stated explicitly, each script
should import NumPy, scipy and matplotlib as:

.. code-block:: python

import numpy as np
import scipy as sp
import matplotlib.pyplot as plt


We'll use up-to-date versions (at the date of writing, i.e. January, 2017) of the
different packages:

=========== =========
Packages Version
=========== =========
Python 3.6.0
----------- ---------
NumPy 1.12.0
----------- ---------
Scipy 0.18.1
----------- ---------
Matplotlib 2.0.0
=========== =========

How to contribute
+++++++++++++++++

If you want to contribute to this book, you can:

* Review chapters (please contact me)
* Report issues (https://github.com/rougier/from-python-to-numpy/issues)
* Suggest improvements (https://github.com/rougier/from-python-to-numpy/pulls)
* Correct English (https://github.com/rougier/from-python-to-numpy/issues)
* Design a better and more responsive html template for the book.
* Star the project (https://github.com/rougier/from-python-to-numpy)

Publishing
++++++++++

If you're an editor interested in publishing this book, you can `contact me
<mailto:Nicolas.Rougier@inria.fr>`_ if you agree to have this version and all
subsequent versions open access (i.e. online at `this address
<http://www.labri.fr/perso/nrougier/from-python-to-numpy>`_), you know how to
deal with `restructured text <http://docutils.sourceforge.net/rst.html>`_ (Word
is not an option), you provide a real added-value as well as supporting
services, and more importantly, you have a truly amazing latex book template
(and be warned that I'm a bit picky about typography & design: `Edward Tufte
<https://www.edwardtufte.com/tufte/>`_ is my hero). Still here?


License
--------

**Book**

This work is licensed under a `Creative Commons Attribution-Non Commercial-Share
Alike 4.0 International License <https://creativecommons.org/licenses/by-nc-sa/4.0/>`_. You are free to:

* **Share** — copy and redistribute the material in any medium or format
* **Adapt** — remix, transform, and build upon the material

The licensor cannot revoke these freedoms as long as you follow the license terms.

**Code**

The code is licensed under the `OSI-approved BSD 2-Clause License
<LICENSE-code.txt>`_.


.. --- Links ------------------------------------------------------------------
.. _Nicolas P. Rougier: http://www.labri.fr/perso/nrougier/
.. _Inria: http://www.inria.fr/en
.. _Mnemosyne: http://www.inria.fr/en/teams/mnemosyne
.. _LaBRI: https://www.labri.fr/
.. _CNRS: http://www.cnrs.fr/index.php
.. _University of Bordeaux: http://www.u-bordeaux.com/
.. _Institute of Neurodegenerative Diseases:
http://www.imn-bordeaux.org/en/
.. _Ten Simple Rules for Better Figures:
http://dx.doi.org/10.1371/journal.pcbi.1003833
.. ----------------------------------------------------------------------------

14 changes: 14 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Book settings
title: From Python to Numpy
author: Nicolas P. Rougier; Loïc Houpert
logo: data/cubes.png



# # Information about where the book exists on the web
# repository:
# url : https://github.com/yourusername/yourbookrepo
#
# # Configure your Binder links, such as the URL of the BinderHub.
# launch_buttons:
# binderhub_url : https://mybinder.org
14 changes: 14 additions & 0 deletions _toc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
format: jb-article
root: book-jupyterbook
title: From Python to Numpy
sections:
- file: 01-preface-with-jupyter-book
- file: 02-introduction
- file: 03-anatomy
- file: 04-code-vectorization
- file: 05-problem-vectorization
- file: 06-custom-vectorization
- file: 07-beyond-numpy
- file: 08-conclusion
- file: 09-quick-reference
- file: 10-bibliography
100 changes: 100 additions & 0 deletions book-jupyterbook.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
.. ----------------------------------------------------------------------------
.. Title: From Python to Numpy
.. Author: Nicolas P. Rougier
.. Date: January 2017
.. License: Creative Commons Share-Alike Non-Commercial International 4.0
.. ----------------------------------------------------------------------------

.. meta::
:description: An open-source book about numpy vectorization techniques, based on experience, practice and descriptive examples
:viewport: width=device-width, initial-scale=1, maximum-scale=1

.. |date| date:: %B %Y

===============================================================================
From Python to Numpy
===============================================================================

Copyright (c) 2021 - Nicolas P. Rougier <Nicolas.Rougier@inria.fr> & Loïc Houpert <loic@lhoupert.fr>

.. default-role:: code

.. container:: title-logos

.. image:: data/cc.large.png
:width: 40px
.. image:: data/by.large.png
:width: 40px
.. image:: data/sa.large.png
:width: 40px
.. image:: data/nc.large.png
:width: 40px

|
| Latest version - |date|
| DOI: `10.5281/zenodo.225783 <http://doi.org/10.5281/zenodo.225783>`_

.. ----------------------------------------------------------------------------
.. container:: title-logos

.. image:: data/cubes.png
:width: 100%

.. ----------------------------------------------------------------------------

There are already a fair number of books about Numpy (see Bibliography_) and a
legitimate question is to wonder if another book is really necessary. As you
may have guessed by reading these lines, my personal answer is yes, mostly
because I think there is room for a different approach concentrating on the
migration from Python to Numpy through vectorization. There are a lot of
techniques that you don't find in books and such techniques are mostly learned
through experience. The goal of this book is to explain some of these
techniques and to provide an opportunity for making this experience in the
process.

**Website:** http://www.labri.fr/perso/nrougier/from-python-to-numpy


.. ----------------------------------------------------------------------------
.. contents:: **Table of Contents**
:class: main-content
:depth: 2

|
|

**Disclaimer:** All external pictures should have associated credits. If there
are missing credits, please tell me, I will correct it. Similarly, all excerpts
should be sourced (wikipedia mostly). If not, this is an error and I will
correct it as soon as you tell me.


The book is open-access (you're reading it) but **if you insist on buying it**,
my advice would be to read it first and then decide if you still want to buy it
(!?). If this is the case, you can do it via `Paypal
<https://www.paypal.me/NicolasPRougier/>`_, price is free (`5 euros
<https://www.paypal.me/NicolasPRougier/5>`_, `10 euros
<https://www.paypal.me/NicolasPRougier/10>`_, `25 euros
<https://www.paypal.me/NicolasPRougier/25>`_). You won't get anything extra but
it might help me with the writing of the upcoming **Python and OpenGL for
Scientific Visualization** (May 2018).


.. ----------------------------------------------------------------------------
.. |WIP| image:: https://img.shields.io/badge/status-WIP-orange.svg?style=flat-square

.. ----------------------------------------------------------------------------
.. include:: 01-preface-with-jupyter-book.rst
.. include:: 02-introduction.rst
.. include:: 03-anatomy.rst
.. include:: 04-code-vectorization.rst
.. include:: 05-problem-vectorization.rst
.. include:: 06-custom-vectorization.rst
.. include:: 07-beyond-numpy.rst
.. include:: 08-conclusion.rst
.. include:: 09-quick-reference.rst
.. include:: 10-bibliography.rst


.. --- Compilation ------------------------------------------------------------
.. rst2html.py --link-stylesheet --stylesheet=markdown.css book.rst book.html
Empty file modified fonts/LICENSE.txt
100755 → 100644
Empty file.
Empty file modified fonts/SourceCodePro-Light.otf.woff
100755 → 100644
Empty file.
Empty file modified fonts/SourceCodePro-Regular.otf.woff
100755 → 100644
Empty file.
Empty file modified fonts/SourceSansPro-It.otf.woff
100755 → 100644
Empty file.
Empty file modified fonts/SourceSansPro-Light.otf.woff
100755 → 100644
Empty file.
Empty file modified fonts/SourceSansPro-LightIt.otf.woff
100755 → 100644
Empty file.
Empty file modified fonts/SourceSansPro-Regular.otf.woff
100755 → 100644
Empty file.
Binary file not shown.
Binary file added jupyter-book/_build/.doctrees/01-preface.doctree
Binary file not shown.
Binary file not shown.
Binary file added jupyter-book/_build/.doctrees/03-anatomy.doctree
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added jupyter-book/_build/.doctrees/README.doctree
Binary file not shown.
Binary file not shown.
Binary file added jupyter-book/_build/.doctrees/book.doctree
Binary file not shown.
Binary file added jupyter-book/_build/.doctrees/environment.pickle
Binary file not shown.
1 change: 1 addition & 0 deletions jupyter-book/_build/.doctrees/glue_cache.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
4 changes: 4 additions & 0 deletions jupyter-book/_build/html/.buildinfo
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: a32e1b8b330eae229df4c3dbb6c01ad7
tags: 645f666f9bcd5a90fca523b33c5a78b7