mirror of
https://github.com/ArthurDanjou/ArtStudies.git
synced 2026-01-28 08:56:10 +01:00
Refactor error messages and function signatures across multiple notebooks for clarity and consistency
- Updated error messages in Gauss method and numerical methods to use variables for better readability. - Added return type hints to function signatures in various notebooks to improve code documentation. - Corrected minor grammatical issues in docstrings for better clarity. - Adjusted print statements and list concatenations for improved output formatting. - Enhanced plotting functions to ensure consistent figure handling.
This commit is contained in:
@@ -184,7 +184,7 @@
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"def F(y, t, a, r):\n",
|
||||
" S, I, R = y\n",
|
||||
" S, I, _R = y\n",
|
||||
" dS = -r * S * I\n",
|
||||
" dI = r * S * I - a * I\n",
|
||||
" dR = a * I\n",
|
||||
|
||||
@@ -46,12 +46,12 @@
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"def S(t, S0, mu, sigma, W):\n",
|
||||
" \"\"\"Solution exacte de l'EDS de Black-Scholes\"\"\"\n",
|
||||
" \"\"\"Solution exacte de l'EDS de Black-Scholes.\"\"\"\n",
|
||||
" return S0 * np.exp((mu - 0.5 * sigma**2) * t + sigma * W)\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"def euler_maruyama(mu, sigma, T, N, X0=0.0):\n",
|
||||
" \"\"\"Simulation d'une EDS de Black-Scholes par la méthode d'Euler-Maruyama\n",
|
||||
" \"\"\"Simulation d'une EDS de Black-Scholes par la méthode d'Euler-Maruyama.\n",
|
||||
"\n",
|
||||
" Paramètres :\n",
|
||||
" mu (float) : drift\n",
|
||||
@@ -80,8 +80,8 @@
|
||||
" return t, X\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"def plot_brownien(t, X, B=None):\n",
|
||||
" \"\"\"Plot la simulation d'Euler-Maruyama\n",
|
||||
"def plot_brownien(t, X, B=None) -> None:\n",
|
||||
" \"\"\"Plot la simulation d'Euler-Maruyama.\n",
|
||||
"\n",
|
||||
" Paramètres :\n",
|
||||
" t (array-like) : tableau des temps\n",
|
||||
@@ -164,8 +164,8 @@
|
||||
"np.random.seed(333)\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"def plot_convergence(S0, mu, sigma, T):\n",
|
||||
" \"\"\"Plot la convergence du schéma d'Euler-Maruyama\n",
|
||||
"def plot_convergence(S0, mu, sigma, T) -> None:\n",
|
||||
" \"\"\"Plot la convergence du schéma d'Euler-Maruyama.\n",
|
||||
"\n",
|
||||
" Paramètres :\n",
|
||||
" S0 (int) : valeur initiale\n",
|
||||
@@ -271,7 +271,7 @@
|
||||
"\n",
|
||||
"def is_barrier_breached(X, B):\n",
|
||||
" \"\"\"Renvoie True si la barrière est franchie, False sinon\n",
|
||||
" La barrière est franchie si X >= B\n",
|
||||
" La barrière est franchie si X >= B.\n",
|
||||
"\n",
|
||||
" Paramètres:\n",
|
||||
" X (array-like): Trajectoire des valeurs\n",
|
||||
@@ -297,8 +297,8 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"def plot_browniens(trajectories, B):\n",
|
||||
" \"\"\"Trace les trajectoires de Brownien et la barrière\n",
|
||||
"def plot_browniens(trajectories, B) -> None:\n",
|
||||
" \"\"\"Trace les trajectoires de Brownien et la barrière.\n",
|
||||
"\n",
|
||||
" Paramètres:\n",
|
||||
" trajectories (list of tuples): Liste des trajectoires avec le temps et les valeurs\n",
|
||||
@@ -451,7 +451,7 @@
|
||||
"np.random.seed(333)\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"def plot_payoff_errors():\n",
|
||||
"def plot_payoff_errors() -> None:\n",
|
||||
" \"\"\"Trace l'erreur de convergence du payoff actualisé en fonction de N.\"\"\"\n",
|
||||
" errors = []\n",
|
||||
"\n",
|
||||
|
||||
@@ -248,7 +248,7 @@
|
||||
" return result.x\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"def plot_perimeter(n):\n",
|
||||
"def plot_perimeter(n) -> None:\n",
|
||||
" optimal_angles = optimize_polygon(n + 1)\n",
|
||||
" plt.figure(figsize=(7, 7))\n",
|
||||
" t = np.linspace(0, 2 * np.pi, 100)\n",
|
||||
|
||||
@@ -902,7 +902,7 @@
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"def divisible_by_3_and13(n):\n",
|
||||
"def divisible_by_3_and13(n) -> None:\n",
|
||||
" if n % 3 == 0 and n % 13 == 0:\n",
|
||||
" print(n, \"is divisible by 3 and 13\")\n",
|
||||
" else:\n",
|
||||
|
||||
@@ -1084,7 +1084,7 @@
|
||||
],
|
||||
"source": [
|
||||
"# We remove the players for whom Salary is missing\n",
|
||||
"hitters.dropna(subset=[\"Salary\"], inplace=True)\n",
|
||||
"hitters = hitters.dropna(subset=[\"Salary\"])\n",
|
||||
"\n",
|
||||
"X = hitters.select_dtypes(include=int)\n",
|
||||
"Y = hitters[\"Salary\"]\n",
|
||||
|
||||
@@ -227,7 +227,8 @@
|
||||
"source": [
|
||||
"sms = pd.read_csv(\"data/spam.csv\", encoding=\"latin\")\n",
|
||||
"\n",
|
||||
"sms.head()"
|
||||
"sms.head()\n",
|
||||
"sms = "
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -243,7 +244,7 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"sms.rename(columns={\"v1\": \"Label\", \"v2\": \"Text\"}, inplace=True)"
|
||||
"sms.rename(columns={\"v1\": \"Label\", \"v2\": \"Text\"})"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user