Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mooc-rr
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
f04e8fe5c70126322d2d4da9d1938c9c
mooc-rr
Commits
700e30fa
Commit
700e30fa
authored
Jun 06, 2024
by
Antoine
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: exo2
parent
eba360d9
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
277 additions
and
75 deletions
+277
-75
exercice_python_fr.html
module2/exo2/exercice_python_fr.html
+252
-0
exercice_python_fr.org
module2/exo2/exercice_python_fr.org
+25
-75
No files found.
module2/exo2/exercice_python_fr.html
0 → 100644
View file @
700e30fa
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html
xmlns=
"http://www.w3.org/1999/xhtml"
lang=
"fr"
xml:lang=
"fr"
>
<head>
<!-- 2024-06-06 Thu 13:37 -->
<meta
http-equiv=
"Content-Type"
content=
"text/html;charset=utf-8"
/>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1"
/>
<title>
Exercice 2
</title>
<meta
name=
"author"
content=
"Antoine Geimer"
/>
<meta
name=
"generator"
content=
"Org Mode"
/>
<style>
#content
{
max-width
:
60em
;
margin
:
auto
;
}
.title
{
text-align
:
center
;
margin-bottom
:
.2em
;
}
.subtitle
{
text-align
:
center
;
font-size
:
medium
;
font-weight
:
bold
;
margin-top
:
0
;
}
.todo
{
font-family
:
monospace
;
color
:
red
;
}
.done
{
font-family
:
monospace
;
color
:
green
;
}
.priority
{
font-family
:
monospace
;
color
:
orange
;
}
.tag
{
background-color
:
#eee
;
font-family
:
monospace
;
padding
:
2px
;
font-size
:
80%
;
font-weight
:
normal
;
}
.timestamp
{
color
:
#bebebe
;
}
.timestamp-kwd
{
color
:
#5f9ea0
;
}
.org-right
{
margin-left
:
auto
;
margin-right
:
0px
;
text-align
:
right
;
}
.org-left
{
margin-left
:
0px
;
margin-right
:
auto
;
text-align
:
left
;
}
.org-center
{
margin-left
:
auto
;
margin-right
:
auto
;
text-align
:
center
;
}
.underline
{
text-decoration
:
underline
;
}
#postamble
p
,
#preamble
p
{
font-size
:
90%
;
margin
:
.2em
;
}
p
.verse
{
margin-left
:
3%
;
}
pre
{
border
:
1px
solid
#e6e6e6
;
border-radius
:
3px
;
background-color
:
#f2f2f2
;
padding
:
8pt
;
font-family
:
monospace
;
overflow
:
auto
;
margin
:
1.2em
;
}
pre
.src
{
position
:
relative
;
overflow
:
auto
;
}
pre
.src
:before
{
display
:
none
;
position
:
absolute
;
top
:
-8px
;
right
:
12px
;
padding
:
3px
;
color
:
#555
;
background-color
:
#f2f2f299
;
}
pre
.src
:hover:before
{
display
:
inline
;
margin-top
:
14px
;}
/* Languages per Org manual */
pre
.src-asymptote
:before
{
content
:
'Asymptote'
;
}
pre
.src-awk
:before
{
content
:
'Awk'
;
}
pre
.src-authinfo
::before
{
content
:
'Authinfo'
;
}
pre
.src-C
:before
{
content
:
'C'
;
}
/* pre.src-C++ doesn't work in CSS */
pre
.src-clojure
:before
{
content
:
'Clojure'
;
}
pre
.src-css
:before
{
content
:
'CSS'
;
}
pre
.src-D
:before
{
content
:
'D'
;
}
pre
.src-ditaa
:before
{
content
:
'ditaa'
;
}
pre
.src-dot
:before
{
content
:
'Graphviz'
;
}
pre
.src-calc
:before
{
content
:
'Emacs Calc'
;
}
pre
.src-emacs-lisp
:before
{
content
:
'Emacs Lisp'
;
}
pre
.src-fortran
:before
{
content
:
'Fortran'
;
}
pre
.src-gnuplot
:before
{
content
:
'gnuplot'
;
}
pre
.src-haskell
:before
{
content
:
'Haskell'
;
}
pre
.src-hledger
:before
{
content
:
'hledger'
;
}
pre
.src-java
:before
{
content
:
'Java'
;
}
pre
.src-js
:before
{
content
:
'Javascript'
;
}
pre
.src-latex
:before
{
content
:
'LaTeX'
;
}
pre
.src-ledger
:before
{
content
:
'Ledger'
;
}
pre
.src-lisp
:before
{
content
:
'Lisp'
;
}
pre
.src-lilypond
:before
{
content
:
'Lilypond'
;
}
pre
.src-lua
:before
{
content
:
'Lua'
;
}
pre
.src-matlab
:before
{
content
:
'MATLAB'
;
}
pre
.src-mscgen
:before
{
content
:
'Mscgen'
;
}
pre
.src-ocaml
:before
{
content
:
'Objective Caml'
;
}
pre
.src-octave
:before
{
content
:
'Octave'
;
}
pre
.src-org
:before
{
content
:
'Org mode'
;
}
pre
.src-oz
:before
{
content
:
'OZ'
;
}
pre
.src-plantuml
:before
{
content
:
'Plantuml'
;
}
pre
.src-processing
:before
{
content
:
'Processing.js'
;
}
pre
.src-python
:before
{
content
:
'Python'
;
}
pre
.src-R
:before
{
content
:
'R'
;
}
pre
.src-ruby
:before
{
content
:
'Ruby'
;
}
pre
.src-sass
:before
{
content
:
'Sass'
;
}
pre
.src-scheme
:before
{
content
:
'Scheme'
;
}
pre
.src-screen
:before
{
content
:
'Gnu Screen'
;
}
pre
.src-sed
:before
{
content
:
'Sed'
;
}
pre
.src-sh
:before
{
content
:
'shell'
;
}
pre
.src-sql
:before
{
content
:
'SQL'
;
}
pre
.src-sqlite
:before
{
content
:
'SQLite'
;
}
/* additional languages in org.el's org-babel-load-languages alist */
pre
.src-forth
:before
{
content
:
'Forth'
;
}
pre
.src-io
:before
{
content
:
'IO'
;
}
pre
.src-J
:before
{
content
:
'J'
;
}
pre
.src-makefile
:before
{
content
:
'Makefile'
;
}
pre
.src-maxima
:before
{
content
:
'Maxima'
;
}
pre
.src-perl
:before
{
content
:
'Perl'
;
}
pre
.src-picolisp
:before
{
content
:
'Pico Lisp'
;
}
pre
.src-scala
:before
{
content
:
'Scala'
;
}
pre
.src-shell
:before
{
content
:
'Shell Script'
;
}
pre
.src-ebnf2ps
:before
{
content
:
'ebfn2ps'
;
}
/* additional language identifiers per "defun org-babel-execute"
in ob-*.el */
pre
.src-cpp
:before
{
content
:
'C++'
;
}
pre
.src-abc
:before
{
content
:
'ABC'
;
}
pre
.src-coq
:before
{
content
:
'Coq'
;
}
pre
.src-groovy
:before
{
content
:
'Groovy'
;
}
/* additional language identifiers from org-babel-shell-names in
ob-shell.el: ob-shell is the only babel language using a lambda to put
the execution function name together. */
pre
.src-bash
:before
{
content
:
'bash'
;
}
pre
.src-csh
:before
{
content
:
'csh'
;
}
pre
.src-ash
:before
{
content
:
'ash'
;
}
pre
.src-dash
:before
{
content
:
'dash'
;
}
pre
.src-ksh
:before
{
content
:
'ksh'
;
}
pre
.src-mksh
:before
{
content
:
'mksh'
;
}
pre
.src-posh
:before
{
content
:
'posh'
;
}
/* Additional Emacs modes also supported by the LaTeX listings package */
pre
.src-ada
:before
{
content
:
'Ada'
;
}
pre
.src-asm
:before
{
content
:
'Assembler'
;
}
pre
.src-caml
:before
{
content
:
'Caml'
;
}
pre
.src-delphi
:before
{
content
:
'Delphi'
;
}
pre
.src-html
:before
{
content
:
'HTML'
;
}
pre
.src-idl
:before
{
content
:
'IDL'
;
}
pre
.src-mercury
:before
{
content
:
'Mercury'
;
}
pre
.src-metapost
:before
{
content
:
'MetaPost'
;
}
pre
.src-modula-2
:before
{
content
:
'Modula-2'
;
}
pre
.src-pascal
:before
{
content
:
'Pascal'
;
}
pre
.src-ps
:before
{
content
:
'PostScript'
;
}
pre
.src-prolog
:before
{
content
:
'Prolog'
;
}
pre
.src-simula
:before
{
content
:
'Simula'
;
}
pre
.src-tcl
:before
{
content
:
'tcl'
;
}
pre
.src-tex
:before
{
content
:
'TeX'
;
}
pre
.src-plain-tex
:before
{
content
:
'Plain TeX'
;
}
pre
.src-verilog
:before
{
content
:
'Verilog'
;
}
pre
.src-vhdl
:before
{
content
:
'VHDL'
;
}
pre
.src-xml
:before
{
content
:
'XML'
;
}
pre
.src-nxml
:before
{
content
:
'XML'
;
}
/* add a generic configuration mode; LaTeX export needs an additional
(add-to-list 'org-latex-listings-langs '(conf " ")) in .emacs */
pre
.src-conf
:before
{
content
:
'Configuration File'
;
}
table
{
border-collapse
:
collapse
;
}
caption
.t-above
{
caption-side
:
top
;
}
caption
.t-bottom
{
caption-side
:
bottom
;
}
td
,
th
{
vertical-align
:
top
;
}
th
.org-right
{
text-align
:
center
;
}
th
.org-left
{
text-align
:
center
;
}
th
.org-center
{
text-align
:
center
;
}
td
.org-right
{
text-align
:
right
;
}
td
.org-left
{
text-align
:
left
;
}
td
.org-center
{
text-align
:
center
;
}
dt
{
font-weight
:
bold
;
}
.footpara
{
display
:
inline
;
}
.footdef
{
margin-bottom
:
1em
;
}
.figure
{
padding
:
1em
;
}
.figure
p
{
text-align
:
center
;
}
.equation-container
{
display
:
table
;
text-align
:
center
;
width
:
100%
;
}
.equation
{
vertical-align
:
middle
;
}
.equation-label
{
display
:
table-cell
;
text-align
:
right
;
vertical-align
:
middle
;
}
.inlinetask
{
padding
:
10px
;
border
:
2px
solid
gray
;
margin
:
10px
;
background
:
#ffffcc
;
}
#org-div-home-and-up
{
text-align
:
right
;
font-size
:
70%
;
white-space
:
nowrap
;
}
textarea
{
overflow-x
:
auto
;
}
.linenr
{
font-size
:
smaller
}
.code-highlighted
{
background-color
:
#ffff00
;
}
.org-info-js_info-navigation
{
border-style
:
none
;
}
#org-info-js_console-label
{
font-size
:
10px
;
font-weight
:
bold
;
white-space
:
nowrap
;
}
.org-info-js_search-highlight
{
background-color
:
#ffff00
;
color
:
#000000
;
font-weight
:
bold
;
}
.org-svg
{
}
</style>
<link
rel=
"stylesheet"
type=
"text/css"
href=
"http://www.pirilampo.org/styles/readtheorg/css/htmlize.css"
/>
<link
rel=
"stylesheet"
type=
"text/css"
href=
"http://www.pirilampo.org/styles/readtheorg/css/readtheorg.css"
/>
<script
src=
"https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"
></script>
<script
src=
"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"
></script>
<script
type=
"text/javascript"
src=
"http://www.pirilampo.org/styles/lib/js/jquery.stickytableheaders.js"
></script>
<script
type=
"text/javascript"
src=
"http://www.pirilampo.org/styles/readtheorg/js/readtheorg.js"
></script>
</head>
<body>
<div
id=
"content"
class=
"content"
>
<h1
class=
"title"
>
Exercice 2
</h1>
<p>
Récuperer les données et les visualiser:
</p>
<div
class=
"org-src-container"
>
<pre
class=
"src src-python"
><span
style=
"color: #b877db;"
>
import
</span>
numpy
<span
style=
"color: #b877db;"
>
as
</span>
np
<span
style=
"color: #e95678;"
>
data
</span>
= np.genfromtxt(
<span
style=
"color: #fab795;"
>
'data.csv'
</span>
, delimiter=
<span
style=
"color: #fab795;"
>
', '
</span>
)
<span
style=
"color: #b877db;"
>
print
</span>
(data)
<span
style=
"color: #6c6f93; background-color: #292b36; font-style: italic;"
>
#
</span><span
style=
"color: #6c6f93; background-color: #292b36; font-style: italic;"
>
visualizing the data
</span>
</pre>
</div>
<pre
class=
"example"
>
[14. 7.6 11.2 12.8 12.5 9.9 14.9 9.4 16.9 10.2 14.9 18.1 7.3 9.8
10.9 12.2 9.9 2.9 2.8 15.4 15.7 9.7 13.1 13.2 12.3 11.7 16. 12.4
17.9 12.2 16.2 18.7 8.9 11.9 12.1 14.6 12.1 4.7 3.9 16.9 16.8 11.3
14.4 15.7 14. 13.6 18. 13.6 19.9 13.7 17. 20.5 9.9 12.5 13.2 16.1
13.5 6.3 6.4 17.6 19.1 12.8 15.5 16.3 15.2 14.6 19.1 14.4 21.4 15.1
19.6 21.7 11.3 15. 14.3 16.8 14. 6.8 8.2 19.9 20.4 14.6 16.4 18.7
16.8 15.8 20.4 15.8 22.4 16.2 20.3 23.4 12.1 15.5 15.4 18.4 15.7 10.2
8.9 21. ]
</pre>
<p>
Statistiques:
</p>
<div
class=
"org-src-container"
>
<pre
class=
"src src-python"
><span
style=
"color: #b877db;"
>
print
</span>
(f
<span
style=
"color: #fab795;"
>
"Mean:
</span>
{np.mean(data)}
<span
style=
"color: #f09383;"
>
\n
</span><span
style=
"color: #fab795;"
>
Min:
</span>
{np.
<span
style=
"color: #b877db;"
>
min
</span>
(data)}
<span
style=
"color: #f09383;"
>
\n
</span><span
style=
"color: #fab795;"
>
Max:
</span>
{np.
<span
style=
"color: #b877db;"
>
max
</span>
(data)}
<span
style=
"color: #f09383;"
>
\n
</span><span
style=
"color: #fab795;"
>
Median:
</span>
{np.median(data)}
<span
style=
"color: #f09383;"
>
\n
</span><span
style=
"color: #fab795;"
>
Std:
</span>
{np.std(data, ddof=1)}
<span
style=
"color: #fab795;"
>
"
</span>
)
</pre>
</div>
<pre
class=
"example"
>
Mean: 14.113000000000001
Min: 2.8
Max: 23.4
Median: 14.5
Std: 4.334094455301447
</pre>
</div>
<div
id=
"postamble"
class=
"status"
>
<p
class=
"date"
>
Date: 2024-06-06 Thu 00:00
</p>
<p
class=
"author"
>
Auteur: Antoine Geimer
</p>
<p
class=
"date"
>
Created: 2024-06-06 Thu 13:37
</p>
<p
class=
"validation"
><a
href=
"https://validator.w3.org/check?uri=referer"
>
Validate
</a></p>
</div>
</body>
</html>
module2/exo2/exercice_python_fr.org
View file @
700e30fa
#+TITLE:
Votre titre
#+TITLE:
Exercice 2
#+AUTHOR:
Votre nom
#+AUTHOR:
Antoine Geimer
#+DATE:
La date du jour
#+DATE:
[2024-06-06 Thu]
#+LANGUAGE: fr
#+LANGUAGE: fr
# #+PROPERTY: header-args :eval never-export
# #+PROPERTY: header-args :eval never-export
...
@@ -11,83 +11,33 @@
...
@@ -11,83 +11,33 @@
#+HTML_HEAD: <script type="text/javascript" src="http://www.pirilampo.org/styles/lib/js/jquery.stickytableheaders.js"></script>
#+HTML_HEAD: <script type="text/javascript" src="http://www.pirilampo.org/styles/lib/js/jquery.stickytableheaders.js"></script>
#+HTML_HEAD: <script type="text/javascript" src="http://www.pirilampo.org/styles/readtheorg/js/readtheorg.js"></script>
#+HTML_HEAD: <script type="text/javascript" src="http://www.pirilampo.org/styles/readtheorg/js/readtheorg.js"></script>
* Quelques explications
Ceci est un document org-mode avec quelques exemples de code
Récuperer les données et les visualiser:
python. Une fois ouvert dans emacs, ce document peut aisément être
#+begin_src python :results output :exports both :session *python*
exporté au format HTML, PDF, et Office. Pour plus de détails sur
import numpy as np
org-mode vous pouvez consulter https://orgmode.org/guide/.
Lorsque vous utiliserez le raccourci =C-c C-e h o=, ce document sera
data = np.genfromtxt('data.csv', delimiter=', ')
compilé en html. Tout le code contenu sera ré-exécuté, les résultats
print(data) # visualizing the data
récupérés et inclus dans un document final. Si vous ne souhaitez pas
ré-exécuter tout le code à chaque fois, il vous suffit de supprimer
le # et l'espace qui sont devant le ~#+PROPERTY:~ au début de ce
document.
Comme nous vous l'avons montré dans la vidéo, on inclue du code
python de la façon suivante (et on l'exécute en faisant ~C-c C-c~):
#+begin_src python :results output :exports both
print("Hello world!")
#+end_src
#+end_src
#+RESULTS:
#+RESULTS:
: Hello world!
: [14. 7.6 11.2 12.8 12.5 9.9 14.9 9.4 16.9 10.2 14.9 18.1 7.3 9.8
: 10.9 12.2 9.9 2.9 2.8 15.4 15.7 9.7 13.1 13.2 12.3 11.7 16. 12.4
Voici la même chose, mais avec une session python, donc une
: 17.9 12.2 16.2 18.7 8.9 11.9 12.1 14.6 12.1 4.7 3.9 16.9 16.8 11.3
persistance d'un bloc à l'autre (et on l'exécute toujours en faisant
: 14.4 15.7 14. 13.6 18. 13.6 19.9 13.7 17. 20.5 9.9 12.5 13.2 16.1
~C-c C-c~).
: 13.5 6.3 6.4 17.6 19.1 12.8 15.5 16.3 15.2 14.6 19.1 14.4 21.4 15.1
#+begin_src python :results output :session :exports both
: 19.6 21.7 11.3 15. 14.3 16.8 14. 6.8 8.2 19.9 20.4 14.6 16.4 18.7
import numpy
: 16.8 15.8 20.4 15.8 22.4 16.2 20.3 23.4 12.1 15.5 15.4 18.4 15.7 10.2
x=numpy.linspace(-15,15)
: 8.9 21. ]
print(x)
Statistiques:
#+begin_src python :results output :exports both :session *python*
print(f"Mean: {np.mean(data)}\nMin: {np.min(data)}\nMax: {np.max(data)}\nMedian: {np.median(data)}\nStd: {np.std(data, ddof=1)}")
#+end_src
#+end_src
#+RESULTS:
#+RESULTS:
#+begin_example
: Mean: 14.113000000000001
[-15. -14.3877551 -13.7755102 -13.16326531 -12.55102041
: Min: 2.8
-11.93877551 -11.32653061 -10.71428571 -10.10204082 -9.48979592
: Max: 23.4
-8.87755102 -8.26530612 -7.65306122 -7.04081633 -6.42857143
: Median: 14.5
-5.81632653 -5.20408163 -4.59183673 -3.97959184 -3.36734694
: Std: 4.334094455301447
-2.75510204 -2.14285714 -1.53061224 -0.91836735 -0.30612245
0.30612245 0.91836735 1.53061224 2.14285714 2.75510204
3.36734694 3.97959184 4.59183673 5.20408163 5.81632653
6.42857143 7.04081633 7.65306122 8.26530612 8.87755102
9.48979592 10.10204082 10.71428571 11.32653061 11.93877551
12.55102041 13.16326531 13.7755102 14.3877551 15. ]
#+end_example
Et enfin, voici un exemple de sortie graphique:
#+begin_src python :results output file :session :var matplot_lib_filename="./cosxsx.png" :exports results
import matplotlib.pyplot as plt
plt.figure(figsize=(10,5))
plt.plot(x,numpy.cos(x)/x)
plt.tight_layout()
plt.savefig(matplot_lib_filename)
print(matplot_lib_filename)
#+end_src
#+RESULTS:
[[file:./cosxsx.png]]
Vous remarquerez le paramètre ~:exports results~ qui indique que le code
ne doit pas apparaître dans la version finale du document. Nous vous
recommandons dans le cadre de ce MOOC de ne pas changer ce paramètre
(indiquer ~both~) car l'objectif est que vos analyses de données soient
parfaitement transparentes pour être reproductibles.
Attention, la figure ainsi générée n'est pas stockée dans le document
org. C'est un fichier ordinaire, ici nommé ~cosxsx.png~. N'oubliez pas
de le committer si vous voulez que votre analyse soit lisible et
compréhensible sur GitLab.
Enfin, n'oubliez pas que nous vous fournissons dans les ressources de
ce MOOC une configuration avec un certain nombre de raccourcis
claviers permettant de créer rapidement les blocs de code python (en
faisant ~<p~, ~<P~ ou ~<PP~ suivi de ~Tab~).
Maintenant, à vous de jouer! Vous pouvez effacer toutes ces
informations et les remplacer par votre document computationnel.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment