Commit ee058b26 authored by Aitor Perez's avatar Aitor Perez

updated presentation

parent 2fa1e5de
......@@ -29,22 +29,28 @@ l = [1, 2, 5, 6]
# Access elements : l[0] = 1, l[2] = 5, l[-1] = 6
# Slice : l[1:3] = [2, 5]
# Nested list
nl = [['vive', 'la'], ['saucisse', 2], 'Toulouse']
# Access sublist element : nl[0] = ['vive', 'la']
# Access final element : nl[0][1] = 'la', nl[1][0] = 'saucisse'
# List comprehension
l1 = [i**2 for i in range(10)]
# l1 = [0, 1, 4, 9, 16, 25, 36, 49, 64, 81]
l2 = [3*n + 1 for n in range(10) if n % 2 == 0]
# l2 = [7, 13, 19, 25, 31]
# %% Slide: Dictionaries
# Dictionaries
d = {'first': 1,
'second': 'two',
'third': {'A': [3, 4, 5], 'B': True}}
'third': {'A': [3, 4, 5],
'B': True}}
# Access elements : d['first'] = 1, d['second'] = 'two'
# d['third'] = {'A': [3, 4, 5], 'B': True}
# d['third']['A'] = [3, 4, 5]
......@@ -79,9 +85,7 @@ while i < 10:
def add(a, b=1): # NO NEED to define the type, b has a default value
return a + b
# add(0.5, 2) = 2.5
# add(1) = 2
# add() -> ERROR
# add(0.5, 2) = 2.5, add(1) = 2, add() -> ERROR
# Possibility of having a variable number of parameters and outputs
......@@ -91,16 +95,15 @@ def doSomething(x, y, z, p1=1, p3='red'):
return out1, out2 # returns a list of two elements
out = doSomething(1, 2, 3) # out[0] = 3, out[1] = 'red3'
# -- shorter equivalent way
value, flag = doSomething(1, 2, 3) # value = 3, flag = 'red3'
# General form of a function (cf. function plot of matplotlib)
def myFuncThatDoThings(*args, **kwargs):
def myFuncThatDoesThings(*args, **kwargs):
pass
# args is a list, with non keyword argument (ex: a in add)
# kwargs is a dictionnary, with keywords arguments (ex: b=1 in add)
# * and ** are just a notation to 'unpack' list and dictionnary
# kwargs is a dictionary, with keywords arguments (ex: b=1 in add)
# forget about * and **, they are just a notation to 'unpack' them
# keywords arguments ALWAYS at the end (ex: add(b=1, a) -> ERROR)
# %% Slide: File IO
......
presentation/img/code-dictionaries.png

58.6 KB | W: | H:

presentation/img/code-dictionaries.png

60.7 KB | W: | H:

presentation/img/code-dictionaries.png
presentation/img/code-dictionaries.png
presentation/img/code-dictionaries.png
presentation/img/code-dictionaries.png
  • 2-up
  • Swipe
  • Onion skin
presentation/img/code-functions.png

54.5 KB | W: | H:

presentation/img/code-functions.png

169 KB | W: | H:

presentation/img/code-functions.png
presentation/img/code-functions.png
presentation/img/code-functions.png
presentation/img/code-functions.png
  • 2-up
  • Swipe
  • Onion skin
presentation/img/code-lists.png

81.5 KB | W: | H:

presentation/img/code-lists.png

95.1 KB | W: | H:

presentation/img/code-lists.png
presentation/img/code-lists.png
presentation/img/code-lists.png
presentation/img/code-lists.png
  • 2-up
  • Swipe
  • Onion skin
No preview for this file type
......@@ -261,58 +261,29 @@
\end{center}
\begin{block}{Numpy : interface for array manipulation}
\begin{itemize}
\item Data are stored in contiguous memory location
\item Operations on arrays are done in C
\item Data stored in contiguous memory location
\item Operations on arrays in C
\item Uses optimized C library for algebraic computation (BLAS)
\end{itemize}
\end{block}See also \href{https://docs.scipy.org/doc/scipy/reference/tutorial/}{Scipy tutorials} on the Internet
\end{block}
\begin{block}{Scipy : companion package for scientific computing}
\begin{itemize}
\item Many functions for linear algebra, optimization, interpolation, ...
\item Interface with C and Fortran optimized routine\\
(LAPACK, FFTW, QUADPACK, ... and many others !)
\item See \href{https://docs.scipy.org/doc/scipy/reference/tutorial/}{Scipy tutorials} on the Internet
\end{itemize}
\end{block}
\vspace*{-10pt}
See also \href{https://docs.scipy.org/doc/scipy/reference/tutorial/}{Scipy tutorials} on the Internet
\end{frame}
\begin{frame}{Numpy basics I}
\includegraphics[width=0.9\linewidth]{code-numpy1}
\end{frame}
\begin{frame}{Numpy basics II}
\includegraphics[width=0.8\linewidth]{code-numpy2}
\end{frame}
\begin{frame}{To go further with Numpy and Scipy}
% \includegraphics[width=0.9\linewidth]{code-scipy}
\small
\vspace{5pt}
\begin{block}{Numpy examples :}
\begin{itemize}
\item Call Fortran routines to accelerate computations
\item Easily read and write files with single line coding
\end{itemize}
\end{block}
\vspace*{-7pt}
... and more in
\href{https://gitlab.unige.ch/Thibaut.Lunet/python-math/tree/master/examples/numpy}{python-math/examples/numpy} directory
\vspace*{6pt}
\begin{block}{Scipy examples :}
\begin{itemize}
\item Data regression using least square minimization
\item Eigenvalue computation of the tri-dimensional advection operator
\end{itemize}
\end{block}
\vspace*{-7pt}
... and more in
\href{https://gitlab.unige.ch/Thibaut.Lunet/python-math/tree/master/examples/scipy}{python-math/examples/scipy} directory \\
\end{frame}
\begin{frame}{Data visualization with Matplotlib I}
\includegraphics[width=0.8\linewidth]{code-matplotlib1}
......@@ -328,6 +299,30 @@
\href{https://gitlab.unige.ch/Thibaut.Lunet/python-math/tree/master/examples/matplotlib}{python-math/examples/matplotlib} directory
\end{frame}
\begin{frame}{To go further with Numpy and Scipy}
% \includegraphics[width=0.9\linewidth]{code-scipy}
\small
\vspace{5pt}
\begin{block}{Numpy examples :}
\begin{itemize}
\item Call Fortran routines to accelerate computations
\item Easily read and write files with single line coding
\end{itemize}
\end{block}
\vspace*{-7pt}
... and more in
\href{https://gitlab.unige.ch/Thibaut.Lunet/python-math/tree/master/examples/numpy}{python-math/examples/numpy} directory
\vspace*{6pt}
\begin{block}{Scipy examples :}
\begin{itemize}
\item Data regression using least square minimization
\item Eigenvalue computation of the tri-dimensional advection operator
\end{itemize}
\end{block}
\vspace*{-7pt}
... and more in
\href{https://gitlab.unige.ch/Thibaut.Lunet/python-math/tree/master/examples/scipy}{python-math/examples/scipy} directory \\
\end{frame}
\begin{frame}{Sympy, more than just another py-word game}
If you are interested in
......@@ -364,9 +359,9 @@
Here was just presented a tiny part of python application for researchers\\
$\Rightarrow$ many other nice things are also possible
\begin{itemize}
\item Writing code documentation, and include math formula
\item Writing code documentation, and include math formulae
\item Create and organize packages for particular applications
\item Benefit from the object-oriented programming to facilitate modularity and code development
\item Use the object-oriented programming paradigm for modularity and code development
\end{itemize}
Do not hesitate to look at \href{https://gitlab.unige.ch/Thibaut.Lunet/python-math/tree/master/examples}{python-math/examples} for other advanced examples ...
\begin{center}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment