We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
collection.keys returns data objects
should return names, but get objects

--- 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 os
8 import shutil
9 
10 import numpy as np
11 
12 import h5py
13 
14 from .. import data as wt_data
15 from .._base import Group
16 
17 
18 # --- define --------------------------------------------------------------------------------------
19 
20 
21 __all__ = ['Collection']
22 
23 
24 # --- classes -------------------------------------------------------------------------------------
25 
26 
27 class Collection(Group):
28     """Nestable Collection of Data objects."""
29     class_name = 'Collection'
30 
31     def __iter__(self):
32         self.__n = 0
33         return self
34 
35     def __len__(self):
36         return len(self.item_names)
37 
38     def __next__(self):
39         if self.__n < len(self):
40             out = self[self.__n]
41             self.__n += 1
42         else:
43             raise StopIteration
44         return out
45 
46     def __repr__(self):
47         return '<WrightTools.Collection \'{0}\' {1} at {2}>'.format(self.natural_name,
48                                                                     self.item_names,
49                                                                     '::'.join([self.filepath,
50                                                                                self.name]))
51 
52     def __getitem__(self, key):
53         if isinstance(key, int):
54             key = self.item_names[key]
55         out = h5py.Group.__getitem__(self, key)
56         if 'class' in out.attrs.keys():
57             if out.attrs['class'] == 'Data':
58                 return wt_data.Data(filepath=self.filepath, parent=self.name, name=key,
59                                     edit_local=True)
60             elif out.attrs['class'] == 'Collection':
61                 return Collection(filepath=self.filepath, parent=self.name, name=key,
62                                   edit_local=True)
63             else:
64                 return Group(filepath=self.filepath, parent=self.name, name=key,
65                               edit_local=True)
66         else:
67             return out
68 
69     def __setitem__(self, key, value):
70         raise NotImplementedError
71 
72     @property
73     def item_names(self):
74         if 'item_names' not in self.attrs.keys():
75             self.attrs['item_names'] = np.array([], dtype='S')
76         return [s.decode() for s in self.attrs['item_names']]
77 
78     def create_collection(self, name='collection', position=None, **kwargs):
79         collection = Collection(filepath=self.filepath, parent=self.name, name=name,
80                                 edit_local=True, **kwargs)
81         if position is None:
82             self._items.append(collection)
83             self.attrs['item_names'] = np.append(self.attrs['item_names'],
84                                                  collection.natural_name.encode())
85         else:
86             self._items.insert(position, collection)
87             self.attrs['item_names'] = np.insert(self.attrs['item_names'], position,
88                                                  collection.natural_name.encode())
89         setattr(self, name, collection)
90         return collection
91 
92     def create_data(self, name='data', position=None, **kwargs):
93         data = wt_data.Data(filepath=self.filepath, parent=self.name, name=name, edit_local=True,
94                             **kwargs)
95         if position is None:
96             self._items.append(data)
97             self.attrs['item_names'] = np.append(self.attrs['item_names'],
98                                                  data.natural_name.encode())
99         else:
100             self._items.insert(position, data)
101             self.attrs['item_names'] = np.insert(self.attrs['item_names'], position,
102                                                  data.natural_name.encode())
103         setattr(self, name, data)
104         return data
105 
106     def index(self):
107         raise NotImplementedError
108 
109     def flush(self):
110         for item in self._items:
111             item.flush()
112         self.file.flush()
113 
114     def save(self, filepath=None, verbose=True):
115         # TODO: documentation
116         self.flush()  # ensure all changes are written to file
117         if filepath is None:
118             filepath = os.path.join(os.getcwd(), self.natural_name + '.wt5')
119         elif len(os.path.basename(filepath).split('.')) == 1:
120             filepath += '.wt5'
121         filepath = os.path.expanduser(filepath)
122         shutil.copyfile(src=self.filepath, dst=filepath)
123         if verbose:
124             print('file saved at', filepath)
125         return filepath
126
```
--- 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
@@ -37,7 +37,7 @@
 
     def __next__(self):
         if self.__n < len(self):
-            out = self[self.__n]
+            out = self.item_names[self.__n]
             self.__n += 1
         else:
             raise StopIteration

{"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@@ -37,7 +37,7 @@\n \n     def __next__(self):\n         if self.__n < len(self):\n-            out = self[self.__n]\n+            out = self.item_names[self.__n]\n             self.__n += 1\n         else:\n             raise StopIteration\n", "issue": "collection.keys returns data objects\nshould return names, but get objects\n", "before_files": [{"content": "\"\"\"Collection.\"\"\"\n\n\n# --- import --------------------------------------------------------------------------------------\n\n\nimport os\nimport shutil\n\nimport numpy as np\n\nimport h5py\n\nfrom .. import data as wt_data\nfrom .._base 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    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[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(self.natural_name,\n                                                                    self.item_names,\n                                                                    '::'.join([self.filepath,\n                                                                               self.name]))\n\n    def __getitem__(self, key):\n        if isinstance(key, int):\n            key = self.item_names[key]\n        out = h5py.Group.__getitem__(self, key)\n        if 'class' in out.attrs.keys():\n            if out.attrs['class'] == 'Data':\n                return wt_data.Data(filepath=self.filepath, parent=self.name, name=key,\n                                    edit_local=True)\n            elif out.attrs['class'] == 'Collection':\n                return Collection(filepath=self.filepath, parent=self.name, name=key,\n                                  edit_local=True)\n            else:\n                return Group(filepath=self.filepath, parent=self.name, name=key,\n                              edit_local=True)\n        else:\n            return out\n\n    def __setitem__(self, key, value):\n        raise NotImplementedError\n\n    @property\n    def item_names(self):\n        if 'item_names' not in self.attrs.keys():\n            self.attrs['item_names'] = np.array([], dtype='S')\n        return [s.decode() for s in self.attrs['item_names']]\n\n    def create_collection(self, name='collection', position=None, **kwargs):\n        collection = Collection(filepath=self.filepath, parent=self.name, name=name,\n                                edit_local=True, **kwargs)\n        if position is None:\n            self._items.append(collection)\n            self.attrs['item_names'] = np.append(self.attrs['item_names'],\n                                                 collection.natural_name.encode())\n        else:\n            self._items.insert(position, collection)\n            self.attrs['item_names'] = np.insert(self.attrs['item_names'], position,\n                                                 collection.natural_name.encode())\n        setattr(self, name, collection)\n        return collection\n\n    def create_data(self, name='data', position=None, **kwargs):\n        data = wt_data.Data(filepath=self.filepath, parent=self.name, name=name, edit_local=True,\n                            **kwargs)\n        if position is None:\n            self._items.append(data)\n            self.attrs['item_names'] = np.append(self.attrs['item_names'],\n                                                 data.natural_name.encode())\n        else:\n            self._items.insert(position, data)\n            self.attrs['item_names'] = np.insert(self.attrs['item_names'], position,\n                                                 data.natural_name.encode())\n        setattr(self, name, data)\n        return data\n\n    def index(self):\n        raise NotImplementedError\n\n    def flush(self):\n        for item in self._items:\n            item.flush()\n        self.file.flush()\n\n    def save(self, filepath=None, verbose=True):\n        # TODO: documentation\n        self.flush()  # ensure all changes are written to file\n        if filepath is None:\n            filepath = os.path.join(os.getcwd(), self.natural_name + '.wt5')\n        elif len(os.path.basename(filepath).split('.')) == 1:\n            filepath += '.wt5'\n        filepath = os.path.expanduser(filepath)\n        shutil.copyfile(src=self.filepath, dst=filepath)\n        if verbose:\n            print('file saved at', filepath)\n        return filepath\n", "path": "WrightTools/collection/_collection.py"}], "after_files": [{"content": "\"\"\"Collection.\"\"\"\n\n\n# --- import --------------------------------------------------------------------------------------\n\n\nimport os\nimport shutil\n\nimport numpy as np\n\nimport h5py\n\nfrom .. import data as wt_data\nfrom .._base 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    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(self.natural_name,\n                                                                    self.item_names,\n                                                                    '::'.join([self.filepath,\n                                                                               self.name]))\n\n    def __getitem__(self, key):\n        if isinstance(key, int):\n            key = self.item_names[key]\n        out = h5py.Group.__getitem__(self, key)\n        if 'class' in out.attrs.keys():\n            if out.attrs['class'] == 'Data':\n                return wt_data.Data(filepath=self.filepath, parent=self.name, name=key,\n                                    edit_local=True)\n            elif out.attrs['class'] == 'Collection':\n                return Collection(filepath=self.filepath, parent=self.name, name=key,\n                                  edit_local=True)\n            else:\n                return Group(filepath=self.filepath, parent=self.name, name=key,\n                              edit_local=True)\n        else:\n            return out\n\n    def __setitem__(self, key, value):\n        raise NotImplementedError\n\n    @property\n    def item_names(self):\n        if 'item_names' not in self.attrs.keys():\n            self.attrs['item_names'] = np.array([], dtype='S')\n        return [s.decode() for s in self.attrs['item_names']]\n\n    def create_collection(self, name='collection', position=None, **kwargs):\n        collection = Collection(filepath=self.filepath, parent=self.name, name=name,\n                                edit_local=True, **kwargs)\n        if position is None:\n            self._items.append(collection)\n            self.attrs['item_names'] = np.append(self.attrs['item_names'],\n                                                 collection.natural_name.encode())\n        else:\n            self._items.insert(position, collection)\n            self.attrs['item_names'] = np.insert(self.attrs['item_names'], position,\n                                                 collection.natural_name.encode())\n        setattr(self, name, collection)\n        return collection\n\n    def create_data(self, name='data', position=None, **kwargs):\n        data = wt_data.Data(filepath=self.filepath, parent=self.name, name=name, edit_local=True,\n                            **kwargs)\n        if position is None:\n            self._items.append(data)\n            self.attrs['item_names'] = np.append(self.attrs['item_names'],\n                                                 data.natural_name.encode())\n        else:\n            self._items.insert(position, data)\n            self.attrs['item_names'] = np.insert(self.attrs['item_names'], position,\n                                                 data.natural_name.encode())\n        setattr(self, name, data)\n        return data\n\n    def index(self):\n        raise NotImplementedError\n\n    def flush(self):\n        for item in self._items:\n            item.flush()\n        self.file.flush()\n\n    def save(self, filepath=None, verbose=True):\n        # TODO: documentation\n        self.flush()  # ensure all changes are written to file\n        if filepath is None:\n            filepath = os.path.join(os.getcwd(), self.natural_name + '.wt5')\n        elif len(os.path.basename(filepath).split('.')) == 1:\n            filepath += '.wt5'\n        filepath = os.path.expanduser(filepath)\n        shutil.copyfile(src=self.filepath, dst=filepath)\n        if verbose:\n            print('file saved at', filepath)\n        return filepath\n", "path": "WrightTools/collection/_collection.py"}]}