From 662a482bba1f310bf6f85b9316a495afd6117d49 Mon Sep 17 00:00:00 2001 From: atharva-2001 Date: Wed, 26 Oct 2022 06:34:33 +0530 Subject: [PATCH 1/3] Set contents of tmp file to zero if datasets do not match --- notebooks/ref_data_compare_from_paths.ipynb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/notebooks/ref_data_compare_from_paths.ipynb b/notebooks/ref_data_compare_from_paths.ipynb index 8ad24ef7..08ec40d9 100644 --- a/notebooks/ref_data_compare_from_paths.ipynb +++ b/notebooks/ref_data_compare_from_paths.ipynb @@ -456,6 +456,22 @@ " tmp2['/test_runner_simple/spectrum_virtual/_frequency'][:-1], \n", " tmp2['/test_runner_simple/spectrum_virtual/luminosity'])" ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "if False in tt.match.values or None in tt.match.values:\n", + " print(\"Reference files do not match, setting contents of tmp file to zero.\")\n", + " with open('/tmp/refdata_compare_result', 'w+') as file:\n", + " file.write('0')\n", + "else:\n", + " print(\"Reference files match.\")\n", + " with open('/tmp/refdata_compare_result', 'w+') as file:\n", + " file.write('1') " + ] } ], "metadata": { From e2ecfdc53421ec1a44d2b8c6e9085c49df3c2a9c Mon Sep 17 00:00:00 2001 From: atharva-2001 Date: Tue, 8 Nov 2022 15:26:19 +0530 Subject: [PATCH 2/3] change file location and contents --- notebooks/ref_data_compare_from_paths.ipynb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/notebooks/ref_data_compare_from_paths.ipynb b/notebooks/ref_data_compare_from_paths.ipynb index 08ec40d9..13c42f22 100644 --- a/notebooks/ref_data_compare_from_paths.ipynb +++ b/notebooks/ref_data_compare_from_paths.ipynb @@ -465,12 +465,12 @@ "source": [ "if False in tt.match.values or None in tt.match.values:\n", " print(\"Reference files do not match, setting contents of tmp file to zero.\")\n", - " with open('/tmp/refdata_compare_result', 'w+') as file:\n", - " file.write('0')\n", + " with open('refdata_compare_result', 'w+') as file:\n", + " file.write('REFDATA COMPARISON FAILED')\n", "else:\n", " print(\"Reference files match.\")\n", - " with open('/tmp/refdata_compare_result', 'w+') as file:\n", - " file.write('1') " + " with open('refdata_compare_result', 'w+') as file:\n", + " file.write('REFDATA COMPARISON SUCCEEDED') " ] } ], From 713194e764ac4fa31b1af974cb968651916346d1 Mon Sep 17 00:00:00 2001 From: atharva-2001 Date: Thu, 17 Nov 2022 21:32:32 +0530 Subject: [PATCH 3/3] Rename file variable to fh --- notebooks/ref_data_compare_from_paths.ipynb | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/notebooks/ref_data_compare_from_paths.ipynb b/notebooks/ref_data_compare_from_paths.ipynb index 13c42f22..037e1fa3 100644 --- a/notebooks/ref_data_compare_from_paths.ipynb +++ b/notebooks/ref_data_compare_from_paths.ipynb @@ -9,7 +9,6 @@ "import os\n", "import sys\n", "import shutil\n", - "import tempfile\n", "import subprocess\n", "import numpy as np\n", "import pandas as pd\n", @@ -465,12 +464,12 @@ "source": [ "if False in tt.match.values or None in tt.match.values:\n", " print(\"Reference files do not match, setting contents of tmp file to zero.\")\n", - " with open('refdata_compare_result', 'w+') as file:\n", - " file.write('REFDATA COMPARISON FAILED')\n", + " with open('refdata_compare_result', 'w+') as fh:\n", + " fh.write('REFDATA COMPARISON FAILED')\n", "else:\n", " print(\"Reference files match.\")\n", - " with open('refdata_compare_result', 'w+') as file:\n", - " file.write('REFDATA COMPARISON SUCCEEDED') " + " with open('refdata_compare_result', 'w+') as fh:\n", + " fh.write('REFDATA COMPARISON SUCCEEDED') " ] } ],