Vous avez reçu un message "Your GitLab account has been locked ..." ? Pas d'inquiétude : lisez cet article https://docs.gricad-pages.univ-grenoble-alpes.fr/help/unlock/

Commit 26cdc630 authored by Loic Huder's avatar Loic Huder
Browse files

Corrected some typos in pres080

parent 948eb6ba
......@@ -12,7 +12,7 @@
"\n",
"**A training to acquire strong basis in Python to use it efficiently**\n",
"\n",
"Pierre Augier (LEGI), Cyrille Bonamy (LEGI), Eric Maldonado (Irstea), Franck Thollard (ISTERRE), Christophe Picard (LJK)\n",
"Pierre Augier (LEGI), Cyrille Bonamy (LEGI), Eric Maldonado (Irstea), Franck Thollard (ISTERRE), Christophe Picard (LJK), Loïc Huder (ISTerre)\n",
"\n",
"# Object-oriented programming: encapsulation\n",
"\n",
......@@ -27,7 +27,7 @@
}
},
"source": [
"For some problems, Object-oriented programming is a very efficient paradigm. Many libraries use it so it is worth understanding what is object orriented programming and when it is useful.\n",
"For some problems, Object-oriented programming is a very efficient paradigm. Many libraries use it so it is worth understanding what is object oriented programming (POO) and when it is useful.\n",
"\n",
"# Concepts\n",
"\n",
......@@ -55,7 +55,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 1,
"metadata": {},
"outputs": [
{
......@@ -63,7 +63,7 @@
"output_type": "stream",
"text": [
"max temp is of 5°C at index 1 \n",
"wind at max temp = 0 km/h\n"
"wind speed at max temp = 0 km/h\n"
]
}
],
......@@ -115,7 +115,7 @@
"output_type": "stream",
"text": [
"max temp is 5°C at index 1\n",
"wind_when_max_temp = 0 km/h\n"
"wind speed at max temp = 0 km/h\n"
]
}
],
......@@ -169,8 +169,8 @@
"name": "stdout",
"output_type": "stream",
"text": [
"max temp is 5 at index 1\n",
"wind when max temp = 0\n"
"max temp is 5°C at index 1\n",
"wind speed at max temp = 0 km/h\n"
]
}
],
......@@ -197,7 +197,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 4,
"metadata": {},
"outputs": [
{
......@@ -210,7 +210,7 @@
"test max_temp computes correctly ... ok\n",
"\n",
"----------------------------------------------------------------------\n",
"Ran 2 tests in 0.003s\n",
"Ran 2 tests in 0.002s\n",
"\n",
"OK\n"
]
......@@ -277,7 +277,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 5,
"metadata": {},
"outputs": [
{
......@@ -320,7 +320,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 6,
"metadata": {},
"outputs": [
{
......@@ -393,7 +393,7 @@
" - If the dedicated function `build_station` is used, the returned dictionary is well structured.\n",
" - If one changes `build_station`, only `max_temp` and `arg_max_temp` have to be changed accordingly\n",
" - We use a list comprehension to be able to have parameters wind and temp provided by any ordered iterable (e.g. see `test_build_station_with_iterable` wtih `range`)\n",
" - *BUT* if we have a new kind of station, *i.e.* that holds only wind and humidity, we want to avoid to be able to use max_temp with it. "
" - **BUT** if we have a new kind of station, *i.e.* that holds only wind and humidity, we want to avoid to be able to use `max_temp` with it. "
]
},
{
......@@ -406,7 +406,7 @@
"source": [
"**Improvement**\n",
" \n",
"We would like to \"embed\" the max_temp and the arg_max_temp in the \"dictionnary station\" in order to address the last point.\n",
"We would like to \"embed\" the `max_temp` and the `arg_max_temp` in the \"dictionnary station\" in order to address the last point.\n",
" \n",
"And here comes the object-oriented programming ! \n",
" "
......@@ -431,7 +431,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 7,
"metadata": {},
"outputs": [
{
......@@ -508,7 +508,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 8,
"metadata": {
"slideshow": {
"slide_type": "-"
......@@ -531,7 +531,7 @@
"test test_max_temp function ... ok\n",
"\n",
"----------------------------------------------------------------------\n",
"Ran 5 tests in 0.008s\n",
"Ran 5 tests in 0.013s\n",
"\n",
"OK\n"
]
......@@ -587,16 +587,16 @@
"source": [
"## Do It Yourself (advanced)\n",
"\n",
"- Add a method (perceived_temp) that takes as input a temperature and wind and return the perceived temperature, i.e. taking into account the wind chill effect.\n",
"- Modify max_temp and arg_max_temp so that they take an additional optional boolean parameter (*e.g.* perceived default to False). If perceived is False, the methods have the same behaviour as before. If perceived is True, the temperatures to process are the perceived temperatures.\n",
"- Add a method (`perceived_temp`) that takes as input a temperature and wind and return the perceived temperature, i.e. taking into account the wind chill effect.\n",
"- Modify `max_temp` and `arg_max_temp` so that they take an additional optional boolean parameter (*e.g.* perceived default to False). If `perceived` is False, the methods have the same behaviour as before. If perceived is True, the temperatures to process are the perceived temperatures.\n",
"- Code so that all the tests are ok.\n",
"- Add a tests for a method (perceived_temperatures) that returns an array containing all the perceived temperatures.\n",
"- Code the method perceived_temperatures so that all tests are ok."
"- Add a tests for a method (`perceived_temperatures`) that returns an array containing all the perceived temperatures.\n",
"- Code the method `perceived_temperatures` so that all tests are ok."
]
},
{
"cell_type": "code",
"execution_count": 32,
"execution_count": 11,
"metadata": {},
"outputs": [
{
......@@ -617,13 +617,13 @@
"test max temp function ... ok\n",
"test_perceived (__main__.TestWeatherStation)\n",
"test that the perceived temp computation works as intended ... ok\n",
"test_perceived_arrays (__main__.TestWeatherStation)\n",
"test that the perceived temp array generation works ... ok\n",
"test_perceived_temperatures (__main__.TestWeatherStation)\n",
"test that the perceived temperatures generation works ... ok\n",
"test_perceived_with_null_wind (__main__.TestWeatherStation)\n",
"test that the perceived temp is the same without wind ... ok\n",
"\n",
"----------------------------------------------------------------------\n",
"Ran 9 tests in 0.014s\n",
"Ran 9 tests in 0.010s\n",
"\n",
"OK\n"
]
......@@ -664,7 +664,7 @@
" # Let's round to the integer to avoid trailing decimals...\n",
" return round(apparent_temp,0)\n",
" \n",
" def perceived_temp_array(self):\n",
" def perceived_temperatures(self):\n",
" \"\"\" Returns an array of percieved temp computed from the temperatures and wind speed data \"\"\"\n",
" apparent_temps = []\n",
" for index, temperature in enumerate(self.temp):\n",
......@@ -677,7 +677,7 @@
" def max_temp(self, perceived=False):\n",
" \"\"\" returns the maximum temperature record in the station\"\"\"\n",
" if perceived:\n",
" apparent_temp = self.perceived_temp_array()\n",
" apparent_temp = self.perceived_temperatures()\n",
" return max(apparent_temp)\n",
" else:\n",
" return max(self.temp)\n",
......@@ -685,7 +685,7 @@
" def arg_max_temp(self, perceived=False):\n",
" \"\"\" returns the index of (one of the) maximum temperature record in the station\"\"\"\n",
" if perceived:\n",
" temp_array_to_search = self.perceived_temp_array()\n",
" temp_array_to_search = self.perceived_temperatures()\n",
" else:\n",
" temp_array_to_search = self.temp\n",
" return temp_array_to_search.index(self.max_temp(perceived))\n",
......@@ -725,9 +725,9 @@
" \"\"\" test that the perceived temp computation works as intended\"\"\"\n",
" self.assertEqual(-24, self.paris.perceived_temp(-20, 5))\n",
" \n",
" def test_perceived_arrays(self):\n",
" \"\"\" test that the perceived temp array generation works\"\"\"\n",
" apparent_temps = self.paris.perceived_temp_array()\n",
" def test_perceived_temperatures(self):\n",
" \"\"\" test that the perceived temperatures generation works\"\"\"\n",
" apparent_temps = self.paris.perceived_temperatures()\n",
" self.assertTrue(isinstance(apparent_temps, list))\n",
" self.assertEqual(len(apparent_temps), len(self.paris.temp))\n",
" for i in range(0, len(apparent_temps)):\n",
......
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