From d9e14ca389cf566fcbcb5825d2e98630cf4cfa2b Mon Sep 17 00:00:00 2001 From: Adam Janovsky Date: Fri, 14 Apr 2023 13:55:18 +0200 Subject: fix references notebook --- notebooks/cc/references.ipynb | 106 ++++++++---------------------------------- 1 file changed, 20 insertions(+), 86 deletions(-) diff --git a/notebooks/cc/references.ipynb b/notebooks/cc/references.ipynb index ae191431..c6d2ddb0 100644 --- a/notebooks/cc/references.ipynb +++ b/notebooks/cc/references.ipynb @@ -19,7 +19,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "metadata": { "pycharm": { "name": "#%%\n" @@ -73,21 +73,13 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "metadata": { "pycharm": { "name": "#%%\n" } }, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "Downloading CC Dataset: 100%|██████████████████████████████████████████████████████████████████████████████████████████████| 135M/135M [00:26<00:00, 5.34MB/s]\n" - ] - } - ], + "outputs": [], "source": [ "# Initialize\n", "dset = CCDataset.from_web_latest()" @@ -95,7 +87,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -126,25 +118,14 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": null, "metadata": { "pycharm": { "name": "#%%\n" }, "scrolled": true }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\\newcommand{\\numCcAllDirectReferencing}{1500}\n", - "\\newcommand{\\numCcAllNotDirectReferencing}{3641}\n", - "\\newcommand{\\numCcWithIdDirectReferencing}{1500}\n", - "\\newcommand{\\numCcWithIdNotDirectReferencing}{3565}\n" - ] - } - ], + "outputs": [], "source": [ "df[\"has_outgoing_direct_references\"] = df.directly_referencing.notnull()\n", "df[\"has_incoming_direct_references\"] = df.directly_referenced_by.notnull()\n", @@ -169,26 +150,16 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\\newcommand{\\numCCActiveDirectReferencing}{545}\n", - "\\newcommand{\\numCCActiveDirectReferencingArchived}{169}\n" - ] - } - ], + "outputs": [], "source": [ "print(f\"\\\\newcommand{{\\\\numCCActiveDirectReferencing}}{{{df_id_rich.loc[df_id_rich.status == 'active'].has_outgoing_direct_references.sum()}}}\")\n", "\n", "archived_cert_id_list = set(df_id_rich[df_id_rich.status == \"archived\"].cert_id)\n", "def contains_archived_cert_reference(referencing):\n", - " if referencing is np.nan:\n", + " if pd.isnull(referencing):\n", " return False\n", - " \n", " return bool(archived_cert_id_list.intersection(referencing))\n", "print(f\"\\\\newcommand{{\\\\numCCActiveDirectReferencingArchived}}{{{df_id_rich[df_id_rich.status == 'active'].directly_referencing.apply(contains_archived_cert_reference).sum()}}}\")" ] @@ -202,7 +173,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": null, "metadata": { "pycharm": { "name": "#%%\n" @@ -229,31 +200,19 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": null, "metadata": { "pycharm": { "name": "#%%\n" } }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\\newcommand{\\numCCDirectRefsSameCategory}{2133}\n", - "\\newcommand{\\numCCDirectRefsOtherCategory}{192}\n", - "\\newcommand{\\numCCDirectRefs}{2325}\n", - "\\newcommand{\\numCCDirectRefsFromSmartcards}{1896}\n" - ] - } - ], + "outputs": [], "source": [ "cert_id_to_category_mapping = dict(zip(df.cert_id, df.category))\n", "cert_id_to_category_mapping[np.NaN] = \"No references\"\n", "\n", "exploded = df_id_rich.loc[:, [\"category\", \"directly_referencing\"]].explode(\"directly_referencing\")\n", - "\n", - "exploded[\"ref_category\"] = exploded.directly_referencing.map(cert_id_to_category_mapping)\n", + "exploded[\"ref_category\"] = exploded.directly_referencing.map(lambda x: cert_id_to_category_mapping[x] if pd.notnull(x) else np.nan)\n", "exploded = exploded.loc[exploded.ref_category.notnull()]\n", "\n", "exploded_with_refs = exploded.loc[exploded.ref_category != \"No references\"]\n", @@ -286,7 +245,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": null, "metadata": { "pycharm": { "name": "#%%\n" @@ -320,21 +279,13 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": null, "metadata": { "pycharm": { "name": "#%%\n" } }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Number of certificates that reference some archived certificate: 933\n" - ] - } - ], + "outputs": [], "source": [ "def references_archived_cert(references):\n", " if pd.isnull(references):\n", @@ -373,7 +324,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": null, "metadata": { "pycharm": { "name": "#%%\n" @@ -406,18 +357,9 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\\newcommand{\\numCCUSReferencing}{4}\n", - "\\newcommand{\\numCCUS}{959}\n" - ] - } - ], + "outputs": [], "source": [ "print(f\"\\\\newcommand{{\\\\numCCUSReferencing}}{{{len(df_id_rich.loc[(df_id_rich.scheme == 'US') & (df_id_rich.directly_referencing.notnull())])}}}\")\n", "print(f\"\\\\newcommand{{\\\\numCCUS}}{{{len(df_id_rich.loc[(df_id_rich.scheme == 'US')])}}}\")" @@ -434,7 +376,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": null, "metadata": { "pycharm": { "name": "#%%\n" @@ -1194,7 +1136,6 @@ " for i, label in enumerate(labels):\n", " label_widths = {}\n", " label_widths[side] = df[df[side] == label][side + \"Weight\"].sum()\n", - " print(\"a\")\n", " if i == 0:\n", " label_widths[\"bottom\"] = 0\n", " label_widths[\"top\"] = label_widths[side]\n", @@ -1208,13 +1149,6 @@ " LOGGER.debug(\"%s position of '%s' : %s\", side, label, label_widths)\n", " return widths, topEdge\n" ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { -- cgit v1.3.1