Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Aug 19, 2024
1 parent 48f232a commit 666aa08
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 98 deletions.
41 changes: 18 additions & 23 deletions docs/benchmark.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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\"])"
Expand Down Expand Up @@ -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",
Expand All @@ -124,7 +122,7 @@
"metadata": {},
"outputs": [],
"source": [
"df = df.sort_values(by='timestamp')\n",
"df = df.sort_values(by=\"timestamp\")\n",
"df"
]
},
Expand Down Expand Up @@ -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\"<br>Git Hash: {h}</br>\",\n",
" f\"<br>Version: {v}</br>\",\n",
" f\"<br>Timestamp {t}</br>\",\n",
" ]))\n",
" \n",
"for h, v, t in zip(git_hash, versions, dates):\n",
" text.append(\n",
" \"\\n\".join(\n",
" [\n",
" f\"<br>Git Hash: {h}</br>\",\n",
" f\"<br>Version: {v}</br>\",\n",
" f\"<br>Timestamp {t}</br>\",\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()"
]
},
Expand Down
74 changes: 37 additions & 37 deletions docs/convergence_spatial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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\"])"
Expand Down Expand Up @@ -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)"
]
},
{
Expand All @@ -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"
]
},
Expand All @@ -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\"<br>Git Hash: {h}</br>\",\n",
" f\"<br>Version: {v}</br>\",\n",
" f\"<br>Timestamp {t}</br>\",\n",
" ]))\n",
" \n",
" for h, v, t in zip(git_hash, versions, dates):\n",
" text.append(\n",
" \"\\n\".join(\n",
" [\n",
" f\"<br>Git Hash: {h}</br>\",\n",
" f\"<br>Version: {v}</br>\",\n",
" f\"<br>Timestamp {t}</br>\",\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()"
]
},
Expand Down
76 changes: 38 additions & 38 deletions docs/convergence_temporal.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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\"])"
Expand All @@ -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",
Expand All @@ -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"
]
},
Expand All @@ -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)"
]
},
{
Expand All @@ -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\"<br>Git Hash: {h}</br>\",\n",
" f\"<br>Version: {v}</br>\",\n",
" f\"<br>Timestamp {t}</br>\",\n",
" ]))\n",
" \n",
" for h, v, t in zip(git_hash, versions, dates):\n",
" text.append(\n",
" \"\\n\".join(\n",
" [\n",
" f\"<br>Git Hash: {h}</br>\",\n",
" f\"<br>Version: {v}</br>\",\n",
" f\"<br>Timestamp {t}</br>\",\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()"
]
}
Expand Down

0 comments on commit 666aa08

Please sign in to comment.