We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
AHF answer tests are flaky
We're seeing random failures from the AHF answer tests on some PRs.

See e.g. https://tests.yt-project.org/job/yt_py3_git/414/.



--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `yt/frontends/ahf/data_structures.py`
Content:
```
1 """
2 AHF data structures
3 
4 
5 
6 """
7 
8 #-----------------------------------------------------------------------------
9 # Copyright (c) 2017, yt Development Team.
10 #
11 # Distributed under the terms of the Modified BSD License.
12 #
13 # The full license is in the file COPYING.txt, distributed with this software.
14 #-----------------------------------------------------------------------------
15 
16 import glob
17 import os
18 import stat
19 
20 import numpy as np
21 
22 from yt.data_objects.static_output import \
23     Dataset, \
24     ParticleFile
25 from yt.funcs import \
26     setdefaultattr
27 from yt.geometry.particle_geometry_handler import \
28     ParticleIndex
29 from yt.utilities.cosmology import \
30     Cosmology
31 
32 from .fields import AHFHalosFieldInfo
33 
34 
35 class AHFHalosFile(ParticleFile):
36     def __init__(self, ds, io, filename, file_id):
37         root, _ = os.path.splitext(filename)
38         candidates = glob.glob(root + '*.AHF_halos')
39         if len(candidates) == 1:
40             filename = candidates[0]
41         else:
42             raise ValueError('Too many AHF_halos files.')
43         self.col_names = self._read_column_names(filename)
44         super(AHFHalosFile, self).__init__(ds, io, filename, file_id)
45 
46     def read_data(self, usecols=None):
47         return np.genfromtxt(self.filename, names=self.col_names,
48                              usecols=usecols)
49 
50     def _read_column_names(self, filename):
51         with open(filename) as f:
52             line = f.readline()
53             # Remove leading '#'
54             line = line[1:]
55             names = line.split()
56             # Remove trailing '()'
57             names = [name.split('(')[0] for name in names]
58             return names
59 
60 
61 class AHFHalosDataset(Dataset):
62     _index_class = ParticleIndex
63     _file_class = AHFHalosFile
64     _field_info_class = AHFHalosFieldInfo
65 
66     def __init__(self, filename, dataset_type='ahf',
67                  n_ref=16, over_refine_factor=1,
68                  units_override=None, unit_system='cgs',
69                  hubble_constant=1.0):
70         root, _ = os.path.splitext(filename)
71         self.log_filename = root + '.log'
72         self.hubble_constant = hubble_constant
73 
74         self.n_ref = n_ref
75         self.over_refine_factor = over_refine_factor
76         super(AHFHalosDataset, self).__init__(
77             filename, dataset_type=dataset_type,
78             units_override=units_override, unit_system=unit_system
79         )
80 
81     def _set_code_unit_attributes(self):
82         setdefaultattr(self, 'length_unit', self.quan(1.0, 'kpccm/h'))
83         setdefaultattr(self, 'mass_unit', self.quan(1.0, 'Msun/h'))
84         setdefaultattr(self, 'time_unit', self.quan(1.0, 's'))
85         setdefaultattr(self, 'velocity_unit', self.quan(1.0, 'km/s'))
86 
87     def _parse_parameter_file(self):
88         # Read all parameters.
89         simu = self._read_log_simu()
90         param = self._read_parameter()
91 
92         # Set up general information.
93         self.filename_template = self.parameter_filename
94         self.file_count = 1
95         self.parameters.update(param)
96         self.particle_types = ('halos')
97         self.particle_types_raw = ('halos')
98         self.unique_identifier = \
99             int(os.stat(self.parameter_filename)[stat.ST_CTIME])
100 
101         # Set up geometrical information.
102         self.refine_by = 2
103         self.dimensionality = 3
104         nz = 1 << self.over_refine_factor
105         self.domain_dimensions = np.ones(self.dimensionality, "int32") * nz
106         self.domain_left_edge = np.array([0.0, 0.0, 0.0])
107         # Note that boxsize is in Mpc but particle positions are in kpc.
108         self.domain_right_edge = np.array([simu['boxsize']] * 3) * 1000
109         self.periodicity = (True, True, True)
110 
111         # Set up cosmological information.
112         self.cosmological_simulation = 1
113         self.current_redshift = param['z']
114         self.omega_lambda = simu['lambda0']
115         self.omega_matter = simu['omega0']
116         cosmo = Cosmology(self.hubble_constant,
117                           self.omega_matter, self.omega_lambda)
118         self.current_time = cosmo.hubble_time(param['z']).in_units('s')
119 
120     @classmethod
121     def _is_valid(self, *args, **kwargs):
122         filename = args[0]
123         if not filename.endswith('.parameter'):
124             return False
125         with open(filename, 'r') as f:
126             if f.readlines()[11].startswith('AHF'):
127                 return True
128         return False
129 
130     # Helper methods
131 
132     def _read_log_simu(self):
133         simu = {}
134         with open(self.log_filename) as f:
135             for l in f:
136                 if l.startswith('simu.'):
137                     name, val = l.split(':')
138                     key = name.strip().split('.')[1]
139                     try:
140                         val = float(val)
141                     except:
142                         val = float.fromhex(val)
143                     simu[key] = val
144         return simu
145 
146     def _read_parameter(self):
147         param = {}
148         with open(self.parameter_filename) as f:
149             for l in f:
150                 words = l.split()
151                 if len(words) == 2:
152                     key, val = words
153                     try:
154                         val = float(val)
155                         param[key] = val
156                     except:
157                         pass
158         return param
159
```
--- 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/yt/frontends/ahf/data_structures.py b/yt/frontends/ahf/data_structures.py
--- a/yt/frontends/ahf/data_structures.py
+++ b/yt/frontends/ahf/data_structures.py
@@ -156,3 +156,7 @@
                     except:
                         pass
         return param
+
+    @property
+    def _skip_cache(self):
+        return True

{"golden_diff": "diff --git a/yt/frontends/ahf/data_structures.py b/yt/frontends/ahf/data_structures.py\n--- a/yt/frontends/ahf/data_structures.py\n+++ b/yt/frontends/ahf/data_structures.py\n@@ -156,3 +156,7 @@\n                     except:\n                         pass\n         return param\n+\n+    @property\n+    def _skip_cache(self):\n+        return True\n", "issue": "AHF answer tests are flaky\nWe're seeing random failures from the AHF answer tests on some PRs.\r\n\r\nSee e.g. https://tests.yt-project.org/job/yt_py3_git/414/.\r\n\r\n\n", "before_files": [{"content": "\"\"\"\nAHF data structures\n\n\n\n\"\"\"\n\n#-----------------------------------------------------------------------------\n# Copyright (c) 2017, yt Development Team.\n#\n# Distributed under the terms of the Modified BSD License.\n#\n# The full license is in the file COPYING.txt, distributed with this software.\n#-----------------------------------------------------------------------------\n\nimport glob\nimport os\nimport stat\n\nimport numpy as np\n\nfrom yt.data_objects.static_output import \\\n    Dataset, \\\n    ParticleFile\nfrom yt.funcs import \\\n    setdefaultattr\nfrom yt.geometry.particle_geometry_handler import \\\n    ParticleIndex\nfrom yt.utilities.cosmology import \\\n    Cosmology\n\nfrom .fields import AHFHalosFieldInfo\n\n\nclass AHFHalosFile(ParticleFile):\n    def __init__(self, ds, io, filename, file_id):\n        root, _ = os.path.splitext(filename)\n        candidates = glob.glob(root + '*.AHF_halos')\n        if len(candidates) == 1:\n            filename = candidates[0]\n        else:\n            raise ValueError('Too many AHF_halos files.')\n        self.col_names = self._read_column_names(filename)\n        super(AHFHalosFile, self).__init__(ds, io, filename, file_id)\n\n    def read_data(self, usecols=None):\n        return np.genfromtxt(self.filename, names=self.col_names,\n                             usecols=usecols)\n\n    def _read_column_names(self, filename):\n        with open(filename) as f:\n            line = f.readline()\n            # Remove leading '#'\n            line = line[1:]\n            names = line.split()\n            # Remove trailing '()'\n            names = [name.split('(')[0] for name in names]\n            return names\n\n\nclass AHFHalosDataset(Dataset):\n    _index_class = ParticleIndex\n    _file_class = AHFHalosFile\n    _field_info_class = AHFHalosFieldInfo\n\n    def __init__(self, filename, dataset_type='ahf',\n                 n_ref=16, over_refine_factor=1,\n                 units_override=None, unit_system='cgs',\n                 hubble_constant=1.0):\n        root, _ = os.path.splitext(filename)\n        self.log_filename = root + '.log'\n        self.hubble_constant = hubble_constant\n\n        self.n_ref = n_ref\n        self.over_refine_factor = over_refine_factor\n        super(AHFHalosDataset, self).__init__(\n            filename, dataset_type=dataset_type,\n            units_override=units_override, unit_system=unit_system\n        )\n\n    def _set_code_unit_attributes(self):\n        setdefaultattr(self, 'length_unit', self.quan(1.0, 'kpccm/h'))\n        setdefaultattr(self, 'mass_unit', self.quan(1.0, 'Msun/h'))\n        setdefaultattr(self, 'time_unit', self.quan(1.0, 's'))\n        setdefaultattr(self, 'velocity_unit', self.quan(1.0, 'km/s'))\n\n    def _parse_parameter_file(self):\n        # Read all parameters.\n        simu = self._read_log_simu()\n        param = self._read_parameter()\n\n        # Set up general information.\n        self.filename_template = self.parameter_filename\n        self.file_count = 1\n        self.parameters.update(param)\n        self.particle_types = ('halos')\n        self.particle_types_raw = ('halos')\n        self.unique_identifier = \\\n            int(os.stat(self.parameter_filename)[stat.ST_CTIME])\n\n        # Set up geometrical information.\n        self.refine_by = 2\n        self.dimensionality = 3\n        nz = 1 << self.over_refine_factor\n        self.domain_dimensions = np.ones(self.dimensionality, \"int32\") * nz\n        self.domain_left_edge = np.array([0.0, 0.0, 0.0])\n        # Note that boxsize is in Mpc but particle positions are in kpc.\n        self.domain_right_edge = np.array([simu['boxsize']] * 3) * 1000\n        self.periodicity = (True, True, True)\n\n        # Set up cosmological information.\n        self.cosmological_simulation = 1\n        self.current_redshift = param['z']\n        self.omega_lambda = simu['lambda0']\n        self.omega_matter = simu['omega0']\n        cosmo = Cosmology(self.hubble_constant,\n                          self.omega_matter, self.omega_lambda)\n        self.current_time = cosmo.hubble_time(param['z']).in_units('s')\n\n    @classmethod\n    def _is_valid(self, *args, **kwargs):\n        filename = args[0]\n        if not filename.endswith('.parameter'):\n            return False\n        with open(filename, 'r') as f:\n            if f.readlines()[11].startswith('AHF'):\n                return True\n        return False\n\n    # Helper methods\n\n    def _read_log_simu(self):\n        simu = {}\n        with open(self.log_filename) as f:\n            for l in f:\n                if l.startswith('simu.'):\n                    name, val = l.split(':')\n                    key = name.strip().split('.')[1]\n                    try:\n                        val = float(val)\n                    except:\n                        val = float.fromhex(val)\n                    simu[key] = val\n        return simu\n\n    def _read_parameter(self):\n        param = {}\n        with open(self.parameter_filename) as f:\n            for l in f:\n                words = l.split()\n                if len(words) == 2:\n                    key, val = words\n                    try:\n                        val = float(val)\n                        param[key] = val\n                    except:\n                        pass\n        return param\n", "path": "yt/frontends/ahf/data_structures.py"}], "after_files": [{"content": "\"\"\"\nAHF data structures\n\n\n\n\"\"\"\n\n#-----------------------------------------------------------------------------\n# Copyright (c) 2017, yt Development Team.\n#\n# Distributed under the terms of the Modified BSD License.\n#\n# The full license is in the file COPYING.txt, distributed with this software.\n#-----------------------------------------------------------------------------\n\nimport glob\nimport os\nimport stat\n\nimport numpy as np\n\nfrom yt.data_objects.static_output import \\\n    Dataset, \\\n    ParticleFile\nfrom yt.funcs import \\\n    setdefaultattr\nfrom yt.geometry.particle_geometry_handler import \\\n    ParticleIndex\nfrom yt.utilities.cosmology import \\\n    Cosmology\n\nfrom .fields import AHFHalosFieldInfo\n\n\nclass AHFHalosFile(ParticleFile):\n    def __init__(self, ds, io, filename, file_id):\n        root, _ = os.path.splitext(filename)\n        candidates = glob.glob(root + '*.AHF_halos')\n        if len(candidates) == 1:\n            filename = candidates[0]\n        else:\n            raise ValueError('Too many AHF_halos files.')\n        self.col_names = self._read_column_names(filename)\n        super(AHFHalosFile, self).__init__(ds, io, filename, file_id)\n\n    def read_data(self, usecols=None):\n        return np.genfromtxt(self.filename, names=self.col_names,\n                             usecols=usecols)\n\n    def _read_column_names(self, filename):\n        with open(filename) as f:\n            line = f.readline()\n            # Remove leading '#'\n            line = line[1:]\n            names = line.split()\n            # Remove trailing '()'\n            names = [name.split('(')[0] for name in names]\n            return names\n\n\nclass AHFHalosDataset(Dataset):\n    _index_class = ParticleIndex\n    _file_class = AHFHalosFile\n    _field_info_class = AHFHalosFieldInfo\n\n    def __init__(self, filename, dataset_type='ahf',\n                 n_ref=16, over_refine_factor=1,\n                 units_override=None, unit_system='cgs',\n                 hubble_constant=1.0):\n        root, _ = os.path.splitext(filename)\n        self.log_filename = root + '.log'\n        self.hubble_constant = hubble_constant\n\n        self.n_ref = n_ref\n        self.over_refine_factor = over_refine_factor\n        super(AHFHalosDataset, self).__init__(\n            filename, dataset_type=dataset_type,\n            units_override=units_override, unit_system=unit_system\n        )\n\n    def _set_code_unit_attributes(self):\n        setdefaultattr(self, 'length_unit', self.quan(1.0, 'kpccm/h'))\n        setdefaultattr(self, 'mass_unit', self.quan(1.0, 'Msun/h'))\n        setdefaultattr(self, 'time_unit', self.quan(1.0, 's'))\n        setdefaultattr(self, 'velocity_unit', self.quan(1.0, 'km/s'))\n\n    def _parse_parameter_file(self):\n        # Read all parameters.\n        simu = self._read_log_simu()\n        param = self._read_parameter()\n\n        # Set up general information.\n        self.filename_template = self.parameter_filename\n        self.file_count = 1\n        self.parameters.update(param)\n        self.particle_types = ('halos')\n        self.particle_types_raw = ('halos')\n        self.unique_identifier = \\\n            int(os.stat(self.parameter_filename)[stat.ST_CTIME])\n\n        # Set up geometrical information.\n        self.refine_by = 2\n        self.dimensionality = 3\n        nz = 1 << self.over_refine_factor\n        self.domain_dimensions = np.ones(self.dimensionality, \"int32\") * nz\n        self.domain_left_edge = np.array([0.0, 0.0, 0.0])\n        # Note that boxsize is in Mpc but particle positions are in kpc.\n        self.domain_right_edge = np.array([simu['boxsize']] * 3) * 1000\n        self.periodicity = (True, True, True)\n\n        # Set up cosmological information.\n        self.cosmological_simulation = 1\n        self.current_redshift = param['z']\n        self.omega_lambda = simu['lambda0']\n        self.omega_matter = simu['omega0']\n        cosmo = Cosmology(self.hubble_constant,\n                          self.omega_matter, self.omega_lambda)\n        self.current_time = cosmo.hubble_time(param['z']).in_units('s')\n\n    @classmethod\n    def _is_valid(self, *args, **kwargs):\n        filename = args[0]\n        if not filename.endswith('.parameter'):\n            return False\n        with open(filename, 'r') as f:\n            if f.readlines()[11].startswith('AHF'):\n                return True\n        return False\n\n    # Helper methods\n\n    def _read_log_simu(self):\n        simu = {}\n        with open(self.log_filename) as f:\n            for l in f:\n                if l.startswith('simu.'):\n                    name, val = l.split(':')\n                    key = name.strip().split('.')[1]\n                    try:\n                        val = float(val)\n                    except:\n                        val = float.fromhex(val)\n                    simu[key] = val\n        return simu\n\n    def _read_parameter(self):\n        param = {}\n        with open(self.parameter_filename) as f:\n            for l in f:\n                words = l.split()\n                if len(words) == 2:\n                    key, val = words\n                    try:\n                        val = float(val)\n                        param[key] = val\n                    except:\n                        pass\n        return param\n\n    @property\n    def _skip_cache(self):\n        return True\n", "path": "yt/frontends/ahf/data_structures.py"}]}