prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  check_paradigm should check for invalid keys in passed dict
  Using the old `nipy` user logic, I passed `amplitude=somethx` instead of `modulation=somethx` in the `make_design_matrix`. I didn't crash but the values where ignored (e.g Error: unknown param, etc.). A default value of 1 was forced...
  
  
  </issue>
  <code>
  [start of nilearn/glm/first_level/experimental_paradigm.py]
  1 """
  2 An experimental protocol is handled as a pandas DataFrame
  3 that includes an 'onset' field.
  4 
  5 This yields the onset time of the events in the experimental paradigm.
  6 It can also contain:
  7 
  8     * a 'trial_type' field that yields the condition identifier.
  9     * a 'duration' field that yields event duration (for so-called block
  10         paradigms).
  11     * a 'modulation' field that associated a scalar value to each event.
  12 
  13 Author: Bertrand Thirion, 2015
  14 
  15 """
  16 import warnings
  17 
  18 import numpy as np
  19 
  20 
  21 def check_events(events):
  22     """Test that the events data describes a valid experimental paradigm
  23 
  24     It is valid if the events data  has an 'onset' key.
  25 
  26     Parameters
  27     ----------
  28     events : pandas DataFrame
  29         Events data that describes a functional experimental paradigm.
  30 
  31     Returns
  32     -------
  33     trial_type : array of shape (n_events,), dtype='s'
  34         Per-event experimental conditions identifier.
  35         Defaults to np.repeat('dummy', len(onsets)).
  36 
  37     onset : array of shape (n_events,), dtype='f'
  38         Per-event onset time (in seconds)
  39 
  40     duration : array of shape (n_events,), dtype='f'
  41         Per-event durantion, (in seconds)
  42         defaults to zeros(n_events) when no duration is provided
  43 
  44     modulation : array of shape (n_events,), dtype='f'
  45         Per-event modulation, (in seconds)
  46         defaults to ones(n_events) when no duration is provided.
  47 
  48     """
  49     if 'onset' not in events.keys():
  50         raise ValueError('The provided events data has no onset column.')
  51     if 'duration' not in events.keys():
  52         raise ValueError('The provided events data has no duration column.')
  53 
  54     onset = np.array(events['onset'])
  55     duration = np.array(events['duration']).astype(np.float)
  56     n_events = len(onset)
  57     trial_type = np.array(events['trial_type'])
  58     modulation = np.ones(n_events)
  59     if 'trial_type' not in events.keys():
  60         warnings.warn("'trial_type' column not found "
  61                       "in the given events data.")
  62         trial_type = np.repeat('dummy', n_events)
  63     if 'modulation' in events.keys():
  64         warnings.warn("'modulation' column found in the given events data.")
  65         modulation = np.array(events['modulation']).astype(np.float)
  66     return trial_type, onset, duration, modulation
  67
  [end of nilearn/glm/first_level/experimental_paradigm.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/nilearn/glm/first_level/experimental_paradigm.py b/nilearn/glm/first_level/experimental_paradigm.py
  --- a/nilearn/glm/first_level/experimental_paradigm.py
  +++ b/nilearn/glm/first_level/experimental_paradigm.py
  @@ -17,6 +17,11 @@
   
   import numpy as np
   
  +VALID_FIELDS = set(["onset",
  +                    "duration",
  +                    "trial_type",
  +                    "modulation",
  +                    ])
   
   def check_events(events):
       """Test that the events data describes a valid experimental paradigm
  @@ -54,13 +59,19 @@
       onset = np.array(events['onset'])
       duration = np.array(events['duration']).astype(np.float)
       n_events = len(onset)
  -    trial_type = np.array(events['trial_type'])
       modulation = np.ones(n_events)
       if 'trial_type' not in events.keys():
           warnings.warn("'trial_type' column not found "
                         "in the given events data.")
           trial_type = np.repeat('dummy', n_events)
  +    else:
  +        trial_type = np.array(events['trial_type'])
       if 'modulation' in events.keys():
           warnings.warn("'modulation' column found in the given events data.")
           modulation = np.array(events['modulation']).astype(np.float)
  +    for event,_ in events.items():
  +        if event not in VALID_FIELDS:
  +            warnings.warn("Unexpected key `{}` in events "
  +                          "will be ignored.".format(
  +                              event))
       return trial_type, onset, duration, modulation
  
verification_info: {"golden_diff": "diff --git a/nilearn/glm/first_level/experimental_paradigm.py b/nilearn/glm/first_level/experimental_paradigm.py\n--- a/nilearn/glm/first_level/experimental_paradigm.py\n+++ b/nilearn/glm/first_level/experimental_paradigm.py\n@@ -17,6 +17,11 @@\n \n import numpy as np\n \n+VALID_FIELDS = set([\"onset\",\n+                    \"duration\",\n+                    \"trial_type\",\n+                    \"modulation\",\n+                    ])\n \n def check_events(events):\n     \"\"\"Test that the events data describes a valid experimental paradigm\n@@ -54,13 +59,19 @@\n     onset = np.array(events['onset'])\n     duration = np.array(events['duration']).astype(np.float)\n     n_events = len(onset)\n-    trial_type = np.array(events['trial_type'])\n     modulation = np.ones(n_events)\n     if 'trial_type' not in events.keys():\n         warnings.warn(\"'trial_type' column not found \"\n                       \"in the given events data.\")\n         trial_type = np.repeat('dummy', n_events)\n+    else:\n+        trial_type = np.array(events['trial_type'])\n     if 'modulation' in events.keys():\n         warnings.warn(\"'modulation' column found in the given events data.\")\n         modulation = np.array(events['modulation']).astype(np.float)\n+    for event,_ in events.items():\n+        if event not in VALID_FIELDS:\n+            warnings.warn(\"Unexpected key `{}` in events \"\n+                          \"will be ignored.\".format(\n+                              event))\n     return trial_type, onset, duration, modulation\n", "issue": "check_paradigm should check for invalid keys in passed dict\nUsing the old `nipy` user logic, I passed `amplitude=somethx` instead of `modulation=somethx` in the `make_design_matrix`. I didn't crash but the values where ignored (e.g Error: unknown param, etc.). A default value of 1 was forced...\n\n", "before_files": [{"content": "\"\"\"\nAn experimental protocol is handled as a pandas DataFrame\nthat includes an 'onset' field.\n\nThis yields the onset time of the events in the experimental paradigm.\nIt can also contain:\n\n    * a 'trial_type' field that yields the condition identifier.\n    * a 'duration' field that yields event duration (for so-called block\n        paradigms).\n    * a 'modulation' field that associated a scalar value to each event.\n\nAuthor: Bertrand Thirion, 2015\n\n\"\"\"\nimport warnings\n\nimport numpy as np\n\n\ndef check_events(events):\n    \"\"\"Test that the events data describes a valid experimental paradigm\n\n    It is valid if the events data  has an 'onset' key.\n\n    Parameters\n    ----------\n    events : pandas DataFrame\n        Events data that describes a functional experimental paradigm.\n\n    Returns\n    -------\n    trial_type : array of shape (n_events,), dtype='s'\n        Per-event experimental conditions identifier.\n        Defaults to np.repeat('dummy', len(onsets)).\n\n    onset : array of shape (n_events,), dtype='f'\n        Per-event onset time (in seconds)\n\n    duration : array of shape (n_events,), dtype='f'\n        Per-event durantion, (in seconds)\n        defaults to zeros(n_events) when no duration is provided\n\n    modulation : array of shape (n_events,), dtype='f'\n        Per-event modulation, (in seconds)\n        defaults to ones(n_events) when no duration is provided.\n\n    \"\"\"\n    if 'onset' not in events.keys():\n        raise ValueError('The provided events data has no onset column.')\n    if 'duration' not in events.keys():\n        raise ValueError('The provided events data has no duration column.')\n\n    onset = np.array(events['onset'])\n    duration = np.array(events['duration']).astype(np.float)\n    n_events = len(onset)\n    trial_type = np.array(events['trial_type'])\n    modulation = np.ones(n_events)\n    if 'trial_type' not in events.keys():\n        warnings.warn(\"'trial_type' column not found \"\n                      \"in the given events data.\")\n        trial_type = np.repeat('dummy', n_events)\n    if 'modulation' in events.keys():\n        warnings.warn(\"'modulation' column found in the given events data.\")\n        modulation = np.array(events['modulation']).astype(np.float)\n    return trial_type, onset, duration, modulation\n", "path": "nilearn/glm/first_level/experimental_paradigm.py"}]}