We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Zero
>>> wt.units.convert(0, "wn", "nm")
ZeroDivisionError: division by zero
>>> wt.units.convert(0, "nm", "wn")
ZeroDivisionError: division by zero

Should return inf

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `WrightTools/units.py`
Content:
```
1 """Unit and label handling in WrightTools."""
2 
3 
4 # --- import --------------------------------------------------------------------------------------
5 
6 
7 import warnings
8 
9 import pint
10 
11 
12 # --- define --------------------------------------------------------------------------------------
13 
14 # Thise "blessed" units are here primarily for backwards compatibility, in particular
15 # to enable the behavior of `data.convert` which will convert freely between the energy units
16 # but does not go to time (where delay will)
17 # Since both of these context can convert to [length] units, they are interconvertible, but we
18 # do not want them to automatically do so.
19 # This list is (at creation time) purely reflective of historical units supported pre pint
20 # There is nothing preventing other units from being used and converted to, only to enable
21 # expected behavior
22 # 2021-01-29 KFS
23 blessed_units = (
24     # angle
25     "rad",
26     "deg",
27     # delay
28     "fs",
29     "ps",
30     "ns",
31     "mm_delay",
32     # energy
33     "nm",
34     "wn",
35     "eV",
36     "meV",
37     "Hz",
38     "THz",
39     "GHz",
40     # optical density
41     "mOD",
42     # position
43     "nm_p",
44     "um",
45     "mm",
46     "cm",
47     "in",
48     # absolute temperature
49     "K",
50     "deg_C",
51     "deg_F",
52     "deg_R",
53     # time
54     "fs_t",
55     "ps_t",
56     "ns_t",
57     "us_t",
58     "ns_t",
59     "s_t",
60     "m_t",
61     "h_t",
62     "d_t",
63 )
64 
65 ureg = pint.UnitRegistry()
66 ureg.define("[fluence] = [energy] / [area]")
67 
68 ureg.define("OD = [] ")
69 
70 ureg.define("wavenumber = 1 / cm = cm^{-1} = wn")
71 
72 
73 # Aliases for backwards compatability
74 ureg.define("@alias s = s_t")
75 ureg.define("@alias min = m_t")
76 ureg.define("@alias hour = h_t")
77 ureg.define("@alias d = d_t")
78 
79 ureg.define("@alias degC = deg_C")
80 ureg.define("@alias degF = deg_F")
81 ureg.define("@alias degR = deg_R")
82 
83 ureg.define("@alias m = m_delay")
84 
85 delay = pint.Context("delay", defaults={"n": 1, "num_pass": 2})
86 delay.add_transformation(
87     "[length]", "[time]", lambda ureg, x, n=1, num_pass=2: num_pass * x / ureg.speed_of_light * n
88 )
89 delay.add_transformation(
90     "[time]", "[length]", lambda ureg, x, n=1, num_pass=2: x / num_pass * ureg.speed_of_light / n
91 )
92 ureg.enable_contexts("spectroscopy", delay)
93 
94 # --- functions -----------------------------------------------------------------------------------
95 
96 
97 def converter(val, current_unit, destination_unit):
98     """Convert from one unit to another.
99 
100     Parameters
101     ----------
102     val : number
103         Number to convert.
104     current_unit : string
105         Current unit.
106     destination_unit : string
107         Destination unit.
108 
109     Returns
110     -------
111     number
112         Converted value.
113     """
114     try:
115         val = ureg.Quantity(val, current_unit).to(destination_unit).magnitude
116     except (pint.errors.DimensionalityError, pint.errors.UndefinedUnitError, AttributeError):
117         warnings.warn(
118             "conversion {0} to {1} not valid: returning input".format(
119                 current_unit, destination_unit
120             )
121         )
122     return val
123 
124 
125 convert = converter
126 
127 
128 def get_symbol(units) -> str:
129     """Get default symbol type.
130 
131     Parameters
132     ----------
133     units_str : string
134         Units.
135 
136     Returns
137     -------
138     string
139         LaTeX formatted symbol.
140     """
141     quantity = ureg.Quantity(1, ureg[units])
142     if quantity.check("[length]"):
143         return r"\lambda"
144     elif quantity.check("1 / [length]"):
145         return r"\bar\nu"
146     elif quantity.check("[energy]"):
147         return r"\hslash\omega"
148     elif quantity.check("1 / [time]"):
149         return "f"
150     elif quantity.check("[time]"):
151         return r"\tau"
152     elif quantity.check("[fluence]"):
153         return r"\mathcal{F}"
154     elif quantity.check("[temperature]"):
155         return "T"
156     elif ureg[units] in (ureg.deg, ureg.radian):
157         return r"\omega"
158     else:
159         return None
160 
161 
162 def get_valid_conversions(units, options=blessed_units) -> tuple:
163     return tuple(i for i in options if is_valid_conversion(units, i) and units != i)
164 
165 
166 def is_valid_conversion(a, b, blessed=True) -> bool:
167     if a is None:
168         return b is None
169     if blessed and a in blessed_units and b in blessed_units:
170         blessed_energy_units = {"nm", "wn", "eV", "meV", "Hz", "THz", "GHz"}
171         if a in blessed_energy_units:
172             return b in blessed_energy_units
173         blessed_delay_units = {"fs", "ps", "ns", "mm_delay"}
174         if a in blessed_delay_units:
175             return b in blessed_delay_units
176         return ureg.Unit(a).dimensionality == ureg.Unit(b).dimensionality
177     try:
178         return ureg.Unit(a).is_compatible_with(b, "spectroscopy")
179     except pint.UndefinedUnitError:
180         return False
181 
182 
183 def kind(units):
184     """Find the dimensionality of given units.
185 
186     Parameters
187     ----------
188     units : string
189         The units of interest
190 
191     Returns
192     -------
193     string
194         The kind of the given units. If no match is found, returns None.
195     """
196     if units is None:
197         return None
198     return str(ureg.Unit(units).dimensionality)
199
```
--- 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()

```

diff --git a/WrightTools/units.py b/WrightTools/units.py
--- a/WrightTools/units.py
+++ b/WrightTools/units.py
@@ -115,10 +115,13 @@
         val = ureg.Quantity(val, current_unit).to(destination_unit).magnitude
     except (pint.errors.DimensionalityError, pint.errors.UndefinedUnitError, AttributeError):
         warnings.warn(
-            "conversion {0} to {1} not valid: returning input".format(
-                current_unit, destination_unit
-            )
+            f"conversion {current_unit} to {destination_unit} not valid: returning input"
         )
+    except ZeroDivisionError:
+        warnings.warn(
+            f"conversion {current_unit} to {destination_unit} resulted in ZeroDivisionError: returning inf"
+        )
+        return float("inf")
     return val

{"golden_diff": "diff --git a/WrightTools/units.py b/WrightTools/units.py\n--- a/WrightTools/units.py\n+++ b/WrightTools/units.py\n@@ -115,10 +115,13 @@\n         val = ureg.Quantity(val, current_unit).to(destination_unit).magnitude\n     except (pint.errors.DimensionalityError, pint.errors.UndefinedUnitError, AttributeError):\n         warnings.warn(\n-            \"conversion {0} to {1} not valid: returning input\".format(\n-                current_unit, destination_unit\n-            )\n+            f\"conversion {current_unit} to {destination_unit} not valid: returning input\"\n         )\n+    except ZeroDivisionError:\n+        warnings.warn(\n+            f\"conversion {current_unit} to {destination_unit} resulted in ZeroDivisionError: returning inf\"\n+        )\n+        return float(\"inf\")\n     return val\n", "issue": "Zero\n>>> wt.units.convert(0, \"wn\", \"nm\")\r\nZeroDivisionError: division by zero\r\n>>> wt.units.convert(0, \"nm\", \"wn\")\r\nZeroDivisionError: division by zero\r\n\r\nShould return inf\n", "before_files": [{"content": "\"\"\"Unit and label handling in WrightTools.\"\"\"\n\n\n# --- import --------------------------------------------------------------------------------------\n\n\nimport warnings\n\nimport pint\n\n\n# --- define --------------------------------------------------------------------------------------\n\n# Thise \"blessed\" units are here primarily for backwards compatibility, in particular\n# to enable the behavior of `data.convert` which will convert freely between the energy units\n# but does not go to time (where delay will)\n# Since both of these context can convert to [length] units, they are interconvertible, but we\n# do not want them to automatically do so.\n# This list is (at creation time) purely reflective of historical units supported pre pint\n# There is nothing preventing other units from being used and converted to, only to enable\n# expected behavior\n# 2021-01-29 KFS\nblessed_units = (\n    # angle\n    \"rad\",\n    \"deg\",\n    # delay\n    \"fs\",\n    \"ps\",\n    \"ns\",\n    \"mm_delay\",\n    # energy\n    \"nm\",\n    \"wn\",\n    \"eV\",\n    \"meV\",\n    \"Hz\",\n    \"THz\",\n    \"GHz\",\n    # optical density\n    \"mOD\",\n    # position\n    \"nm_p\",\n    \"um\",\n    \"mm\",\n    \"cm\",\n    \"in\",\n    # absolute temperature\n    \"K\",\n    \"deg_C\",\n    \"deg_F\",\n    \"deg_R\",\n    # time\n    \"fs_t\",\n    \"ps_t\",\n    \"ns_t\",\n    \"us_t\",\n    \"ns_t\",\n    \"s_t\",\n    \"m_t\",\n    \"h_t\",\n    \"d_t\",\n)\n\nureg = pint.UnitRegistry()\nureg.define(\"[fluence] = [energy] / [area]\")\n\nureg.define(\"OD = [] \")\n\nureg.define(\"wavenumber = 1 / cm = cm^{-1} = wn\")\n\n\n# Aliases for backwards compatability\nureg.define(\"@alias s = s_t\")\nureg.define(\"@alias min = m_t\")\nureg.define(\"@alias hour = h_t\")\nureg.define(\"@alias d = d_t\")\n\nureg.define(\"@alias degC = deg_C\")\nureg.define(\"@alias degF = deg_F\")\nureg.define(\"@alias degR = deg_R\")\n\nureg.define(\"@alias m = m_delay\")\n\ndelay = pint.Context(\"delay\", defaults={\"n\": 1, \"num_pass\": 2})\ndelay.add_transformation(\n    \"[length]\", \"[time]\", lambda ureg, x, n=1, num_pass=2: num_pass * x / ureg.speed_of_light * n\n)\ndelay.add_transformation(\n    \"[time]\", \"[length]\", lambda ureg, x, n=1, num_pass=2: x / num_pass * ureg.speed_of_light / n\n)\nureg.enable_contexts(\"spectroscopy\", delay)\n\n# --- functions -----------------------------------------------------------------------------------\n\n\ndef converter(val, current_unit, destination_unit):\n    \"\"\"Convert from one unit to another.\n\n    Parameters\n    ----------\n    val : number\n        Number to convert.\n    current_unit : string\n        Current unit.\n    destination_unit : string\n        Destination unit.\n\n    Returns\n    -------\n    number\n        Converted value.\n    \"\"\"\n    try:\n        val = ureg.Quantity(val, current_unit).to(destination_unit).magnitude\n    except (pint.errors.DimensionalityError, pint.errors.UndefinedUnitError, AttributeError):\n        warnings.warn(\n            \"conversion {0} to {1} not valid: returning input\".format(\n                current_unit, destination_unit\n            )\n        )\n    return val\n\n\nconvert = converter\n\n\ndef get_symbol(units) -> str:\n    \"\"\"Get default symbol type.\n\n    Parameters\n    ----------\n    units_str : string\n        Units.\n\n    Returns\n    -------\n    string\n        LaTeX formatted symbol.\n    \"\"\"\n    quantity = ureg.Quantity(1, ureg[units])\n    if quantity.check(\"[length]\"):\n        return r\"\\lambda\"\n    elif quantity.check(\"1 / [length]\"):\n        return r\"\\bar\\nu\"\n    elif quantity.check(\"[energy]\"):\n        return r\"\\hslash\\omega\"\n    elif quantity.check(\"1 / [time]\"):\n        return \"f\"\n    elif quantity.check(\"[time]\"):\n        return r\"\\tau\"\n    elif quantity.check(\"[fluence]\"):\n        return r\"\\mathcal{F}\"\n    elif quantity.check(\"[temperature]\"):\n        return \"T\"\n    elif ureg[units] in (ureg.deg, ureg.radian):\n        return r\"\\omega\"\n    else:\n        return None\n\n\ndef get_valid_conversions(units, options=blessed_units) -> tuple:\n    return tuple(i for i in options if is_valid_conversion(units, i) and units != i)\n\n\ndef is_valid_conversion(a, b, blessed=True) -> bool:\n    if a is None:\n        return b is None\n    if blessed and a in blessed_units and b in blessed_units:\n        blessed_energy_units = {\"nm\", \"wn\", \"eV\", \"meV\", \"Hz\", \"THz\", \"GHz\"}\n        if a in blessed_energy_units:\n            return b in blessed_energy_units\n        blessed_delay_units = {\"fs\", \"ps\", \"ns\", \"mm_delay\"}\n        if a in blessed_delay_units:\n            return b in blessed_delay_units\n        return ureg.Unit(a).dimensionality == ureg.Unit(b).dimensionality\n    try:\n        return ureg.Unit(a).is_compatible_with(b, \"spectroscopy\")\n    except pint.UndefinedUnitError:\n        return False\n\n\ndef kind(units):\n    \"\"\"Find the dimensionality of given units.\n\n    Parameters\n    ----------\n    units : string\n        The units of interest\n\n    Returns\n    -------\n    string\n        The kind of the given units. If no match is found, returns None.\n    \"\"\"\n    if units is None:\n        return None\n    return str(ureg.Unit(units).dimensionality)\n", "path": "WrightTools/units.py"}], "after_files": [{"content": "\"\"\"Unit and label handling in WrightTools.\"\"\"\n\n\n# --- import --------------------------------------------------------------------------------------\n\n\nimport warnings\n\nimport pint\n\n\n# --- define --------------------------------------------------------------------------------------\n\n# Thise \"blessed\" units are here primarily for backwards compatibility, in particular\n# to enable the behavior of `data.convert` which will convert freely between the energy units\n# but does not go to time (where delay will)\n# Since both of these context can convert to [length] units, they are interconvertible, but we\n# do not want them to automatically do so.\n# This list is (at creation time) purely reflective of historical units supported pre pint\n# There is nothing preventing other units from being used and converted to, only to enable\n# expected behavior\n# 2021-01-29 KFS\nblessed_units = (\n    # angle\n    \"rad\",\n    \"deg\",\n    # delay\n    \"fs\",\n    \"ps\",\n    \"ns\",\n    \"mm_delay\",\n    # energy\n    \"nm\",\n    \"wn\",\n    \"eV\",\n    \"meV\",\n    \"Hz\",\n    \"THz\",\n    \"GHz\",\n    # optical density\n    \"mOD\",\n    # position\n    \"nm_p\",\n    \"um\",\n    \"mm\",\n    \"cm\",\n    \"in\",\n    # absolute temperature\n    \"K\",\n    \"deg_C\",\n    \"deg_F\",\n    \"deg_R\",\n    # time\n    \"fs_t\",\n    \"ps_t\",\n    \"ns_t\",\n    \"us_t\",\n    \"ns_t\",\n    \"s_t\",\n    \"m_t\",\n    \"h_t\",\n    \"d_t\",\n)\n\nureg = pint.UnitRegistry()\nureg.define(\"[fluence] = [energy] / [area]\")\n\nureg.define(\"OD = [] \")\n\nureg.define(\"wavenumber = 1 / cm = cm^{-1} = wn\")\n\n\n# Aliases for backwards compatability\nureg.define(\"@alias s = s_t\")\nureg.define(\"@alias min = m_t\")\nureg.define(\"@alias hour = h_t\")\nureg.define(\"@alias d = d_t\")\n\nureg.define(\"@alias degC = deg_C\")\nureg.define(\"@alias degF = deg_F\")\nureg.define(\"@alias degR = deg_R\")\n\nureg.define(\"@alias m = m_delay\")\n\ndelay = pint.Context(\"delay\", defaults={\"n\": 1, \"num_pass\": 2})\ndelay.add_transformation(\n    \"[length]\", \"[time]\", lambda ureg, x, n=1, num_pass=2: num_pass * x / ureg.speed_of_light * n\n)\ndelay.add_transformation(\n    \"[time]\", \"[length]\", lambda ureg, x, n=1, num_pass=2: x / num_pass * ureg.speed_of_light / n\n)\nureg.enable_contexts(\"spectroscopy\", delay)\n\n# --- functions -----------------------------------------------------------------------------------\n\n\ndef converter(val, current_unit, destination_unit):\n    \"\"\"Convert from one unit to another.\n\n    Parameters\n    ----------\n    val : number\n        Number to convert.\n    current_unit : string\n        Current unit.\n    destination_unit : string\n        Destination unit.\n\n    Returns\n    -------\n    number\n        Converted value.\n    \"\"\"\n    try:\n        val = ureg.Quantity(val, current_unit).to(destination_unit).magnitude\n    except (pint.errors.DimensionalityError, pint.errors.UndefinedUnitError, AttributeError):\n        warnings.warn(\n            f\"conversion {current_unit} to {destination_unit} not valid: returning input\"\n        )\n    except ZeroDivisionError:\n        warnings.warn(\n            f\"conversion {current_unit} to {destination_unit} resulted in ZeroDivisionError: returning inf\"\n        )\n        return float(\"inf\")\n    return val\n\n\nconvert = converter\n\n\ndef get_symbol(units) -> str:\n    \"\"\"Get default symbol type.\n\n    Parameters\n    ----------\n    units_str : string\n        Units.\n\n    Returns\n    -------\n    string\n        LaTeX formatted symbol.\n    \"\"\"\n    quantity = ureg.Quantity(1, ureg[units])\n    if quantity.check(\"[length]\"):\n        return r\"\\lambda\"\n    elif quantity.check(\"1 / [length]\"):\n        return r\"\\bar\\nu\"\n    elif quantity.check(\"[energy]\"):\n        return r\"\\hslash\\omega\"\n    elif quantity.check(\"1 / [time]\"):\n        return \"f\"\n    elif quantity.check(\"[time]\"):\n        return r\"\\tau\"\n    elif quantity.check(\"[fluence]\"):\n        return r\"\\mathcal{F}\"\n    elif quantity.check(\"[temperature]\"):\n        return \"T\"\n    elif ureg[units] in (ureg.deg, ureg.radian):\n        return r\"\\omega\"\n    else:\n        return None\n\n\ndef get_valid_conversions(units, options=blessed_units) -> tuple:\n    return tuple(i for i in options if is_valid_conversion(units, i) and units != i)\n\n\ndef is_valid_conversion(a, b, blessed=True) -> bool:\n    if a is None:\n        return b is None\n    if blessed and a in blessed_units and b in blessed_units:\n        blessed_energy_units = {\"nm\", \"wn\", \"eV\", \"meV\", \"Hz\", \"THz\", \"GHz\"}\n        if a in blessed_energy_units:\n            return b in blessed_energy_units\n        blessed_delay_units = {\"fs\", \"ps\", \"ns\", \"mm_delay\"}\n        if a in blessed_delay_units:\n            return b in blessed_delay_units\n        return ureg.Unit(a).dimensionality == ureg.Unit(b).dimensionality\n    try:\n        return ureg.Unit(a).is_compatible_with(b, \"spectroscopy\")\n    except pint.UndefinedUnitError:\n        return False\n\n\ndef kind(units):\n    \"\"\"Find the dimensionality of given units.\n\n    Parameters\n    ----------\n    units : string\n        The units of interest\n\n    Returns\n    -------\n    string\n        The kind of the given units. If no match is found, returns None.\n    \"\"\"\n    if units is None:\n        return None\n    return str(ureg.Unit(units).dimensionality)\n", "path": "WrightTools/units.py"}]}