prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  [bug] print_monitor_cv.py model not iterable
  I've tried `print_monitor_cv.py model.pkl` but I've got
  
  ```
  Traceback (most recent call last):
    File "~/pylearn2/pylearn2/scripts/print_monitor_cv.py", line 84, in <module>
      main(**vars(args))
    File "~/pylearn2/pylearn2/scripts/print_monitor_cv.py", line 38, in main
      for model in list(this_models):
  TypeError: 'MLP' object is not iterable
  ```
  
  so I changed [this part](https://github.com/lisa-lab/pylearn2/blob/master/pylearn2/scripts/print_monitor_cv.py#L38):
  
  ``` python
          this_models = serial.load(filename)
          for model in list(this_models):
              # ...
  ```
  
  to
  
  ``` python
          # ....
          this_models = serial.load(filename)
  
          try:
              this_models = list(this_models)
          except TypeError:
              this_models = [this_models]
  
          for model in this_models:
              # ...
  ```
  
  PR?
  
  
  </issue>
  <code>
  [start of pylearn2/scripts/print_monitor_cv.py]
  1 #!/usr/bin/env python
  2 """
  3 Print (average) channel values for a collection of models, such as that
  4 serialized by TrainCV. Based on print_monitor.py.
  5 
  6 usage: print_monitor_cv.py model.pkl [-a]
  7 """
  8 from __future__ import print_function
  9 
  10 __author__ = "Steven Kearnes"
  11 __copyright__ = "Copyright 2014, Stanford University"
  12 __license__ = "3-clause BSD"
  13 __maintainer__ = "Steven Kearnes"
  14 
  15 import argparse
  16 import numpy as np
  17 
  18 from pylearn2.utils import serial
  19 
  20 
  21 def main(models, all=False):
  22     """
  23     Print (average) final channel values for a collection of models.
  24 
  25     Parameters
  26     ----------
  27     models : list
  28         Filename(s) for models to analyze.
  29     all : bool, optional (default False)
  30         Whether to output values for all models. If False, only averages
  31         and standard deviations across all models are displayed.
  32     """
  33     epochs = []
  34     time = []
  35     values = {}
  36     for filename in np.atleast_1d(models):
  37         this_models = serial.load(filename)
  38         for model in list(this_models):
  39             monitor = model.monitor
  40             channels = monitor.channels
  41             epochs.append(monitor._epochs_seen)
  42             time.append(max(channels[key].time_record[-1] for key in channels))
  43             for key in sorted(channels.keys()):
  44                 if key not in values:
  45                     values[key] = []
  46                 values[key].append(channels[key].val_record[-1])
  47     n_models = len(epochs)
  48     print('number of models: {0}'.format(n_models))
  49     if n_models > 1:
  50         if all:
  51             print('\nepochs seen:\n{0}\n{1} +/- {2}'.format(np.asarray(epochs),
  52                                                             np.mean(epochs),
  53                                                             np.std(epochs)))
  54             print('\ntraining time:\n{0}\n{1} +/- {2}'.format(np.asarray(time),
  55                                                               np.mean(time),
  56                                                               np.std(time)))
  57         else:
  58             print('epochs seen: {0} +/- {1}'.format(np.mean(epochs),
  59                                                     np.std(epochs)))
  60             print('training time: {0} +/- {1}'.format(np.mean(time),
  61                                                       np.std(time)))
  62         for key in sorted(values.keys()):
  63             if all:
  64                 print('\n{0}:\n{1}\n{2} +/- {3}'.format(
  65                     key, np.asarray(values[key]),
  66                     np.mean(values[key]), np.std(values[key])))
  67             else:
  68                 print('{0}: {1} +/- {2}'.format(key, np.mean(values[key]),
  69                                                 np.std(values[key])))
  70     else:
  71         print('epochs seen: {0}'.format(epochs[0]))
  72         print('training time: {0}'.format(time[0]))
  73         for key in sorted(values.keys()):
  74             print('{0}: {1}'.format(key, values[key][0]))
  75 
  76 if __name__ == '__main__':
  77     parser = argparse.ArgumentParser()
  78     parser.add_argument('models', nargs='+',
  79                         help='Model or models to analyze.')
  80     parser.add_argument('-a', '--all', action='store_true',
  81                         help='Print values for all models instead of ' +
  82                              'averages.')
  83     args = parser.parse_args()
  84     main(**vars(args))
  85
  [end of pylearn2/scripts/print_monitor_cv.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/pylearn2/scripts/print_monitor_cv.py b/pylearn2/scripts/print_monitor_cv.py
  --- a/pylearn2/scripts/print_monitor_cv.py
  +++ b/pylearn2/scripts/print_monitor_cv.py
  @@ -13,6 +13,7 @@
   __maintainer__ = "Steven Kearnes"
   
   import argparse
  +from collections import Iterable
   import numpy as np
   
   from pylearn2.utils import serial
  @@ -35,6 +36,8 @@
       values = {}
       for filename in np.atleast_1d(models):
           this_models = serial.load(filename)
  +        if not isinstance(this_models, Iterable):
  +            this_models = [this_models]
           for model in list(this_models):
               monitor = model.monitor
               channels = monitor.channels
  
verification_info: {"golden_diff": "diff --git a/pylearn2/scripts/print_monitor_cv.py b/pylearn2/scripts/print_monitor_cv.py\n--- a/pylearn2/scripts/print_monitor_cv.py\n+++ b/pylearn2/scripts/print_monitor_cv.py\n@@ -13,6 +13,7 @@\n __maintainer__ = \"Steven Kearnes\"\n \n import argparse\n+from collections import Iterable\n import numpy as np\n \n from pylearn2.utils import serial\n@@ -35,6 +36,8 @@\n     values = {}\n     for filename in np.atleast_1d(models):\n         this_models = serial.load(filename)\n+        if not isinstance(this_models, Iterable):\n+            this_models = [this_models]\n         for model in list(this_models):\n             monitor = model.monitor\n             channels = monitor.channels\n", "issue": "[bug] print_monitor_cv.py model not iterable\nI've tried `print_monitor_cv.py model.pkl` but I've got\n\n```\nTraceback (most recent call last):\n  File \"~/pylearn2/pylearn2/scripts/print_monitor_cv.py\", line 84, in <module>\n    main(**vars(args))\n  File \"~/pylearn2/pylearn2/scripts/print_monitor_cv.py\", line 38, in main\n    for model in list(this_models):\nTypeError: 'MLP' object is not iterable\n```\n\nso I changed [this part](https://github.com/lisa-lab/pylearn2/blob/master/pylearn2/scripts/print_monitor_cv.py#L38):\n\n``` python\n        this_models = serial.load(filename)\n        for model in list(this_models):\n            # ...\n```\n\nto\n\n``` python\n        # ....\n        this_models = serial.load(filename)\n\n        try:\n            this_models = list(this_models)\n        except TypeError:\n            this_models = [this_models]\n\n        for model in this_models:\n            # ...\n```\n\nPR?\n\n", "before_files": [{"content": "#!/usr/bin/env python\n\"\"\"\nPrint (average) channel values for a collection of models, such as that\nserialized by TrainCV. Based on print_monitor.py.\n\nusage: print_monitor_cv.py model.pkl [-a]\n\"\"\"\nfrom __future__ import print_function\n\n__author__ = \"Steven Kearnes\"\n__copyright__ = \"Copyright 2014, Stanford University\"\n__license__ = \"3-clause BSD\"\n__maintainer__ = \"Steven Kearnes\"\n\nimport argparse\nimport numpy as np\n\nfrom pylearn2.utils import serial\n\n\ndef main(models, all=False):\n    \"\"\"\n    Print (average) final channel values for a collection of models.\n\n    Parameters\n    ----------\n    models : list\n        Filename(s) for models to analyze.\n    all : bool, optional (default False)\n        Whether to output values for all models. If False, only averages\n        and standard deviations across all models are displayed.\n    \"\"\"\n    epochs = []\n    time = []\n    values = {}\n    for filename in np.atleast_1d(models):\n        this_models = serial.load(filename)\n        for model in list(this_models):\n            monitor = model.monitor\n            channels = monitor.channels\n            epochs.append(monitor._epochs_seen)\n            time.append(max(channels[key].time_record[-1] for key in channels))\n            for key in sorted(channels.keys()):\n                if key not in values:\n                    values[key] = []\n                values[key].append(channels[key].val_record[-1])\n    n_models = len(epochs)\n    print('number of models: {0}'.format(n_models))\n    if n_models > 1:\n        if all:\n            print('\\nepochs seen:\\n{0}\\n{1} +/- {2}'.format(np.asarray(epochs),\n                                                            np.mean(epochs),\n                                                            np.std(epochs)))\n            print('\\ntraining time:\\n{0}\\n{1} +/- {2}'.format(np.asarray(time),\n                                                              np.mean(time),\n                                                              np.std(time)))\n        else:\n            print('epochs seen: {0} +/- {1}'.format(np.mean(epochs),\n                                                    np.std(epochs)))\n            print('training time: {0} +/- {1}'.format(np.mean(time),\n                                                      np.std(time)))\n        for key in sorted(values.keys()):\n            if all:\n                print('\\n{0}:\\n{1}\\n{2} +/- {3}'.format(\n                    key, np.asarray(values[key]),\n                    np.mean(values[key]), np.std(values[key])))\n            else:\n                print('{0}: {1} +/- {2}'.format(key, np.mean(values[key]),\n                                                np.std(values[key])))\n    else:\n        print('epochs seen: {0}'.format(epochs[0]))\n        print('training time: {0}'.format(time[0]))\n        for key in sorted(values.keys()):\n            print('{0}: {1}'.format(key, values[key][0]))\n\nif __name__ == '__main__':\n    parser = argparse.ArgumentParser()\n    parser.add_argument('models', nargs='+',\n                        help='Model or models to analyze.')\n    parser.add_argument('-a', '--all', action='store_true',\n                        help='Print values for all models instead of ' +\n                             'averages.')\n    args = parser.parse_args()\n    main(**vars(args))\n", "path": "pylearn2/scripts/print_monitor_cv.py"}]}