Skip to content

Commit

Permalink
Merge pull request #10 from spglib/pre-commit-ci-update-config
Browse files Browse the repository at this point in the history
[pre-commit.ci] pre-commit autoupdate
  • Loading branch information
lan496 authored Aug 20, 2024
2 parents 6f885e0 + da27294 commit 90eef1d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ repos:
stages: [manual] # because it's slow
# Python
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.7
rev: v0.6.1
hooks:
- id: ruff-format
args: ["--config", "moyopy/pyproject.toml"]
Expand Down
46 changes: 27 additions & 19 deletions bench/mp/analysis.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
"import matplotlib.pyplot as plt\n",
"import seaborn as sns\n",
"\n",
"sns.set_context('poster')\n",
"plt.rcParams['grid.linewidth'] = 0.2\n",
"pd.set_option('display.max_rows', 500)"
"sns.set_context(\"poster\")\n",
"plt.rcParams[\"grid.linewidth\"] = 0.2\n",
"pd.set_option(\"display.max_rows\", 500)"
]
},
{
Expand Down Expand Up @@ -211,16 +211,20 @@
],
"source": [
"df = pd.read_json(\"stats.json\")\n",
"df.sort_values(['material_id', 'symprec'], inplace=True)\n",
"df.sort_values([\"material_id\", \"symprec\"], inplace=True)\n",
"\n",
"series_moyopy = df.groupby('material_id')['number_moyopy'].apply(list)\n",
"series_spglib = df.groupby('material_id')['number_spglib'].apply(list)\n",
"series_moyopy = df.groupby(\"material_id\")[\"number_moyopy\"].apply(list)\n",
"series_spglib = df.groupby(\"material_id\")[\"number_spglib\"].apply(list)\n",
"\n",
"df_stat = pd.concat([series_moyopy, series_spglib], axis=1)\n",
"# jaccard_index(A, B) := |A ∩ B| / |A ∪ B|\n",
"df_stat['jaccard'] = df_stat.apply(lambda row: len(set(row['number_moyopy']) & set(row['number_spglib'])) / len(set(row['number_moyopy']) | set(row['number_spglib'])), axis=1)\n",
"df_stat['number_moyopy_last'] = df_stat['number_moyopy'].apply(lambda x: x[-1])\n",
"df_stat['number_spglib_last'] = df_stat['number_spglib'].apply(lambda x: x[-1])\n",
"df_stat[\"jaccard\"] = df_stat.apply(\n",
" lambda row: len(set(row[\"number_moyopy\"]) & set(row[\"number_spglib\"]))\n",
" / len(set(row[\"number_moyopy\"]) | set(row[\"number_spglib\"])),\n",
" axis=1,\n",
")\n",
"df_stat[\"number_moyopy_last\"] = df_stat[\"number_moyopy\"].apply(lambda x: x[-1])\n",
"df_stat[\"number_spglib_last\"] = df_stat[\"number_spglib\"].apply(lambda x: x[-1])\n",
"df_stat"
]
},
Expand Down Expand Up @@ -250,7 +254,7 @@
}
],
"source": [
"df['time_spglib'].sum() / df['time_moyopy'].sum()"
"df[\"time_spglib\"].sum() / df[\"time_moyopy\"].sum()"
]
},
{
Expand All @@ -272,15 +276,17 @@
"source": [
"fig, ax = plt.subplots(figsize=(6.75, 6.75))\n",
"# df.plot.scatter(x='time_spglib', y='time_moyopy', ax=ax, facecolors='none', edgecolors='C0')\n",
"ax.scatter(df['time_spglib'], df['time_moyopy'], facecolors='none', edgecolors='C0', s=8, linewidths=1)\n",
"ax.scatter(\n",
" df[\"time_spglib\"], df[\"time_moyopy\"], facecolors=\"none\", edgecolors=\"C0\", s=8, linewidths=1\n",
")\n",
"ax.set_xlim(0, 0.1)\n",
"ax.set_ylim(0, 0.1)\n",
"ax.set_xlabel('spglib (s)')\n",
"ax.set_ylabel('moyopy (s)')\n",
"ax.set_aspect('equal')\n",
"ax.set_xlabel(\"spglib (s)\")\n",
"ax.set_ylabel(\"moyopy (s)\")\n",
"ax.set_aspect(\"equal\")\n",
"ax.set_title(\"mp_computed_structure_entries\")\n",
"ax.grid()\n",
"fig.savefig('mp.png', bbox_inches=\"tight\", pad_inches=0.0, dpi=200)"
"fig.savefig(\"mp.png\", bbox_inches=\"tight\", pad_inches=0.0, dpi=200)"
]
},
{
Expand Down Expand Up @@ -309,7 +315,7 @@
}
],
"source": [
"len(df_stat[df_stat['jaccard'] < 1]) / len(df_stat)"
"len(df_stat[df_stat[\"jaccard\"] < 1]) / len(df_stat)"
]
},
{
Expand Down Expand Up @@ -4017,7 +4023,7 @@
}
],
"source": [
"fig = px.histogram(df_stat[df_stat['jaccard'] < 1], x='jaccard', range_x=[0, 0.9])\n",
"fig = px.histogram(df_stat[df_stat[\"jaccard\"] < 1], x=\"jaccard\", range_x=[0, 0.9])\n",
"fig"
]
},
Expand Down Expand Up @@ -4208,7 +4214,7 @@
}
],
"source": [
"df_stat[df_stat['jaccard'] < 1]"
"df_stat[df_stat[\"jaccard\"] < 1]"
]
},
{
Expand Down Expand Up @@ -7167,7 +7173,9 @@
}
],
"source": [
"df_stat[(df_stat['number_moyopy_last'] < df_stat['number_spglib_last']) & (df_stat['jaccard'] < 1)].sort_values('jaccard')"
"df_stat[\n",
" (df_stat[\"number_moyopy_last\"] < df_stat[\"number_spglib_last\"]) & (df_stat[\"jaccard\"] < 1)\n",
"].sort_values(\"jaccard\")"
]
}
],
Expand Down

0 comments on commit 90eef1d

Please sign in to comment.