Skip to content

Commit

Permalink
Correct deletion of temp files in temp dirs in user guide
Browse files Browse the repository at this point in the history
Signed-off-by: Håkon Wiik Ånes <[email protected]>
  • Loading branch information
hakonanes committed Feb 1, 2021
1 parent 05071ee commit a9ff191
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 11 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,6 @@ ENV/
#auto changing files
build/
src/

# Backport
.backportrc.json
2 changes: 2 additions & 0 deletions doc/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ Contributors

Fixed
-----
- Deletion of temporary files saved to temporary directories in user guide
(`#311 <https://github.com/pyxem/kikuchipy/pull/311>`_)
- Pattern matching sometimes failing to generate a crystal map due to incorrect
creation of spatial arrays
(`#307 <https://github.com/pyxem/kikuchipy/pull/307>`_)
Expand Down
17 changes: 9 additions & 8 deletions doc/geometrical_ebsd_simulations.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
]
},
Expand Down Expand Up @@ -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)"
]
},
Expand Down Expand Up @@ -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)"
]
}
],
Expand Down
13 changes: 12 additions & 1 deletion doc/load_save_data.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@
"metadata": {},
"outputs": [],
"source": [
"temp_dir = tempfile.mkdtemp()\n",
"temp_dir = tempfile.mkdtemp() + \"/\"\n",
"s.save(temp_dir + \"patterns\")"
]
},
Expand Down Expand Up @@ -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)"
]
}
Expand Down
4 changes: 3 additions & 1 deletion doc/pattern_matching.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
]
Expand Down Expand Up @@ -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)"
]
}
Expand Down
4 changes: 3 additions & 1 deletion doc/virtual_backscatter_electron_imaging.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
]
},
Expand Down Expand Up @@ -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)"
]
}
Expand Down

0 comments on commit a9ff191

Please sign in to comment.