prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Hyperoptable parameter type: CategoricalParameter is not returning correctly.
  ## Describe your environment
  
    * Operating system: MacOS 11.2.3 (20D91)
    * Python Version: using the version shiped freqtradeorg/freqtrade:stable (Image ID 73a48178c043)
    * CCXT version: using the version shiped freqtradeorg/freqtrade:stable (Image ID 73a48178c043)
    * Freqtrade Version: freqtrade 2021.4
    
  Note: All issues other than enhancement requests will be closed without further comment if the above template is deleted or not filled out.
  
  ## Describe the problem:
  
  Hi! It appears the Hyperoptable parameter type: `CategoricalParameter` is not returning correctly.
  
  If I run the example as per the Freqtrade Docs [here](https://www.freqtrade.io/en/stable/hyperopt/#hyperoptable-parameters), namely setting a  `CategoricalParameter` like so:
  
  ```
  buy_rsi_enabled = CategoricalParameter([True, False]),
  ```
  
  ...then when running the Hyperopt tool there is an error in the `populate_buy_trend` as below:
  
  ```
  if self.buy_adx_enabled.value:
  AttributeError: 'tuple' object has no attribute 'value'
  ```
  
  It would appear that the `CategoricalParameter` is not actually returning one of the categories (even a default) but instead returning a Python Tuple.
  
  ### Steps to reproduce:
  
    1. Follow the example in the [Docs](https://www.freqtrade.io/en/stable/hyperopt/#hyperoptable-parameters)
    
  ### Observed Results:
  
    * What happened? There was an AttributeError: 'tuple' object has no attribute 'value'. 
    * What did you expect to happen? The 'value' property to exist and be set to either True or False
  
  ### Relevant code exceptions or logs
  
  Note: Please copy/paste text of the messages, no screenshots of logs please.
  
    ```
  2021-05-02 09:48:02,421 - freqtrade - ERROR - Fatal exception!
  joblib.externals.loky.process_executor._RemoteTraceback:
  """
  Traceback (most recent call last):
    File "/home/ftuser/.local/lib/python3.9/site-packages/joblib/externals/loky/process_executor.py", line 431, in _process_worker
      r = call_item()
    File "/home/ftuser/.local/lib/python3.9/site-packages/joblib/externals/loky/process_executor.py", line 285, in __call__
      return self.fn(*self.args, **self.kwargs)
    File "/home/ftuser/.local/lib/python3.9/site-packages/joblib/_parallel_backends.py", line 595, in __call__
      return self.func(*args, **kwargs)
    File "/home/ftuser/.local/lib/python3.9/site-packages/joblib/parallel.py", line 262, in __call__
      return [func(*args, **kwargs)
    File "/home/ftuser/.local/lib/python3.9/site-packages/joblib/parallel.py", line 262, in <listcomp>
      return [func(*args, **kwargs)
    File "/home/ftuser/.local/lib/python3.9/site-packages/joblib/externals/loky/cloudpickle_wrapper.py", line 38, in __call__
      return self._obj(*args, **kwargs)
    File "/freqtrade/freqtrade/optimize/hyperopt.py", line 288, in generate_optimizer
      backtesting_results = self.backtesting.backtest(
    File "/freqtrade/freqtrade/optimize/backtesting.py", line 352, in backtest
      data: Dict = self._get_ohlcv_as_lists(processed)
    File "/freqtrade/freqtrade/optimize/backtesting.py", line 196, in _get_ohlcv_as_lists
      self.strategy.advise_buy(pair_data, {'pair': pair}), {'pair': pair})[headers].copy()
    File "/freqtrade/freqtrade/optimize/hyperopt_auto.py", line 31, in populate_buy_trend
      return self.strategy.populate_buy_trend(dataframe, metadata)
    File "/freqtrade/user_data/strategies/Strategy004.py", line 149, in populate_buy_trend
      if self.buy_adx_enabled.value:
  AttributeError: 'tuple' object has no attribute 'value'
    ```
  
  
  </issue>
  <code>
  [start of freqtrade/__init__.py]
  1 """ Freqtrade bot """
  2 __version__ = 'develop'
  3 
  4 if __version__ == 'develop':
  5 
  6     try:
  7         import subprocess
  8 
  9         __version__ = 'develop-' + subprocess.check_output(
  10             ['git', 'log', '--format="%h"', '-n 1'],
  11             stderr=subprocess.DEVNULL).decode("utf-8").rstrip().strip('"')
  12 
  13         # from datetime import datetime
  14         # last_release = subprocess.check_output(
  15         #     ['git', 'tag']
  16         # ).decode('utf-8').split()[-1].split(".")
  17         # # Releases are in the format "2020.1" - we increment the latest version for dev.
  18         # prefix = f"{last_release[0]}.{int(last_release[1]) + 1}"
  19         # dev_version = int(datetime.now().timestamp() // 1000)
  20         # __version__ = f"{prefix}.dev{dev_version}"
  21 
  22         #  subprocess.check_output(
  23         #     ['git', 'log', '--format="%h"', '-n 1'],
  24         #     stderr=subprocess.DEVNULL).decode("utf-8").rstrip().strip('"')
  25     except Exception:
  26         # git not available, ignore
  27         try:
  28             # Try Fallback to freqtrade_commit file (created by CI while building docker image)
  29             from pathlib import Path
  30             versionfile = Path('./freqtrade_commit')
  31             if versionfile.is_file():
  32                 __version__ = f"docker-{versionfile.read_text()[:8]}"
  33         except Exception:
  34             pass
  35
  [end of freqtrade/__init__.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/freqtrade/__init__.py b/freqtrade/__init__.py
  --- a/freqtrade/__init__.py
  +++ b/freqtrade/__init__.py
  @@ -1,5 +1,5 @@
   """ Freqtrade bot """
  -__version__ = 'develop'
  +__version__ = '2021.8'
   
   if __version__ == 'develop':
  
verification_info: {"golden_diff": "diff --git a/freqtrade/__init__.py b/freqtrade/__init__.py\n--- a/freqtrade/__init__.py\n+++ b/freqtrade/__init__.py\n@@ -1,5 +1,5 @@\n \"\"\" Freqtrade bot \"\"\"\n-__version__ = 'develop'\n+__version__ = '2021.8'\n \n if __version__ == 'develop':\n", "issue": "Hyperoptable parameter type: CategoricalParameter is not returning correctly.\n## Describe your environment\r\n\r\n  * Operating system: MacOS 11.2.3 (20D91)\r\n  * Python Version: using the version shiped freqtradeorg/freqtrade:stable (Image ID 73a48178c043)\r\n  * CCXT version: using the version shiped freqtradeorg/freqtrade:stable (Image ID 73a48178c043)\r\n  * Freqtrade Version: freqtrade 2021.4\r\n  \r\nNote: All issues other than enhancement requests will be closed without further comment if the above template is deleted or not filled out.\r\n\r\n## Describe the problem:\r\n\r\nHi! It appears the Hyperoptable parameter type: `CategoricalParameter` is not returning correctly.\r\n\r\nIf I run the example as per the Freqtrade Docs [here](https://www.freqtrade.io/en/stable/hyperopt/#hyperoptable-parameters), namely setting a  `CategoricalParameter` like so:\r\n\r\n```\r\nbuy_rsi_enabled = CategoricalParameter([True, False]),\r\n```\r\n\r\n...then when running the Hyperopt tool there is an error in the `populate_buy_trend` as below:\r\n\r\n```\r\nif self.buy_adx_enabled.value:\r\nAttributeError: 'tuple' object has no attribute 'value'\r\n```\r\n\r\nIt would appear that the `CategoricalParameter` is not actually returning one of the categories (even a default) but instead returning a Python Tuple.\r\n\r\n### Steps to reproduce:\r\n\r\n  1. Follow the example in the [Docs](https://www.freqtrade.io/en/stable/hyperopt/#hyperoptable-parameters)\r\n  \r\n### Observed Results:\r\n\r\n  * What happened? There was an AttributeError: 'tuple' object has no attribute 'value'. \r\n  * What did you expect to happen? The 'value' property to exist and be set to either True or False\r\n\r\n### Relevant code exceptions or logs\r\n\r\nNote: Please copy/paste text of the messages, no screenshots of logs please.\r\n\r\n  ```\r\n2021-05-02 09:48:02,421 - freqtrade - ERROR - Fatal exception!\r\njoblib.externals.loky.process_executor._RemoteTraceback:\r\n\"\"\"\r\nTraceback (most recent call last):\r\n  File \"/home/ftuser/.local/lib/python3.9/site-packages/joblib/externals/loky/process_executor.py\", line 431, in _process_worker\r\n    r = call_item()\r\n  File \"/home/ftuser/.local/lib/python3.9/site-packages/joblib/externals/loky/process_executor.py\", line 285, in __call__\r\n    return self.fn(*self.args, **self.kwargs)\r\n  File \"/home/ftuser/.local/lib/python3.9/site-packages/joblib/_parallel_backends.py\", line 595, in __call__\r\n    return self.func(*args, **kwargs)\r\n  File \"/home/ftuser/.local/lib/python3.9/site-packages/joblib/parallel.py\", line 262, in __call__\r\n    return [func(*args, **kwargs)\r\n  File \"/home/ftuser/.local/lib/python3.9/site-packages/joblib/parallel.py\", line 262, in <listcomp>\r\n    return [func(*args, **kwargs)\r\n  File \"/home/ftuser/.local/lib/python3.9/site-packages/joblib/externals/loky/cloudpickle_wrapper.py\", line 38, in __call__\r\n    return self._obj(*args, **kwargs)\r\n  File \"/freqtrade/freqtrade/optimize/hyperopt.py\", line 288, in generate_optimizer\r\n    backtesting_results = self.backtesting.backtest(\r\n  File \"/freqtrade/freqtrade/optimize/backtesting.py\", line 352, in backtest\r\n    data: Dict = self._get_ohlcv_as_lists(processed)\r\n  File \"/freqtrade/freqtrade/optimize/backtesting.py\", line 196, in _get_ohlcv_as_lists\r\n    self.strategy.advise_buy(pair_data, {'pair': pair}), {'pair': pair})[headers].copy()\r\n  File \"/freqtrade/freqtrade/optimize/hyperopt_auto.py\", line 31, in populate_buy_trend\r\n    return self.strategy.populate_buy_trend(dataframe, metadata)\r\n  File \"/freqtrade/user_data/strategies/Strategy004.py\", line 149, in populate_buy_trend\r\n    if self.buy_adx_enabled.value:\r\nAttributeError: 'tuple' object has no attribute 'value'\r\n  ```\r\n\n", "before_files": [{"content": "\"\"\" Freqtrade bot \"\"\"\n__version__ = 'develop'\n\nif __version__ == 'develop':\n\n    try:\n        import subprocess\n\n        __version__ = 'develop-' + subprocess.check_output(\n            ['git', 'log', '--format=\"%h\"', '-n 1'],\n            stderr=subprocess.DEVNULL).decode(\"utf-8\").rstrip().strip('\"')\n\n        # from datetime import datetime\n        # last_release = subprocess.check_output(\n        #     ['git', 'tag']\n        # ).decode('utf-8').split()[-1].split(\".\")\n        # # Releases are in the format \"2020.1\" - we increment the latest version for dev.\n        # prefix = f\"{last_release[0]}.{int(last_release[1]) + 1}\"\n        # dev_version = int(datetime.now().timestamp() // 1000)\n        # __version__ = f\"{prefix}.dev{dev_version}\"\n\n        #  subprocess.check_output(\n        #     ['git', 'log', '--format=\"%h\"', '-n 1'],\n        #     stderr=subprocess.DEVNULL).decode(\"utf-8\").rstrip().strip('\"')\n    except Exception:\n        # git not available, ignore\n        try:\n            # Try Fallback to freqtrade_commit file (created by CI while building docker image)\n            from pathlib import Path\n            versionfile = Path('./freqtrade_commit')\n            if versionfile.is_file():\n                __version__ = f\"docker-{versionfile.read_text()[:8]}\"\n        except Exception:\n            pass\n", "path": "freqtrade/__init__.py"}]}