prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Use numpy.load and save instead of pickle
  As @StanczakDominik put it:
  
  > By the way, apparently pickle is unsafe due to allowing arbitrary code execution, and we're now including those in Langmuir samples. @jasperbeckers do you think we could transition to numpy.save and numpy.load .npz files? We're just storing two arrays in each of those anyway, right?
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `plasmapy/examples/plot_langmuir_analysis.py`
  Content:
  ```
  1 # coding: utf-8
  2 """
  3 Langmuir probe data analysis
  4 ============================
  5 
  6 Let's analyze a few Langmuir probe characteristics using the
  7 `diagnostics.langmuir` subpackage. First we need to import the module and some
  8 basics.
  9 """
  10 
  11 from plasmapy.diagnostics.langmuir import Characteristic, swept_probe_analysis
  12 import astropy.units as u
  13 import numpy as np
  14 import pickle
  15 import os
  16 
  17 ######################################################
  18 # The first characteristic we analyze is a simple single-probe measurement in
  19 # a low (ion) temperature, low density plasma with a cylindrical probe. This
  20 # allows us to utilize OML theory implemented in `swept_probe_analysis`.
  21 # The data has been preprocessed with some smoothing, which allows us to obtain
  22 # a Electron Energy Distribution Function (EEDF) as well.
  23 
  24 # Load the bias and current values stored in the .p pickle file.
  25 path = os.path.join("langmuir_samples", "Beckers2017.p")
  26 bias, current = pickle.load(open(path, 'rb'))
  27 
  28 # Create the Characteristic object, taking into account the correct units
  29 characteristic = Characteristic(np.array(bias) * u.V,
  30                                 np.array(current)*1e3 * u.mA)
  31 
  32 # Calculate the cylindrical probe surface area
  33 probe_length = 1.145 * u.mm
  34 probe_diameter = 1.57 * u.mm
  35 probe_area = (probe_length * np.pi * probe_diameter +
  36               np.pi * 0.25 * probe_diameter**2)
  37 
  38 ######################################################
  39 # Now we can actually perform the analysis. Since the plasma is in Helium an
  40 # ion mass number of 4 is entered. The results are visualized and the obtained
  41 # EEDF is also shown.
  42 print(swept_probe_analysis(characteristic,
  43                            probe_area, 4 * u.u,
  44                            visualize=True,
  45                            plot_EEDF=True))
  46 
  47 ######################################################
  48 # The cyan and yellow lines indicate the fitted electron and ion currents,
  49 # respectively. The green line is the sum of these and agrees nicely with the
  50 # data. This indicates a succesfull analysis.
  51 
  52 ######################################################
  53 # The next sample probe data is provided by David Pace. is also obtained from a low relatively ion
  54 # temperature and density plasma, in Argon.
  55 
  56 # Load the data from a file and create the Characteristic object
  57 path = os.path.join("langmuir_samples", "Pace2015.p")
  58 bias, current = pickle.load(open(path, 'rb'))
  59 characteristic = Characteristic(np.array(bias) * u.V,
  60                                 np.array(current) * 1e3 * u.mA)
  61 
  62 ######################################################
  63 # Initially the electrons are assumed to be Maxwellian. To check this the fit
  64 # of the electron growth region will be plotted.
  65 swept_probe_analysis(characteristic,
  66                      0.738 * u.cm**2,
  67                      40 * u.u,
  68                      bimaxwellian=False,
  69                      plot_electron_fit=True)
  70 
  71 ######################################################
  72 # It can be seen that this plasma is slightly bi-Maxwellian, as there are two
  73 # distinct slopes in the exponential section. The analysis is now performed
  74 # with bimaxwellian set to True, which yields improved results.
  75 print(swept_probe_analysis(characteristic,
  76                            0.738 * u.cm**2,
  77                            40 * u.u,
  78                            bimaxwellian=True,
  79                            visualize=True,
  80                            plot_electron_fit=True))
  81 
  82 ######################################################
  83 # The probe current resolution of the raw data is relatively poor, but the
  84 # analysis still performs well in the ion current region. The bi-Maxwellian
  85 # properties are not significant but do make a difference. Check this analysis
  86 # without setting `bimaxwellian` to True!
  87 # This is reflected in the results, which indicate that the temperatures of
  88 # the cold and hot electron population are indeed different, but relatively
  89 # close.
  90 
  91 ######################################################
  92 # This Helium plasma is fully bi-Maxwellian.
  93 
  94 # Import probe data and calculate probe surface area.
  95 path = os.path.join("langmuir_samples", "Beckers2017b.p")
  96 bias, current = pickle.load(open(path, 'rb'))
  97 characteristic = Characteristic(np.array(bias) * u.V,
  98                                 np.array(current) * 1e3 * u.mA)
  99 probe_length = 1.145 * u.mm
  100 probe_diameter = 1.57 * u.mm
  101 probe_area = (probe_length * np.pi * probe_diameter +
  102               np.pi * 0.25 * probe_diameter**2)
  103 
  104 ######################################################
  105 # `plot_electron_fit` is set to True to check the bi-Maxwellian properties.
  106 # The fit converges nicely to the two slopes of the electron growth region.
  107 print(swept_probe_analysis(characteristic,
  108                            probe_area,
  109                            4 * u.u,
  110                            bimaxwellian=True,
  111                            plot_electron_fit=True,
  112                            visualize=True))
  113
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/plasmapy/examples/plot_langmuir_analysis.py b/plasmapy/examples/plot_langmuir_analysis.py
  --- a/plasmapy/examples/plot_langmuir_analysis.py
  +++ b/plasmapy/examples/plot_langmuir_analysis.py
  @@ -11,7 +11,6 @@
   from plasmapy.diagnostics.langmuir import Characteristic, swept_probe_analysis
   import astropy.units as u
   import numpy as np
  -import pickle
   import os
   
   ######################################################
  @@ -22,8 +21,8 @@
   # a Electron Energy Distribution Function (EEDF) as well.
   
   # Load the bias and current values stored in the .p pickle file.
  -path = os.path.join("langmuir_samples", "Beckers2017.p")
  -bias, current = pickle.load(open(path, 'rb'))
  +path = os.path.join("langmuir_samples", "Beckers2017.npy")
  +bias, current = np.load(path)
   
   # Create the Characteristic object, taking into account the correct units
   characteristic = Characteristic(np.array(bias) * u.V,
  @@ -50,12 +49,12 @@
   # data. This indicates a succesfull analysis.
   
   ######################################################
  -# The next sample probe data is provided by David Pace. is also obtained from a low relatively ion
  -# temperature and density plasma, in Argon.
  +# The next sample probe data is provided by David Pace. It is also obtained
  +# from a low relatively ion temperature and density plasma, in Argon.
   
   # Load the data from a file and create the Characteristic object
  -path = os.path.join("langmuir_samples", "Pace2015.p")
  -bias, current = pickle.load(open(path, 'rb'))
  +path = os.path.join("langmuir_samples", "Pace2015.npy")
  +bias, current = np.load(path)
   characteristic = Characteristic(np.array(bias) * u.V,
                                   np.array(current) * 1e3 * u.mA)
   
  @@ -92,8 +91,8 @@
   # This Helium plasma is fully bi-Maxwellian.
   
   # Import probe data and calculate probe surface area.
  -path = os.path.join("langmuir_samples", "Beckers2017b.p")
  -bias, current = pickle.load(open(path, 'rb'))
  +path = os.path.join("langmuir_samples", "Beckers2017b.npy")
  +bias, current = np.load(path)
   characteristic = Characteristic(np.array(bias) * u.V,
                                   np.array(current) * 1e3 * u.mA)
   probe_length = 1.145 * u.mm
  
verification_info: {"golden_diff": "diff --git a/plasmapy/examples/plot_langmuir_analysis.py b/plasmapy/examples/plot_langmuir_analysis.py\n--- a/plasmapy/examples/plot_langmuir_analysis.py\n+++ b/plasmapy/examples/plot_langmuir_analysis.py\n@@ -11,7 +11,6 @@\n from plasmapy.diagnostics.langmuir import Characteristic, swept_probe_analysis\n import astropy.units as u\n import numpy as np\n-import pickle\n import os\n \n ######################################################\n@@ -22,8 +21,8 @@\n # a Electron Energy Distribution Function (EEDF) as well.\n \n # Load the bias and current values stored in the .p pickle file.\n-path = os.path.join(\"langmuir_samples\", \"Beckers2017.p\")\n-bias, current = pickle.load(open(path, 'rb'))\n+path = os.path.join(\"langmuir_samples\", \"Beckers2017.npy\")\n+bias, current = np.load(path)\n \n # Create the Characteristic object, taking into account the correct units\n characteristic = Characteristic(np.array(bias) * u.V,\n@@ -50,12 +49,12 @@\n # data. This indicates a succesfull analysis.\n \n ######################################################\n-# The next sample probe data is provided by David Pace. is also obtained from a low relatively ion\n-# temperature and density plasma, in Argon.\n+# The next sample probe data is provided by David Pace. It is also obtained\n+# from a low relatively ion temperature and density plasma, in Argon.\n \n # Load the data from a file and create the Characteristic object\n-path = os.path.join(\"langmuir_samples\", \"Pace2015.p\")\n-bias, current = pickle.load(open(path, 'rb'))\n+path = os.path.join(\"langmuir_samples\", \"Pace2015.npy\")\n+bias, current = np.load(path)\n characteristic = Characteristic(np.array(bias) * u.V,\n                                 np.array(current) * 1e3 * u.mA)\n \n@@ -92,8 +91,8 @@\n # This Helium plasma is fully bi-Maxwellian.\n \n # Import probe data and calculate probe surface area.\n-path = os.path.join(\"langmuir_samples\", \"Beckers2017b.p\")\n-bias, current = pickle.load(open(path, 'rb'))\n+path = os.path.join(\"langmuir_samples\", \"Beckers2017b.npy\")\n+bias, current = np.load(path)\n characteristic = Characteristic(np.array(bias) * u.V,\n                                 np.array(current) * 1e3 * u.mA)\n probe_length = 1.145 * u.mm\n", "issue": "Use numpy.load and save instead of pickle\nAs @StanczakDominik put it:\r\n\r\n> By the way, apparently pickle is unsafe due to allowing arbitrary code execution, and we're now including those in Langmuir samples. @jasperbeckers do you think we could transition to numpy.save and numpy.load .npz files? We're just storing two arrays in each of those anyway, right?\n", "before_files": [{"content": "# coding: utf-8\n\"\"\"\nLangmuir probe data analysis\n============================\n\nLet's analyze a few Langmuir probe characteristics using the\n`diagnostics.langmuir` subpackage. First we need to import the module and some\nbasics.\n\"\"\"\n\nfrom plasmapy.diagnostics.langmuir import Characteristic, swept_probe_analysis\nimport astropy.units as u\nimport numpy as np\nimport pickle\nimport os\n\n######################################################\n# The first characteristic we analyze is a simple single-probe measurement in\n# a low (ion) temperature, low density plasma with a cylindrical probe. This\n# allows us to utilize OML theory implemented in `swept_probe_analysis`.\n# The data has been preprocessed with some smoothing, which allows us to obtain\n# a Electron Energy Distribution Function (EEDF) as well.\n\n# Load the bias and current values stored in the .p pickle file.\npath = os.path.join(\"langmuir_samples\", \"Beckers2017.p\")\nbias, current = pickle.load(open(path, 'rb'))\n\n# Create the Characteristic object, taking into account the correct units\ncharacteristic = Characteristic(np.array(bias) * u.V,\n                                np.array(current)*1e3 * u.mA)\n\n# Calculate the cylindrical probe surface area\nprobe_length = 1.145 * u.mm\nprobe_diameter = 1.57 * u.mm\nprobe_area = (probe_length * np.pi * probe_diameter +\n              np.pi * 0.25 * probe_diameter**2)\n\n######################################################\n# Now we can actually perform the analysis. Since the plasma is in Helium an\n# ion mass number of 4 is entered. The results are visualized and the obtained\n# EEDF is also shown.\nprint(swept_probe_analysis(characteristic,\n                           probe_area, 4 * u.u,\n                           visualize=True,\n                           plot_EEDF=True))\n\n######################################################\n# The cyan and yellow lines indicate the fitted electron and ion currents,\n# respectively. The green line is the sum of these and agrees nicely with the\n# data. This indicates a succesfull analysis.\n\n######################################################\n# The next sample probe data is provided by David Pace. is also obtained from a low relatively ion\n# temperature and density plasma, in Argon.\n\n# Load the data from a file and create the Characteristic object\npath = os.path.join(\"langmuir_samples\", \"Pace2015.p\")\nbias, current = pickle.load(open(path, 'rb'))\ncharacteristic = Characteristic(np.array(bias) * u.V,\n                                np.array(current) * 1e3 * u.mA)\n\n######################################################\n# Initially the electrons are assumed to be Maxwellian. To check this the fit\n# of the electron growth region will be plotted.\nswept_probe_analysis(characteristic,\n                     0.738 * u.cm**2,\n                     40 * u.u,\n                     bimaxwellian=False,\n                     plot_electron_fit=True)\n\n######################################################\n# It can be seen that this plasma is slightly bi-Maxwellian, as there are two\n# distinct slopes in the exponential section. The analysis is now performed\n# with bimaxwellian set to True, which yields improved results.\nprint(swept_probe_analysis(characteristic,\n                           0.738 * u.cm**2,\n                           40 * u.u,\n                           bimaxwellian=True,\n                           visualize=True,\n                           plot_electron_fit=True))\n\n######################################################\n# The probe current resolution of the raw data is relatively poor, but the\n# analysis still performs well in the ion current region. The bi-Maxwellian\n# properties are not significant but do make a difference. Check this analysis\n# without setting `bimaxwellian` to True!\n# This is reflected in the results, which indicate that the temperatures of\n# the cold and hot electron population are indeed different, but relatively\n# close.\n\n######################################################\n# This Helium plasma is fully bi-Maxwellian.\n\n# Import probe data and calculate probe surface area.\npath = os.path.join(\"langmuir_samples\", \"Beckers2017b.p\")\nbias, current = pickle.load(open(path, 'rb'))\ncharacteristic = Characteristic(np.array(bias) * u.V,\n                                np.array(current) * 1e3 * u.mA)\nprobe_length = 1.145 * u.mm\nprobe_diameter = 1.57 * u.mm\nprobe_area = (probe_length * np.pi * probe_diameter +\n              np.pi * 0.25 * probe_diameter**2)\n\n######################################################\n# `plot_electron_fit` is set to True to check the bi-Maxwellian properties.\n# The fit converges nicely to the two slopes of the electron growth region.\nprint(swept_probe_analysis(characteristic,\n                           probe_area,\n                           4 * u.u,\n                           bimaxwellian=True,\n                           plot_electron_fit=True,\n                           visualize=True))\n", "path": "plasmapy/examples/plot_langmuir_analysis.py"}], "after_files": [{"content": "# coding: utf-8\n\"\"\"\nLangmuir probe data analysis\n============================\n\nLet's analyze a few Langmuir probe characteristics using the\n`diagnostics.langmuir` subpackage. First we need to import the module and some\nbasics.\n\"\"\"\n\nfrom plasmapy.diagnostics.langmuir import Characteristic, swept_probe_analysis\nimport astropy.units as u\nimport numpy as np\nimport os\n\n######################################################\n# The first characteristic we analyze is a simple single-probe measurement in\n# a low (ion) temperature, low density plasma with a cylindrical probe. This\n# allows us to utilize OML theory implemented in `swept_probe_analysis`.\n# The data has been preprocessed with some smoothing, which allows us to obtain\n# a Electron Energy Distribution Function (EEDF) as well.\n\n# Load the bias and current values stored in the .p pickle file.\npath = os.path.join(\"langmuir_samples\", \"Beckers2017.npy\")\nbias, current = np.load(path)\n\n# Create the Characteristic object, taking into account the correct units\ncharacteristic = Characteristic(np.array(bias) * u.V,\n                                np.array(current)*1e3 * u.mA)\n\n# Calculate the cylindrical probe surface area\nprobe_length = 1.145 * u.mm\nprobe_diameter = 1.57 * u.mm\nprobe_area = (probe_length * np.pi * probe_diameter +\n              np.pi * 0.25 * probe_diameter**2)\n\n######################################################\n# Now we can actually perform the analysis. Since the plasma is in Helium an\n# ion mass number of 4 is entered. The results are visualized and the obtained\n# EEDF is also shown.\nprint(swept_probe_analysis(characteristic,\n                           probe_area, 4 * u.u,\n                           visualize=True,\n                           plot_EEDF=True))\n\n######################################################\n# The cyan and yellow lines indicate the fitted electron and ion currents,\n# respectively. The green line is the sum of these and agrees nicely with the\n# data. This indicates a succesfull analysis.\n\n######################################################\n# The next sample probe data is provided by David Pace. It is also obtained\n# from a low relatively ion temperature and density plasma, in Argon.\n\n# Load the data from a file and create the Characteristic object\npath = os.path.join(\"langmuir_samples\", \"Pace2015.npy\")\nbias, current = np.load(path)\ncharacteristic = Characteristic(np.array(bias) * u.V,\n                                np.array(current) * 1e3 * u.mA)\n\n######################################################\n# Initially the electrons are assumed to be Maxwellian. To check this the fit\n# of the electron growth region will be plotted.\nswept_probe_analysis(characteristic,\n                     0.738 * u.cm**2,\n                     40 * u.u,\n                     bimaxwellian=False,\n                     plot_electron_fit=True)\n\n######################################################\n# It can be seen that this plasma is slightly bi-Maxwellian, as there are two\n# distinct slopes in the exponential section. The analysis is now performed\n# with bimaxwellian set to True, which yields improved results.\nprint(swept_probe_analysis(characteristic,\n                           0.738 * u.cm**2,\n                           40 * u.u,\n                           bimaxwellian=True,\n                           visualize=True,\n                           plot_electron_fit=True))\n\n######################################################\n# The probe current resolution of the raw data is relatively poor, but the\n# analysis still performs well in the ion current region. The bi-Maxwellian\n# properties are not significant but do make a difference. Check this analysis\n# without setting `bimaxwellian` to True!\n# This is reflected in the results, which indicate that the temperatures of\n# the cold and hot electron population are indeed different, but relatively\n# close.\n\n######################################################\n# This Helium plasma is fully bi-Maxwellian.\n\n# Import probe data and calculate probe surface area.\npath = os.path.join(\"langmuir_samples\", \"Beckers2017b.npy\")\nbias, current = np.load(path)\ncharacteristic = Characteristic(np.array(bias) * u.V,\n                                np.array(current) * 1e3 * u.mA)\nprobe_length = 1.145 * u.mm\nprobe_diameter = 1.57 * u.mm\nprobe_area = (probe_length * np.pi * probe_diameter +\n              np.pi * 0.25 * probe_diameter**2)\n\n######################################################\n# `plot_electron_fit` is set to True to check the bi-Maxwellian properties.\n# The fit converges nicely to the two slopes of the electron growth region.\nprint(swept_probe_analysis(characteristic,\n                           probe_area,\n                           4 * u.u,\n                           bimaxwellian=True,\n                           plot_electron_fit=True,\n                           visualize=True))\n", "path": "plasmapy/examples/plot_langmuir_analysis.py"}]}