prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Need to decode approximant strings in pycbc_condition_strain 
  Currently pycbc_condition_strain does not recognize approximants after reading them from the variable parameters table of an injection hdf. For example, when approximant 'SEOBNRv4' is stored as a variable parameter in an injection hdf, reading the hdf gives back a string b'SEOBNRv4' which is not recognized as being the same thing as 'SEOBNRv4'
  
  Running the pycbc live test contained in my pull request  https://github.com/gwastro/pycbc/pull/3322 causes an error when pycbc_condition_strain gets to Applying Injections
  
  2020-07-24 12:14:04,373 Applying injections
  Traceback (most recent call last):
    File "/home/max.trevor/dev_env/bin/pycbc_condition_strain", line 4, in <module>
      __import__('pkg_resources').run_script('PyCBC===e9f3da', 'pycbc_condition_strain')
    File "/home/max.trevor/dev_env/lib/python3.6/site-packages/pkg_resources/__init__.py", line 667, in run_script
      self.require(requires)[0].run_script(script_name, ns)
    File "/home/max.trevor/dev_env/lib/python3.6/site-packages/pkg_resources/__init__.py", line 1464, in run_script
      exec(code, namespace, namespace)
    File "/home/max.trevor/dev_env/lib/python3.6/site-packages/PyCBC-e9f3da-py3.6-linux-x86_64.egg/EGG-INFO/scripts/pycbc_condition_strain", line 87, in <module>
      precision=args.output_precision)
    File "/home/max.trevor/dev_env/lib/python3.6/site-packages/PyCBC-e9f3da-py3.6-linux-x86_64.egg/pycbc/strain/strain.py", line 392, in from_cli
      inj_filter_rejector=inj_filter_rejector)
    File "/home/max.trevor/dev_env/lib/python3.6/site-packages/PyCBC-e9f3da-py3.6-linux-x86_64.egg/pycbc/inject/inject.py", line 505, in apply
      detector_name, f_lower=f_l, distance_scale=distance_scale)
    File "/home/max.trevor/dev_env/lib/python3.6/site-packages/PyCBC-e9f3da-py3.6-linux-x86_64.egg/pycbc/inject/inject.py", line 557, in make_strain_from_inj_object
      **self.extra_args)
    File "/home/max.trevor/dev_env/lib/python3.6/site-packages/PyCBC-e9f3da-py3.6-linux-x86_64.egg/pycbc/waveform/waveform.py", line 462, in get_td_waveform
      (input_params['approximant']))
  ValueError: Approximant b'SEOBNRv4' not available
  
  
  </issue>
  <code>
  [start of examples/live/generate_injections.py]
  1 #!/usr/bin/env python
  2 
  3 import os
  4 import sys
  5 from pycbc.io import FieldArray
  6 from pycbc.inject import InjectionSet
  7 
  8 
  9 if os.path.exists('./test_inj1.hdf'):
  10     raise OSError("output-file 1 already exists")
  11 
  12 if os.path.exists('./test_inj2.hdf'):
  13     raise OSError("output-file 2 already exists")
  14 
  15 dtype = [('mass1', float), ('mass2', float),
  16          ('spin1z', float), ('spin2z', float),
  17          ('tc', float), ('distance', float)]
  18 
  19 # injection 1
  20 static_params = {'f_lower': 18.0, 'f_ref': 18.0, 'approximant': 'SEOBNRv4',
  21                  'taper': 'start', 'ra': 45.0, 'dec': 45.0,
  22                  'inclination': 0.0, 'coa_phase': 0.0, 'polarization': 0.0}
  23 
  24 samples = FieldArray(1, dtype=dtype)
  25 
  26 # The following 'magic numbers' are intended to match the highest
  27 # mass injection in the template bank
  28 samples['mass1'] = [290.929321]
  29 samples['mass2'] = [3.6755455]
  30 samples['spin1z'] = [0.9934847]
  31 samples['spin2z'] = [0.92713535]
  32 samples['tc'] = [1272790100.1]
  33 samples['distance'] = [301.5]
  34 
  35 InjectionSet.write('test_inj1.hdf', samples, static_args=static_params,
  36                    injtype='cbc', cmd=" ".join(sys.argv))
  37 
  38 # injection 2
  39 static_params['approximant'] = 'SpinTaylorT4'
  40 
  41 samples = FieldArray(1, dtype=dtype)
  42 
  43 # The following 'magic numbers' are intended to match the lowest
  44 # mass injection in the template bank
  45 samples['mass1'] = [1.1331687]
  46 samples['mass2'] = [1.010624]
  47 samples['spin1z'] = [0.029544285]
  48 samples['spin2z'] = [0.020993788]
  49 samples['tc'] = [1272790260.1]
  50 samples['distance'] = [36.0]
  51 
  52 InjectionSet.write('test_inj2.hdf', samples, static_args=static_params,
  53                    injtype='cbc', cmd=" ".join(sys.argv))
  54
  [end of examples/live/generate_injections.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/examples/live/generate_injections.py b/examples/live/generate_injections.py
  --- a/examples/live/generate_injections.py
  +++ b/examples/live/generate_injections.py
  @@ -1,53 +1,30 @@
   #!/usr/bin/env python
   
  -import os
   import sys
   from pycbc.io import FieldArray
   from pycbc.inject import InjectionSet
   
   
  -if os.path.exists('./test_inj1.hdf'):
  -    raise OSError("output-file 1 already exists")
  -
  -if os.path.exists('./test_inj2.hdf'):
  -    raise OSError("output-file 2 already exists")
  -
   dtype = [('mass1', float), ('mass2', float),
            ('spin1z', float), ('spin2z', float),
  -         ('tc', float), ('distance', float)]
  +         ('tc', float), ('distance', float),
  +         ('approximant', 'S32')]
   
  -# injection 1
  -static_params = {'f_lower': 18.0, 'f_ref': 18.0, 'approximant': 'SEOBNRv4',
  +static_params = {'f_lower': 18.0, 'f_ref': 18.0,
                    'taper': 'start', 'ra': 45.0, 'dec': 45.0,
                    'inclination': 0.0, 'coa_phase': 0.0, 'polarization': 0.0}
   
  -samples = FieldArray(1, dtype=dtype)
  +samples = FieldArray(2, dtype=dtype)
   
   # The following 'magic numbers' are intended to match the highest
  -# mass injection in the template bank
  -samples['mass1'] = [290.929321]
  -samples['mass2'] = [3.6755455]
  -samples['spin1z'] = [0.9934847]
  -samples['spin2z'] = [0.92713535]
  -samples['tc'] = [1272790100.1]
  -samples['distance'] = [301.5]
  -
  -InjectionSet.write('test_inj1.hdf', samples, static_args=static_params,
  -                   injtype='cbc', cmd=" ".join(sys.argv))
  -
  -# injection 2
  -static_params['approximant'] = 'SpinTaylorT4'
  -
  -samples = FieldArray(1, dtype=dtype)
  -
  -# The following 'magic numbers' are intended to match the lowest
  -# mass injection in the template bank
  -samples['mass1'] = [1.1331687]
  -samples['mass2'] = [1.010624]
  -samples['spin1z'] = [0.029544285]
  -samples['spin2z'] = [0.020993788]
  -samples['tc'] = [1272790260.1]
  -samples['distance'] = [36.0]
  -
  -InjectionSet.write('test_inj2.hdf', samples, static_args=static_params,
  +# and lowest mass templates in the template bank
  +samples['mass1'] = [290.929321, 1.1331687]
  +samples['mass2'] = [3.6755455, 1.010624]
  +samples['spin1z'] = [0.9934847, 0.029544285]
  +samples['spin2z'] = [0.92713535, 0.020993788]
  +samples['tc'] = [1272790100.1, 1272790260.1]
  +samples['distance'] = [301.5, 36.0]
  +samples['approximant'] = ['SEOBNRv4', 'SpinTaylorT4']
  +
  +InjectionSet.write('injections.hdf', samples, static_args=static_params,
                      injtype='cbc', cmd=" ".join(sys.argv))
  
verification_info: {"golden_diff": "diff --git a/examples/live/generate_injections.py b/examples/live/generate_injections.py\n--- a/examples/live/generate_injections.py\n+++ b/examples/live/generate_injections.py\n@@ -1,53 +1,30 @@\n #!/usr/bin/env python\n \n-import os\n import sys\n from pycbc.io import FieldArray\n from pycbc.inject import InjectionSet\n \n \n-if os.path.exists('./test_inj1.hdf'):\n-    raise OSError(\"output-file 1 already exists\")\n-\n-if os.path.exists('./test_inj2.hdf'):\n-    raise OSError(\"output-file 2 already exists\")\n-\n dtype = [('mass1', float), ('mass2', float),\n          ('spin1z', float), ('spin2z', float),\n-         ('tc', float), ('distance', float)]\n+         ('tc', float), ('distance', float),\n+         ('approximant', 'S32')]\n \n-# injection 1\n-static_params = {'f_lower': 18.0, 'f_ref': 18.0, 'approximant': 'SEOBNRv4',\n+static_params = {'f_lower': 18.0, 'f_ref': 18.0,\n                  'taper': 'start', 'ra': 45.0, 'dec': 45.0,\n                  'inclination': 0.0, 'coa_phase': 0.0, 'polarization': 0.0}\n \n-samples = FieldArray(1, dtype=dtype)\n+samples = FieldArray(2, dtype=dtype)\n \n # The following 'magic numbers' are intended to match the highest\n-# mass injection in the template bank\n-samples['mass1'] = [290.929321]\n-samples['mass2'] = [3.6755455]\n-samples['spin1z'] = [0.9934847]\n-samples['spin2z'] = [0.92713535]\n-samples['tc'] = [1272790100.1]\n-samples['distance'] = [301.5]\n-\n-InjectionSet.write('test_inj1.hdf', samples, static_args=static_params,\n-                   injtype='cbc', cmd=\" \".join(sys.argv))\n-\n-# injection 2\n-static_params['approximant'] = 'SpinTaylorT4'\n-\n-samples = FieldArray(1, dtype=dtype)\n-\n-# The following 'magic numbers' are intended to match the lowest\n-# mass injection in the template bank\n-samples['mass1'] = [1.1331687]\n-samples['mass2'] = [1.010624]\n-samples['spin1z'] = [0.029544285]\n-samples['spin2z'] = [0.020993788]\n-samples['tc'] = [1272790260.1]\n-samples['distance'] = [36.0]\n-\n-InjectionSet.write('test_inj2.hdf', samples, static_args=static_params,\n+# and lowest mass templates in the template bank\n+samples['mass1'] = [290.929321, 1.1331687]\n+samples['mass2'] = [3.6755455, 1.010624]\n+samples['spin1z'] = [0.9934847, 0.029544285]\n+samples['spin2z'] = [0.92713535, 0.020993788]\n+samples['tc'] = [1272790100.1, 1272790260.1]\n+samples['distance'] = [301.5, 36.0]\n+samples['approximant'] = ['SEOBNRv4', 'SpinTaylorT4']\n+\n+InjectionSet.write('injections.hdf', samples, static_args=static_params,\n                    injtype='cbc', cmd=\" \".join(sys.argv))\n", "issue": "Need to decode approximant strings in pycbc_condition_strain \nCurrently pycbc_condition_strain does not recognize approximants after reading them from the variable parameters table of an injection hdf. For example, when approximant 'SEOBNRv4' is stored as a variable parameter in an injection hdf, reading the hdf gives back a string b'SEOBNRv4' which is not recognized as being the same thing as 'SEOBNRv4'\r\n\r\nRunning the pycbc live test contained in my pull request  https://github.com/gwastro/pycbc/pull/3322 causes an error when pycbc_condition_strain gets to Applying Injections\r\n\r\n2020-07-24 12:14:04,373 Applying injections\r\nTraceback (most recent call last):\r\n  File \"/home/max.trevor/dev_env/bin/pycbc_condition_strain\", line 4, in <module>\r\n    __import__('pkg_resources').run_script('PyCBC===e9f3da', 'pycbc_condition_strain')\r\n  File \"/home/max.trevor/dev_env/lib/python3.6/site-packages/pkg_resources/__init__.py\", line 667, in run_script\r\n    self.require(requires)[0].run_script(script_name, ns)\r\n  File \"/home/max.trevor/dev_env/lib/python3.6/site-packages/pkg_resources/__init__.py\", line 1464, in run_script\r\n    exec(code, namespace, namespace)\r\n  File \"/home/max.trevor/dev_env/lib/python3.6/site-packages/PyCBC-e9f3da-py3.6-linux-x86_64.egg/EGG-INFO/scripts/pycbc_condition_strain\", line 87, in <module>\r\n    precision=args.output_precision)\r\n  File \"/home/max.trevor/dev_env/lib/python3.6/site-packages/PyCBC-e9f3da-py3.6-linux-x86_64.egg/pycbc/strain/strain.py\", line 392, in from_cli\r\n    inj_filter_rejector=inj_filter_rejector)\r\n  File \"/home/max.trevor/dev_env/lib/python3.6/site-packages/PyCBC-e9f3da-py3.6-linux-x86_64.egg/pycbc/inject/inject.py\", line 505, in apply\r\n    detector_name, f_lower=f_l, distance_scale=distance_scale)\r\n  File \"/home/max.trevor/dev_env/lib/python3.6/site-packages/PyCBC-e9f3da-py3.6-linux-x86_64.egg/pycbc/inject/inject.py\", line 557, in make_strain_from_inj_object\r\n    **self.extra_args)\r\n  File \"/home/max.trevor/dev_env/lib/python3.6/site-packages/PyCBC-e9f3da-py3.6-linux-x86_64.egg/pycbc/waveform/waveform.py\", line 462, in get_td_waveform\r\n    (input_params['approximant']))\r\nValueError: Approximant b'SEOBNRv4' not available\r\n\n", "before_files": [{"content": "#!/usr/bin/env python\n\nimport os\nimport sys\nfrom pycbc.io import FieldArray\nfrom pycbc.inject import InjectionSet\n\n\nif os.path.exists('./test_inj1.hdf'):\n    raise OSError(\"output-file 1 already exists\")\n\nif os.path.exists('./test_inj2.hdf'):\n    raise OSError(\"output-file 2 already exists\")\n\ndtype = [('mass1', float), ('mass2', float),\n         ('spin1z', float), ('spin2z', float),\n         ('tc', float), ('distance', float)]\n\n# injection 1\nstatic_params = {'f_lower': 18.0, 'f_ref': 18.0, 'approximant': 'SEOBNRv4',\n                 'taper': 'start', 'ra': 45.0, 'dec': 45.0,\n                 'inclination': 0.0, 'coa_phase': 0.0, 'polarization': 0.0}\n\nsamples = FieldArray(1, dtype=dtype)\n\n# The following 'magic numbers' are intended to match the highest\n# mass injection in the template bank\nsamples['mass1'] = [290.929321]\nsamples['mass2'] = [3.6755455]\nsamples['spin1z'] = [0.9934847]\nsamples['spin2z'] = [0.92713535]\nsamples['tc'] = [1272790100.1]\nsamples['distance'] = [301.5]\n\nInjectionSet.write('test_inj1.hdf', samples, static_args=static_params,\n                   injtype='cbc', cmd=\" \".join(sys.argv))\n\n# injection 2\nstatic_params['approximant'] = 'SpinTaylorT4'\n\nsamples = FieldArray(1, dtype=dtype)\n\n# The following 'magic numbers' are intended to match the lowest\n# mass injection in the template bank\nsamples['mass1'] = [1.1331687]\nsamples['mass2'] = [1.010624]\nsamples['spin1z'] = [0.029544285]\nsamples['spin2z'] = [0.020993788]\nsamples['tc'] = [1272790260.1]\nsamples['distance'] = [36.0]\n\nInjectionSet.write('test_inj2.hdf', samples, static_args=static_params,\n                   injtype='cbc', cmd=\" \".join(sys.argv))\n", "path": "examples/live/generate_injections.py"}]}