diff --git a/docs/benchmark.ipynb b/docs/benchmark.ipynb index 886be9fe..e377d717 100644 --- a/docs/benchmark.ipynb +++ b/docs/benchmark.ipynb @@ -17,9 +17,7 @@ "metadata": {}, "outputs": [], "source": [ - "from pathlib import Path\n", "import json\n", - "import matplotlib.pyplot as plt\n", "import numpy as np\n", "from collections import defaultdict\n", "import pandas as pd\n", @@ -43,7 +41,7 @@ "}\n", "print(\"Get existing data from gist\")\n", "response = requests.get(\n", - " f\"https://api.github.com/gists/73fa6531f28da2b3633a7ddaca38a7cd\",\n", + " \"https://api.github.com/gists/73fa6531f28da2b3633a7ddaca38a7cd\",\n", " headers=headers,\n", ")\n", "data = json.loads(response.json()[\"files\"][\"convergence_test.json\"][\"content\"])" @@ -97,7 +95,7 @@ " if key in excluded_keys:\n", " continue\n", " all_results[key].append(value)\n", - " \n", + "\n", "results = {}\n", "for k, v in all_results.items():\n", " print(k, len(v))\n", @@ -124,7 +122,7 @@ "metadata": {}, "outputs": [], "source": [ - "df = df.sort_values(by='timestamp')\n", + "df = df.sort_values(by=\"timestamp\")\n", "df" ] }, @@ -187,31 +185,28 @@ "dates = [t.date() for t in df[\"timestamp\"]]\n", "\n", "text = []\n", - "for h,v, t in zip(git_hash, versions, dates):\n", - " text.append(\"\\n\".join([\n", - " f\"
Git Hash: {h}
\",\n", - " f\"
Version: {v}
\",\n", - " f\"
Timestamp {t}
\",\n", - " ]))\n", - " \n", + "for h, v, t in zip(git_hash, versions, dates):\n", + " text.append(\n", + " \"\\n\".join(\n", + " [\n", + " f\"
Git Hash: {h}
\",\n", + " f\"
Version: {v}
\",\n", + " f\"
Timestamp {t}
\",\n", + " ]\n", + " )\n", + " )\n", + "\n", "fig = make_subplots(rows=len(columns), cols=1, subplot_titles=columns, shared_xaxes=True)\n", "\n", "yranges = []\n", "for i, c in enumerate(columns):\n", - " \n", " row = i + 1\n", " col = 1\n", - " \n", - " fig.add_trace(\n", - " go.Scatter(x=df[\"timestamp\"], y=df[c], text=text, hovertemplate=\"%{text}\"),\n", - " row=row, col=col\n", - " )\n", - " fig.update_yaxes(range=get_ylim(df[c]),row=row, col=col)\n", "\n", - "fig.update_layout(\n", - " height=5000,\n", - " showlegend=False\n", - ")\n", + " fig.add_trace(go.Scatter(x=df[\"timestamp\"], y=df[c], text=text, hovertemplate=\"%{text}\"), row=row, col=col)\n", + " fig.update_yaxes(range=get_ylim(df[c]), row=row, col=col)\n", + "\n", + "fig.update_layout(height=5000, showlegend=False)\n", "fig.show()" ] }, diff --git a/docs/convergence_spatial.ipynb b/docs/convergence_spatial.ipynb index 271dfff6..ac76ffaf 100644 --- a/docs/convergence_spatial.ipynb +++ b/docs/convergence_spatial.ipynb @@ -15,7 +15,6 @@ "metadata": {}, "outputs": [], "source": [ - "from pathlib import Path\n", "import json\n", "import numpy as np\n", "from collections import defaultdict\n", @@ -40,7 +39,7 @@ "}\n", "print(\"Get existing data from gist\")\n", "response = requests.get(\n", - " f\"https://api.github.com/gists/73fa6531f28da2b3633a7ddaca38a7cd\",\n", + " \"https://api.github.com/gists/73fa6531f28da2b3633a7ddaca38a7cd\",\n", " headers=headers,\n", ")\n", "data = json.loads(response.json()[\"files\"][\"convergence_test.json\"][\"content\"])" @@ -106,9 +105,9 @@ " y_min = np.min(values)\n", " d_max = y_max - 1\n", " d_min = 1 - y_min\n", - " \n", + "\n", " d = max(d_min, d_max) + 0.025\n", - " return (1 - d, 1 + d)\n" + " return (1 - d, 1 + d)" ] }, { @@ -119,7 +118,7 @@ "outputs": [], "source": [ "dxs = df[\"dx\"].unique()\n", - "DX = np.median(dxs) # Choose the dx in the middle as the one to compare with\n", + "DX = np.median(dxs) # Choose the dx in the middle as the one to compare with\n", "dxs" ] }, @@ -137,60 +136,61 @@ "dates = [t.date() for t in df[\"timestamp\"]]\n", "\n", "df_DX = df[df[\"dx\"] == DX]\n", - "df_DX.sort_values(by='timestamp')\n", - " \n", + "df_DX.sort_values(by=\"timestamp\")\n", + "\n", "fig = make_subplots(\n", - " rows=len(columns), \n", - " cols=1, \n", - " subplot_titles=columns, \n", - " y_title=\"Percentage deviation from median case\", \n", - " shared_xaxes=True\n", + " rows=len(columns),\n", + " cols=1,\n", + " subplot_titles=columns,\n", + " y_title=\"Percentage deviation from median case\",\n", + " shared_xaxes=True,\n", ")\n", "\n", "yranges = []\n", - "colors = ['red', 'green', 'blue']\n", + "colors = [\"red\", \"green\", \"blue\"]\n", "for color, dx in zip(colors, sorted(dxs)):\n", " df_dx = df[df[\"dx\"] == dx]\n", - " df_dx.sort_values(by='timestamp')\n", - " \n", + " df_dx.sort_values(by=\"timestamp\")\n", + "\n", " git_hash = df_dx[\"sha\"]\n", " versions = df_dx[\"simcardems_version\"]\n", " dates = [t.date() for t in df_dx[\"timestamp\"]]\n", - " \n", + "\n", " text = []\n", - " for h,v, t in zip(git_hash, versions, dates):\n", - " text.append(\"\\n\".join([\n", - " f\"
Git Hash: {h}
\",\n", - " f\"
Version: {v}
\",\n", - " f\"
Timestamp {t}
\",\n", - " ]))\n", - " \n", + " for h, v, t in zip(git_hash, versions, dates):\n", + " text.append(\n", + " \"\\n\".join(\n", + " [\n", + " f\"
Git Hash: {h}
\",\n", + " f\"
Version: {v}
\",\n", + " f\"
Timestamp {t}
\",\n", + " ]\n", + " )\n", + " )\n", + "\n", " for i, c in enumerate(columns):\n", - " \n", " y = df_dx[c].to_numpy() / df_DX[c].to_numpy()\n", - " \n", + "\n", " row = i + 1\n", " col = 1\n", - " showlegend=i==0\n", + " showlegend = i == 0\n", " fig.add_trace(\n", " go.Scatter(\n", - " x=df_dx[\"timestamp\"], \n", - " y=y, \n", - " text=text, \n", + " x=df_dx[\"timestamp\"],\n", + " y=y,\n", + " text=text,\n", " hovertemplate=\"%{text}\",\n", - " name=f\"dx={dx}\", \n", + " name=f\"dx={dx}\",\n", " legendgroup=str(dx),\n", - " showlegend=i==0,\n", - " marker_color=color\n", + " showlegend=i == 0,\n", + " marker_color=color,\n", " ),\n", - " row=row, col=col\n", + " row=row,\n", + " col=col,\n", " )\n", " fig.update_yaxes(range=get_ylim(y), row=row, col=col)\n", "\n", - "fig.update_layout(\n", - " height=5000,\n", - " showlegend=True\n", - ")\n", + "fig.update_layout(height=5000, showlegend=True)\n", "fig.show()" ] }, diff --git a/docs/convergence_temporal.ipynb b/docs/convergence_temporal.ipynb index 2010e07d..3a125c48 100644 --- a/docs/convergence_temporal.ipynb +++ b/docs/convergence_temporal.ipynb @@ -15,7 +15,6 @@ "metadata": {}, "outputs": [], "source": [ - "from pathlib import Path\n", "import json\n", "import numpy as np\n", "from collections import defaultdict\n", @@ -40,7 +39,7 @@ "}\n", "print(\"Get existing data from gist\")\n", "response = requests.get(\n", - " f\"https://api.github.com/gists/73fa6531f28da2b3633a7ddaca38a7cd\",\n", + " \"https://api.github.com/gists/73fa6531f28da2b3633a7ddaca38a7cd\",\n", " headers=headers,\n", ")\n", "data = json.loads(response.json()[\"files\"][\"convergence_test.json\"][\"content\"])" @@ -67,7 +66,7 @@ " continue # Only select data with \"dt0.05\"\n", " for key, value in d1.items():\n", " all_results[key].append(value)\n", - " \n", + "\n", "N = max(len(v) for v in all_results.values())\n", "results = {}\n", "for k, v in all_results.items():\n", @@ -88,7 +87,7 @@ "outputs": [], "source": [ "dts = df[\"dt\"].unique()\n", - "DT = np.median(dts) # Choose the dt in the middle as the one to compare with\n", + "DT = np.median(dts) # Choose the dt in the middle as the one to compare with\n", "dts" ] }, @@ -106,9 +105,9 @@ " y_min = np.min(values)\n", " d_max = y_max - 1\n", " d_min = 1 - y_min\n", - " \n", + "\n", " d = max(d_min, d_max) + 0.025\n", - " return (1 - d, 1 + d)\n" + " return (1 - d, 1 + d)" ] }, { @@ -124,60 +123,61 @@ "dates = [t.date() for t in df[\"timestamp\"]]\n", "\n", "df_DT = df[df[\"dt\"] == DT]\n", - "df_DT.sort_values(by='timestamp')\n", - " \n", + "df_DT.sort_values(by=\"timestamp\")\n", + "\n", "fig = make_subplots(\n", - " rows=len(columns), \n", - " cols=1, \n", + " rows=len(columns),\n", + " cols=1,\n", " y_title=\"Percentage deviation from median case\",\n", - " subplot_titles=columns, \n", - " shared_xaxes=True\n", + " subplot_titles=columns,\n", + " shared_xaxes=True,\n", ")\n", "\n", "yranges = []\n", - "colors = ['red', 'green', 'blue']\n", + "colors = [\"red\", \"green\", \"blue\"]\n", "for color, dt in zip(colors, sorted(dts)):\n", " df_dt = df[df[\"dt\"] == dt]\n", - " df_dt.sort_values(by='timestamp')\n", - " \n", + " df_dt.sort_values(by=\"timestamp\")\n", + "\n", " git_hash = df_dt[\"sha\"]\n", " versions = df_dt[\"simcardems_version\"]\n", " dates = [t.date() for t in df_dt[\"timestamp\"]]\n", - " \n", + "\n", " text = []\n", - " for h,v, t in zip(git_hash, versions, dates):\n", - " text.append(\"\\n\".join([\n", - " f\"
Git Hash: {h}
\",\n", - " f\"
Version: {v}
\",\n", - " f\"
Timestamp {t}
\",\n", - " ]))\n", - " \n", + " for h, v, t in zip(git_hash, versions, dates):\n", + " text.append(\n", + " \"\\n\".join(\n", + " [\n", + " f\"
Git Hash: {h}
\",\n", + " f\"
Version: {v}
\",\n", + " f\"
Timestamp {t}
\",\n", + " ]\n", + " )\n", + " )\n", + "\n", " for i, c in enumerate(columns):\n", - " \n", " y = df_dt[c].to_numpy() / df_DT[c].to_numpy()\n", - " \n", + "\n", " row = i + 1\n", " col = 1\n", - " showlegend=i==0\n", + " showlegend = i == 0\n", " fig.add_trace(\n", " go.Scatter(\n", - " x=df_dt[\"timestamp\"], \n", - " y=y, \n", - " text=text, \n", - " hovertemplate=\"%{text}\", \n", - " name=f\"dt={dt}\", \n", + " x=df_dt[\"timestamp\"],\n", + " y=y,\n", + " text=text,\n", + " hovertemplate=\"%{text}\",\n", + " name=f\"dt={dt}\",\n", " legendgroup=str(dt),\n", - " showlegend=i==0,\n", - " marker_color=color\n", + " showlegend=i == 0,\n", + " marker_color=color,\n", " ),\n", - " row=row, col=col\n", + " row=row,\n", + " col=col,\n", " )\n", " fig.update_yaxes(range=get_ylim(y), row=row, col=col)\n", "\n", - "fig.update_layout(\n", - " height=7000,\n", - " showlegend=True\n", - ")\n", + "fig.update_layout(height=7000, showlegend=True)\n", "fig.show()" ] }