diff --git a/.gitignore b/.gitignore index b90f1e7c..b2804f35 100644 --- a/.gitignore +++ b/.gitignore @@ -104,3 +104,6 @@ ENV/ #auto changing files build/ src/ + +# Backport +.backportrc.json \ No newline at end of file diff --git a/doc/changelog.rst b/doc/changelog.rst index 4efeab35..01902499 100644 --- a/doc/changelog.rst +++ b/doc/changelog.rst @@ -21,6 +21,8 @@ Contributors Fixed ----- +- Deletion of temporary files saved to temporary directories in user guide + (`#312 `_) - Pattern matching sometimes failing to generate a crystal map due to incorrect creation of spatial arrays (`#307 `_) diff --git a/doc/geometrical_ebsd_simulations.ipynb b/doc/geometrical_ebsd_simulations.ipynb index 66caab53..fb7a1966 100644 --- a/doc/geometrical_ebsd_simulations.ipynb +++ b/doc/geometrical_ebsd_simulations.ipynb @@ -415,8 +415,8 @@ "outputs": [], "source": [ "nav_x, nav_y = s.axes_manager.indices\n", - "temp_dir = tempfile.mkdtemp()\n", - "fname = temp_dir + f\"/geosim_y{nav_y}_x{nav_x}.png\"\n", + "temp_dir = tempfile.mkdtemp() + \"/\"\n", + "fname = temp_dir + f\"geosim_y{nav_y}_x{nav_x}.png\"\n", "s._plot.signal_plot.figure.savefig(fname, bbox_inches=bbox, dpi=150)" ] }, @@ -444,7 +444,7 @@ "outputs": [], "source": [ "nav_x, nav_y = s.axes_manager.indices\n", - "fname = temp_dir + f\"/geosim_y{nav_y}_x{nav_x}.png\"\n", + "fname = temp_dir + f\"geosim_y{nav_y}_x{nav_x}.png\"\n", "s._plot.signal_plot.figure.savefig(fname, bbox_inches=bbox, dpi=150)" ] }, @@ -602,13 +602,14 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "nbsphinx": "hidden" - }, + "metadata": {}, "outputs": [], "source": [ - "from shutil import rmtree\n", - "rmtree(temp_dir) # Remove files written to disk in this user guide" + "# Remove files written to disk in this user guide\n", + "import os\n", + "for file in [\"geosim_y0_x0.png\", \"geosim_y1_x2.png\"]:\n", + " os.remove(temp_dir + file)\n", + "os.rmdir(temp_dir)" ] } ], diff --git a/doc/load_save_data.ipynb b/doc/load_save_data.ipynb index d7a02839..fcf3a715 100644 --- a/doc/load_save_data.ipynb +++ b/doc/load_save_data.ipynb @@ -397,7 +397,7 @@ "metadata": {}, "outputs": [], "source": [ - "temp_dir = tempfile.mkdtemp()\n", + "temp_dir = tempfile.mkdtemp() + \"/\"\n", "s.save(temp_dir + \"patterns\")" ] }, @@ -957,7 +957,18 @@ }, "outputs": [], "source": [ + "# Remove files written to disk in this user guide\n", "import os\n", + "for file in [\n", + " \"patterns.h5\",\n", + " \"patterns_new.h5\",\n", + " \"patterns.dat\",\n", + " \"master_pattern.hspy\",\n", + " \"vbse.tif\",\n", + "]:\n", + " os.remove(temp_dir + file)\n", + "for i in range(25):\n", + " os.remove(temp_dir + f\"vbse{i}.png\")\n", "os.rmdir(temp_dir)" ] } diff --git a/doc/pattern_matching.ipynb b/doc/pattern_matching.ipynb index 180fdc73..11b05320 100644 --- a/doc/pattern_matching.ipynb +++ b/doc/pattern_matching.ipynb @@ -341,7 +341,7 @@ "metadata": {}, "outputs": [], "source": [ - "temp_dir = tempfile.mkdtemp()\n", + "temp_dir = tempfile.mkdtemp() + \"/\"\n", "xmap_file = temp_dir + \"ni.h5\"\n", "io.save(xmap_file, xmap)" ] @@ -449,7 +449,9 @@ }, "outputs": [], "source": [ + "# Remove files written to disk in this user guide\n", "import os\n", + "os.remove(xmap_file)\n", "os.rmdir(temp_dir)" ] } diff --git a/doc/virtual_backscatter_electron_imaging.ipynb b/doc/virtual_backscatter_electron_imaging.ipynb index 495e1c39..400f40f0 100644 --- a/doc/virtual_backscatter_electron_imaging.ipynb +++ b/doc/virtual_backscatter_electron_imaging.ipynb @@ -120,7 +120,7 @@ "metadata": {}, "outputs": [], "source": [ - "temp_dir = tempfile.mkdtemp()\n", + "temp_dir = tempfile.mkdtemp() + \"/\"\n", "plt.imsave(temp_dir + \"vbse1.png\", arr=vbse.data)" ] }, @@ -377,7 +377,9 @@ }, "outputs": [], "source": [ + "# Remove files written to disk in this user guide\n", "import os\n", + "os.remove(temp_dir + \"vbse1.png\")\n", "os.rmdir(temp_dir)" ] }