We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
collection.convert
Would like to support syntax `collection.convert(unit)`.

Would convert all contained data objects recursively.

--- 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/collection/_collection.py`
Content:
```
1 """Collection."""
2 
3 
4 # --- import --------------------------------------------------------------------------------------
5 
6 
7 import numpy as np
8 
9 from .. import data as wt_data
10 from .. import exceptions as wt_exceptions
11 from .._group import Group
12 
13 
14 # --- define --------------------------------------------------------------------------------------
15 
16 
17 __all__ = ["Collection"]
18 
19 
20 # --- classes -------------------------------------------------------------------------------------
21 
22 
23 class Collection(Group):
24     """Nestable Collection of Data objects."""
25 
26     class_name = "Collection"
27 
28     def __iter__(self):
29         self.__n = 0
30         return self
31 
32     def __len__(self):
33         return len(self.item_names)
34 
35     def __next__(self):
36         if self.__n < len(self):
37             out = self.item_names[self.__n]
38             self.__n += 1
39         else:
40             raise StopIteration
41         return out
42 
43     def __repr__(self):
44         return "<WrightTools.Collection '{0}' {1} at {2}>".format(
45             self.natural_name, self.item_names, "::".join([self.filepath, self.name])
46         )
47 
48     def __getitem__(self, key):
49         if isinstance(key, int):
50             key = self.item_names[key]
51         if key == "":
52             return None
53         return super().__getitem__(key)
54 
55     def __setitem__(self, key, value):
56         raise NotImplementedError
57 
58     @property
59     def _leaf(self):
60         return self.natural_name
61 
62     def _print_branch(self, prefix, depth, verbose):
63         for i, name in enumerate(self.item_names):
64             item = self[name]
65             if i + 1 == len(self.item_names):
66                 s = prefix + "└── {0}: {1}".format(i, item._leaf)
67                 p = prefix + "    "
68             else:
69                 s = prefix + "├── {0}: {1}".format(i, item._leaf)
70                 p = prefix + "│   "
71             print(s)
72             if depth > 1 and hasattr(item, "_print_branch"):
73                 item._print_branch(p, depth=depth - 1, verbose=verbose)
74 
75     def create_collection(self, name="collection", position=None, **kwargs):
76         """Create a new child colleciton.
77 
78         Parameters
79         ----------
80         name : string
81             Unique identifier.
82         position : integer (optional)
83             Location to insert. Default is None (append).
84         kwargs
85             Additional arguments to child collection instantiation.
86 
87         Returns
88         -------
89         WrightTools Collection
90             New child.
91         """
92         if name in self.item_names:
93             wt_exceptions.ObjectExistsWarning.warn(name)
94             return self[name]
95         collection = Collection(
96             filepath=self.filepath, parent=self.name, name=name, edit_local=True, **kwargs
97         )
98         if position is not None:
99             self.attrs["item_names"] = np.insert(
100                 self.attrs["item_names"][:-1], position, collection.natural_name.encode()
101             )
102         setattr(self, name, collection)
103         return collection
104 
105     def create_data(self, name="data", position=None, **kwargs):
106         """Create a new child data.
107 
108         Parameters
109         ----------
110         name : string
111             Unique identifier.
112         position : integer (optional)
113             Location to insert. Default is None (append).
114         kwargs
115             Additional arguments to child data instantiation.
116 
117         Returns
118         -------
119         WrightTools Data
120             New child.
121         """
122         if name in self.item_names:
123             wt_exceptions.ObjectExistsWarning.warn(name)
124             return self[name]
125 
126         if name == "":
127             data = None
128             natural_name = "".encode()
129         else:
130             data = wt_data.Data(
131                 filepath=self.filepath, parent=self.name, name=name, edit_local=True, **kwargs
132             )
133             natural_name = data.natural_name.encode()
134         if position is not None:
135             self.attrs["item_names"] = np.insert(
136                 self.attrs["item_names"][:-1], position, natural_name
137             )
138         setattr(self, name, data)
139         return data
140 
141     def index(self):
142         """Index."""
143         raise NotImplementedError
144 
145     def print_tree(self, depth=9, *, verbose=False):
146         """Print a ascii-formatted tree representation of the collection contents.
147 
148         Parameters
149         ----------
150         depth : integer (optional)
151             Number of layers to include in the tree. Default is 9.
152         verbose : boolean (optional)
153             Toggle inclusion of extra information. Default is True.
154         """
155         print("{0} ({1})".format(self.natural_name, self.filepath))
156         self._print_branch("", depth=depth, verbose=verbose)
157 
158     def flush(self):
159         """Ensure contents are written to file."""
160         for name in self.item_names:
161             item = self[name]
162             item.flush()
163         self.file.flush()
164
```
--- 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/collection/_collection.py b/WrightTools/collection/_collection.py
--- a/WrightTools/collection/_collection.py
+++ b/WrightTools/collection/_collection.py
@@ -102,6 +102,18 @@
         setattr(self, name, collection)
         return collection
 
+    def convert(self, units, convert_variables=False, verbose=True):
+        """Convert units of a collection.
+        Parameters
+        ----------
+        units: string
+            Units to convert to.
+        """
+
+        for name in self.item_names:
+            item = self[name]
+            item.convert(units, convert_variables=convert_variables, verbose=verbose)
+
     def create_data(self, name="data", position=None, **kwargs):
         """Create a new child data.

{"golden_diff": "diff --git a/WrightTools/collection/_collection.py b/WrightTools/collection/_collection.py\n--- a/WrightTools/collection/_collection.py\n+++ b/WrightTools/collection/_collection.py\n@@ -102,6 +102,18 @@\n         setattr(self, name, collection)\n         return collection\n \n+    def convert(self, units, convert_variables=False, verbose=True):\n+        \"\"\"Convert units of a collection.\n+        Parameters\n+        ----------\n+        units: string\n+            Units to convert to.\n+        \"\"\"\n+\n+        for name in self.item_names:\n+            item = self[name]\n+            item.convert(units, convert_variables=convert_variables, verbose=verbose)\n+\n     def create_data(self, name=\"data\", position=None, **kwargs):\n         \"\"\"Create a new child data.\n", "issue": "collection.convert\nWould like to support syntax `collection.convert(unit)`.\r\n\r\nWould convert all contained data objects recursively.\n", "before_files": [{"content": "\"\"\"Collection.\"\"\"\n\n\n# --- import --------------------------------------------------------------------------------------\n\n\nimport numpy as np\n\nfrom .. import data as wt_data\nfrom .. import exceptions as wt_exceptions\nfrom .._group import Group\n\n\n# --- define --------------------------------------------------------------------------------------\n\n\n__all__ = [\"Collection\"]\n\n\n# --- classes -------------------------------------------------------------------------------------\n\n\nclass Collection(Group):\n    \"\"\"Nestable Collection of Data objects.\"\"\"\n\n    class_name = \"Collection\"\n\n    def __iter__(self):\n        self.__n = 0\n        return self\n\n    def __len__(self):\n        return len(self.item_names)\n\n    def __next__(self):\n        if self.__n < len(self):\n            out = self.item_names[self.__n]\n            self.__n += 1\n        else:\n            raise StopIteration\n        return out\n\n    def __repr__(self):\n        return \"<WrightTools.Collection '{0}' {1} at {2}>\".format(\n            self.natural_name, self.item_names, \"::\".join([self.filepath, self.name])\n        )\n\n    def __getitem__(self, key):\n        if isinstance(key, int):\n            key = self.item_names[key]\n        if key == \"\":\n            return None\n        return super().__getitem__(key)\n\n    def __setitem__(self, key, value):\n        raise NotImplementedError\n\n    @property\n    def _leaf(self):\n        return self.natural_name\n\n    def _print_branch(self, prefix, depth, verbose):\n        for i, name in enumerate(self.item_names):\n            item = self[name]\n            if i + 1 == len(self.item_names):\n                s = prefix + \"\u2514\u2500\u2500 {0}: {1}\".format(i, item._leaf)\n                p = prefix + \"    \"\n            else:\n                s = prefix + \"\u251c\u2500\u2500 {0}: {1}\".format(i, item._leaf)\n                p = prefix + \"\u2502   \"\n            print(s)\n            if depth > 1 and hasattr(item, \"_print_branch\"):\n                item._print_branch(p, depth=depth - 1, verbose=verbose)\n\n    def create_collection(self, name=\"collection\", position=None, **kwargs):\n        \"\"\"Create a new child colleciton.\n\n        Parameters\n        ----------\n        name : string\n            Unique identifier.\n        position : integer (optional)\n            Location to insert. Default is None (append).\n        kwargs\n            Additional arguments to child collection instantiation.\n\n        Returns\n        -------\n        WrightTools Collection\n            New child.\n        \"\"\"\n        if name in self.item_names:\n            wt_exceptions.ObjectExistsWarning.warn(name)\n            return self[name]\n        collection = Collection(\n            filepath=self.filepath, parent=self.name, name=name, edit_local=True, **kwargs\n        )\n        if position is not None:\n            self.attrs[\"item_names\"] = np.insert(\n                self.attrs[\"item_names\"][:-1], position, collection.natural_name.encode()\n            )\n        setattr(self, name, collection)\n        return collection\n\n    def create_data(self, name=\"data\", position=None, **kwargs):\n        \"\"\"Create a new child data.\n\n        Parameters\n        ----------\n        name : string\n            Unique identifier.\n        position : integer (optional)\n            Location to insert. Default is None (append).\n        kwargs\n            Additional arguments to child data instantiation.\n\n        Returns\n        -------\n        WrightTools Data\n            New child.\n        \"\"\"\n        if name in self.item_names:\n            wt_exceptions.ObjectExistsWarning.warn(name)\n            return self[name]\n\n        if name == \"\":\n            data = None\n            natural_name = \"\".encode()\n        else:\n            data = wt_data.Data(\n                filepath=self.filepath, parent=self.name, name=name, edit_local=True, **kwargs\n            )\n            natural_name = data.natural_name.encode()\n        if position is not None:\n            self.attrs[\"item_names\"] = np.insert(\n                self.attrs[\"item_names\"][:-1], position, natural_name\n            )\n        setattr(self, name, data)\n        return data\n\n    def index(self):\n        \"\"\"Index.\"\"\"\n        raise NotImplementedError\n\n    def print_tree(self, depth=9, *, verbose=False):\n        \"\"\"Print a ascii-formatted tree representation of the collection contents.\n\n        Parameters\n        ----------\n        depth : integer (optional)\n            Number of layers to include in the tree. Default is 9.\n        verbose : boolean (optional)\n            Toggle inclusion of extra information. Default is True.\n        \"\"\"\n        print(\"{0} ({1})\".format(self.natural_name, self.filepath))\n        self._print_branch(\"\", depth=depth, verbose=verbose)\n\n    def flush(self):\n        \"\"\"Ensure contents are written to file.\"\"\"\n        for name in self.item_names:\n            item = self[name]\n            item.flush()\n        self.file.flush()\n", "path": "WrightTools/collection/_collection.py"}], "after_files": [{"content": "\"\"\"Collection.\"\"\"\n\n\n# --- import --------------------------------------------------------------------------------------\n\n\nimport numpy as np\n\nfrom .. import data as wt_data\nfrom .. import exceptions as wt_exceptions\nfrom .._group import Group\n\n\n# --- define --------------------------------------------------------------------------------------\n\n\n__all__ = [\"Collection\"]\n\n\n# --- classes -------------------------------------------------------------------------------------\n\n\nclass Collection(Group):\n    \"\"\"Nestable Collection of Data objects.\"\"\"\n\n    class_name = \"Collection\"\n\n    def __iter__(self):\n        self.__n = 0\n        return self\n\n    def __len__(self):\n        return len(self.item_names)\n\n    def __next__(self):\n        if self.__n < len(self):\n            out = self.item_names[self.__n]\n            self.__n += 1\n        else:\n            raise StopIteration\n        return out\n\n    def __repr__(self):\n        return \"<WrightTools.Collection '{0}' {1} at {2}>\".format(\n            self.natural_name, self.item_names, \"::\".join([self.filepath, self.name])\n        )\n\n    def __getitem__(self, key):\n        if isinstance(key, int):\n            key = self.item_names[key]\n        if key == \"\":\n            return None\n        return super().__getitem__(key)\n\n    def __setitem__(self, key, value):\n        raise NotImplementedError\n\n    @property\n    def _leaf(self):\n        return self.natural_name\n\n    def _print_branch(self, prefix, depth, verbose):\n        for i, name in enumerate(self.item_names):\n            item = self[name]\n            if i + 1 == len(self.item_names):\n                s = prefix + \"\u2514\u2500\u2500 {0}: {1}\".format(i, item._leaf)\n                p = prefix + \"    \"\n            else:\n                s = prefix + \"\u251c\u2500\u2500 {0}: {1}\".format(i, item._leaf)\n                p = prefix + \"\u2502   \"\n            print(s)\n            if depth > 1 and hasattr(item, \"_print_branch\"):\n                item._print_branch(p, depth=depth - 1, verbose=verbose)\n\n    def create_collection(self, name=\"collection\", position=None, **kwargs):\n        \"\"\"Create a new child colleciton.\n\n        Parameters\n        ----------\n        name : string\n            Unique identifier.\n        position : integer (optional)\n            Location to insert. Default is None (append).\n        kwargs\n            Additional arguments to child collection instantiation.\n\n        Returns\n        -------\n        WrightTools Collection\n            New child.\n        \"\"\"\n        if name in self.item_names:\n            wt_exceptions.ObjectExistsWarning.warn(name)\n            return self[name]\n        collection = Collection(\n            filepath=self.filepath, parent=self.name, name=name, edit_local=True, **kwargs\n        )\n        if position is not None:\n            self.attrs[\"item_names\"] = np.insert(\n                self.attrs[\"item_names\"][:-1], position, collection.natural_name.encode()\n            )\n        setattr(self, name, collection)\n        return collection\n\n    def convert(self, units, convert_variables=False, verbose=True):\n        \"\"\"Convert units of a collection.\n        Parameters\n        ----------\n        units: string\n            Units to convert to.\n        \"\"\"\n\n        for name in self.item_names:\n            item = self[name]\n            item.convert(units, convert_variables=convert_variables, verbose=verbose)\n\n    def create_data(self, name=\"data\", position=None, **kwargs):\n        \"\"\"Create a new child data.\n\n        Parameters\n        ----------\n        name : string\n            Unique identifier.\n        position : integer (optional)\n            Location to insert. Default is None (append).\n        kwargs\n            Additional arguments to child data instantiation.\n\n        Returns\n        -------\n        WrightTools Data\n            New child.\n        \"\"\"\n        if name in self.item_names:\n            wt_exceptions.ObjectExistsWarning.warn(name)\n            return self[name]\n\n        if name == \"\":\n            data = None\n            natural_name = \"\".encode()\n        else:\n            data = wt_data.Data(\n                filepath=self.filepath, parent=self.name, name=name, edit_local=True, **kwargs\n            )\n            natural_name = data.natural_name.encode()\n        if position is not None:\n            self.attrs[\"item_names\"] = np.insert(\n                self.attrs[\"item_names\"][:-1], position, natural_name\n            )\n        setattr(self, name, data)\n        return data\n\n    def index(self):\n        \"\"\"Index.\"\"\"\n        raise NotImplementedError\n\n    def print_tree(self, depth=9, *, verbose=False):\n        \"\"\"Print a ascii-formatted tree representation of the collection contents.\n\n        Parameters\n        ----------\n        depth : integer (optional)\n            Number of layers to include in the tree. Default is 9.\n        verbose : boolean (optional)\n            Toggle inclusion of extra information. Default is True.\n        \"\"\"\n        print(\"{0} ({1})\".format(self.natural_name, self.filepath))\n        self._print_branch(\"\", depth=depth, verbose=verbose)\n\n    def flush(self):\n        \"\"\"Ensure contents are written to file.\"\"\"\n        for name in self.item_names:\n            item = self[name]\n            item.flush()\n        self.file.flush()\n", "path": "WrightTools/collection/_collection.py"}]}