internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: enthought/chaco

Issue:
ArrayDataSource get_mask_data() fails when data is None
See this test here:

https://github.com/enthought/chaco/blob/enh/data-source-tests/chaco/tests/arraydatasource_test_case.py#L108

More generally, I think that the behaviour for an empty data source is probably wrong (why a _scalar_ `0.0` instead of `array([])`?) but I'm not sure what will break if that is changed.



Discussion:
Updated link: https://github.com/enthought/chaco/blob/b74e14918ad533d973775d78feaf1b80bfa4095a/chaco/tests/test_arraydatasource.py#L102-L108 

Uncommenting the skip the test fails with:
```
======================================================================
ERROR: test_get_data_mask_no_data (chaco.tests.test_arraydatasource.ArrayDataSourceTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/aayres/Desktop/chaco/chaco/tests/test_arraydatasource.py", line 106, in test_get_data_mask_no_data
    data, mask = data_source.get_data_mask()
  File "/Users/aayres/Desktop/chaco/chaco/array_data_source.py", line 158, in get_data_mask
    return self._data, ones(len(self._data), dtype=bool)
TypeError: object of type 'NoneType' has no len()

----------------------------------------------------------------------
```

Resolving patch:
diff --git a/chaco/array_data_source.py b/chaco/array_data_source.py
--- a/chaco/array_data_source.py
+++ b/chaco/array_data_source.py
@@ -155,7 +155,10 @@ def get_data_mask(self):
         Implements AbstractDataSource.
         """
         if self._cached_mask is None:
-            return self._data, ones(len(self._data), dtype=bool)
+            if self._data is None:
+                return self._data, ones(0, dtype=bool)
+            else:
+                return self._data, ones(len(self._data), dtype=bool)
         else:
             return self._data, self._cached_mask
 


Test patch:
diff --git a/chaco/tests/test_arraydatasource.py b/chaco/tests/test_arraydatasource.py
--- a/chaco/tests/test_arraydatasource.py
+++ b/chaco/tests/test_arraydatasource.py
@@ -99,13 +99,12 @@ def test_get_data_mask(self):
         assert_array_equal(data, self.myarray)
         assert_array_equal(mask, self.mymask)
 
-    @unittest.skip("get_data_mask() fails in this case")
     def test_get_data_mask_no_data(self):
         data_source = ArrayDataSource(None)
 
         data, mask = data_source.get_data_mask()
-        assert_array_equal(data, 0.0)
-        assert_array_equal(mask, True)
+        self.assertEqual(data, None)
+        assert_array_equal(mask, ones(shape=0, dtype=bool))
 
     def test_get_data_mask_no_mask(self):
         data, mask = self.data_source.get_data_mask()
Repository: enthought/chaco

Issue:
Replace mutable default argument in plot_factory create_*_plot functions
Replace the use of mutable default `data` argument to the `create_*_plot` functions in the `plot_factory` module.

https://github.com/enthought/chaco/blob/ef7227706642f7d26042717ad9b60648d7572068/chaco/plot_factory.py#L43
https://github.com/enthought/chaco/blob/ef7227706642f7d26042717ad9b60648d7572068/chaco/plot_factory.py#L91
https://github.com/enthought/chaco/blob/ef7227706642f7d26042717ad9b60648d7572068/chaco/plot_factory.py#L136




Discussion:

Resolving patch:
diff --git a/chaco/plot_factory.py b/chaco/plot_factory.py
--- a/chaco/plot_factory.py
+++ b/chaco/plot_factory.py
@@ -48,7 +48,7 @@ def _create_data_sources(data, index_sort="none"):
 
 
 def create_scatter_plot(
-    data=[],
+    data=None,
     index_bounds=None,
     value_bounds=None,
     orientation="h",
@@ -69,6 +69,8 @@ def create_scatter_plot(
 
     Pre-existing "index" and "value" datasources can be passed in.
     """
+    if data is None:
+        data = []
 
     index, value = _create_data_sources(data)
 
@@ -109,7 +111,7 @@ def create_scatter_plot(
 
 
 def create_line_plot(
-    data=[],
+    data=None,
     index_bounds=None,
     value_bounds=None,
     orientation="h",
@@ -130,6 +132,9 @@ def create_line_plot(
 
     Pre-existing "index" and "value" datasources can be passed in.
     """
+    if data is None:
+        data = []
+
     index, value = _create_data_sources(data, index_sort)
 
     if index_bounds is not None:
@@ -168,7 +173,7 @@ def create_line_plot(
 
 
 def create_bar_plot(
-    data=[],
+    data=None,
     index_bounds=None,
     value_bounds=None,
     orientation="h",
@@ -191,6 +196,9 @@ def create_bar_plot(
 
     Pre-existing "index" and "value" datasources can be passed in.
     """
+    if data is None:
+        data = []
+
     index, value = _create_data_sources(data)
 
     if index_bounds is not None:


Test patch:
Repository: enthought/chaco

Issue:
Remove unnecessary u-prefixes from the codebase and examples
The u-prefix e.g. `u"abc"` is not needed on Python 3 so the prefixes can be removed. Note that this is not worth doing unless this can be automated using a search-and-replace, possibly using a regex.


Discussion:

Resolving patch:
diff --git a/chaco/examples/demo/basic/minard_napoleon.py b/chaco/examples/demo/basic/minard_napoleon.py
--- a/chaco/examples/demo/basic/minard_napoleon.py
+++ b/chaco/examples/demo/basic/minard_napoleon.py
@@ -22,26 +22,26 @@
 # town locations
 towns = np.array(
     [
-        (24.0, 55.0, u"Kowno"),
-        (25.3, 54.7, u"Wilna"),
-        (26.4, 54.4, u"Smorgoni"),
-        (26.8, 54.3, u"Molodexno"),
-        (27.7, 55.2, u"Gloubokoe"),
-        (27.6, 53.9, u"Minsk"),
-        (28.5, 54.3, u"Studienska"),
-        (28.7, 55.5, u"Polotzk"),
-        (29.2, 54.4, u"Bobr"),
-        (30.2, 55.3, u"Witebsk"),
-        (30.4, 54.5, u"Orscha"),
-        (30.4, 53.9, u"Mohilow"),
-        (32.0, 54.8, u"Smolensk"),
-        (33.2, 54.9, u"Dorogobouge"),
-        (34.3, 55.2, u"Wixma"),
-        (34.4, 55.5, u"Chjat"),
-        (36.0, 55.5, u"Mojaisk"),
-        (37.6, 55.8, u"Moscou"),
-        (36.6, 55.3, u"Tarantino"),
-        (36.5, 55.0, u"Malo-jarosewli"),
+        (24.0, 55.0, "Kowno"),
+        (25.3, 54.7, "Wilna"),
+        (26.4, 54.4, "Smorgoni"),
+        (26.8, 54.3, "Molodexno"),
+        (27.7, 55.2, "Gloubokoe"),
+        (27.6, 53.9, "Minsk"),
+        (28.5, 54.3, "Studienska"),
+        (28.7, 55.5, "Polotzk"),
+        (29.2, 54.4, "Bobr"),
+        (30.2, 55.3, "Witebsk"),
+        (30.4, 54.5, "Orscha"),
+        (30.4, 53.9, "Mohilow"),
+        (32.0, 54.8, "Smolensk"),
+        (33.2, 54.9, "Dorogobouge"),
+        (34.3, 55.2, "Wixma"),
+        (34.4, 55.5, "Chjat"),
+        (36.0, 55.5, "Mojaisk"),
+        (37.6, 55.8, "Moscou"),
+        (36.6, 55.3, "Tarantino"),
+        (36.5, 55.0, "Malo-jarosewli"),
     ],
     dtype=[("lon", "f4"), ("lat", "f4"), ("town", "U12")],
 )
@@ -192,7 +192,7 @@ def _create_plot_component():
     temp_plot.x_grid = None
     temp_plot.x_axis = None
     temp_plot.y_axis.orientation = "right"
-    temp_plot.y_axis.title = u"Temp (°Re)"
+    temp_plot.y_axis.title = "Temp (°Re)"
     temp_plot.plot(
         ("temp_lon", "temp"),
         type="line",


Test patch:
diff --git a/chaco/tests/test_arraydatasource.py b/chaco/tests/test_arraydatasource.py
--- a/chaco/tests/test_arraydatasource.py
+++ b/chaco/tests/test_arraydatasource.py
@@ -186,10 +186,10 @@ def test_bounds_negative_positive_inf(self):
         self.assertEqual(bounds, (-np.inf, np.inf))
 
     def test_bounds_non_numeric(self):
-        myarray = np.array([u"abc", u"foo", u"bar", u"def"], dtype=str)
+        myarray = np.array(["abc", "foo", "bar", "def"], dtype=str)
         data_source = ArrayDataSource(myarray)
         bounds = data_source.get_bounds()
-        self.assertEqual(bounds, (u"abc", u"def"))
+        self.assertEqual(bounds, ("abc", "def"))
 
     def test_data_size(self):
         # We know that ArrayDataTestCase always returns the exact length of
Repository: enthought/chaco

Issue:
NameError: name 'gc' is not defined
**Problem Description**
NameError: name 'gc' is not defined in chaco/chaco/plots/polar_line_renderer.py

**Reproduction Steps:**
python chaco/examples/demo/simple_polar.py

[Steps to reproduce issue here.]

```python
# Code to reproduce issue here
```

**Expected behavior:**  

[MacOS, python3.8 (EDM)]

**OS, Python version:** [Enter OS name and Python version]



Discussion:

Resolving patch:
diff --git a/chaco/plots/polar_line_renderer.py b/chaco/plots/polar_line_renderer.py
--- a/chaco/plots/polar_line_renderer.py
+++ b/chaco/plots/polar_line_renderer.py
@@ -130,7 +130,7 @@ def map_data(self, screen_pt):
     def _downsample(self):
         return self.map_screen(self._cached_data_pts)
 
-    def _draw_plot(self, *args, **kw):
+    def _draw_plot(self, gc, *args, **kw):
         """Draws the 'plot' layer."""
         self._gather_points()
         self._render(gc, self._cached_data_pts)


Test patch:
Repository: enthought/chaco

Issue:
ImportError: cannot import name 'BaseTool' from 'chaco.api'
**Problem Description**
ImportError: cannot import name 'BaseTool' from 'chaco.api' when running chaco/examples/demo/canvas/mptools.py

**Reproduction Steps:**
python chaco/examples/demo/canvas/mptools.py

**OS, Python version:** [MacOS, python3.11, python3.8 (with EDM)]
 


Discussion:

Resolving patch:
diff --git a/examples/demo/canvas/mptools.py b/examples/demo/canvas/mptools.py
--- a/examples/demo/canvas/mptools.py
+++ b/examples/demo/canvas/mptools.py
@@ -15,8 +15,9 @@
     CArray,
 )
 
+from enable.api import BaseTool
+
 # Chaco imports
-from chaco.api import BaseTool
 from chaco.chaco_traits import Optional
 from chaco.tools.api import PanTool, DragZoom, LegendTool, RangeSelection
 


Test patch:
Repository: enthought/chaco

Issue:
ImportError: cannot import name 'marker_trait' from 'chaco.api'
**Problem Description**
ImportError: cannot import name 'marker_trait' from 'chaco.api' when trying to run a 2008 demo

**Reproduction Steps:**

```python
python chaco/examples/tutorials/scipy2008/traits_example.py
```

**Expected behavior:**
test past

**OS, Python version:** [MacOS, python3.8 (with or without edm) or 3.11]



Discussion:
In issue #878 It is caused by not importing from the right API. This may be a problem of similar cause.
In general it is better to fix the demo to conform to the current API than changing the API.  Import from enable in the example if that is where things currently are.

Resolving patch:
diff --git a/examples/tutorials/scipy2008/traits_example.py b/examples/tutorials/scipy2008/traits_example.py
--- a/examples/tutorials/scipy2008/traits_example.py
+++ b/examples/tutorials/scipy2008/traits_example.py
@@ -1,7 +1,7 @@
 from numpy import linspace, sin
 
-from enable.api import ColorTrait
-from chaco.api import ArrayPlotData, Plot, marker_trait
+from enable.api import ColorTrait, marker_trait
+from chaco.api import ArrayPlotData, Plot
 from enable.api import ComponentEditor
 from traits.api import HasTraits, Instance, Int
 from traitsui.api import Group, Item, View


Test patch:
Repository: enthought/chaco

Issue:
Downstream users still import marker_trait from chaco.api
This was removed in PR #679

To avoid breaking code we should bring it back into the `chaco.api` for the 5.0.0 release


Discussion:
I would like to note that the first example of a dynamically changing plot in the tutorial on enthought.com relies on marker_trait from chaco.api and therefore can not be run in the current version of chaco.
The tutorial on enthought.com is broken because **_you created a backward incompatibility_**. (Really?  Who does that.)  Please fix the incompatibility, or at least **_fix the tutorial_**.   This will turn away new users.  

Resolving patch:
diff --git a/chaco/api.py b/chaco/api.py
--- a/chaco/api.py
+++ b/chaco/api.py
@@ -498,7 +498,7 @@
     YlGn,
     YlGnBu,
     YlOrBr,
-    YlOrRd,  
+    YlOrRd,
     gist_earth,
     gist_gray,
     gist_heat,
@@ -527,3 +527,20 @@
     Set3,
 )
 from .default_colors import cbrewer, palette11, palette14, PALETTES
+
+
+def __getattr__(name):
+    """Backward compatibility lazy imports.
+
+    These imports warn about backwards incompatible changes.
+    """
+    if name in {'marker_trait'}:
+        from warnings import warn
+        import enable.api
+        warn(
+            f"Please import {name} from enable.api instead of chaco.api.",
+            DeprecationWarning,
+        )
+        return getattr(enable.api, name)
+
+    raise AttributeError(f"module {__name__!r} has no attribute {name!r}")


Test patch:
diff --git a/chaco/tests/test_api.py b/chaco/tests/test_api.py
new file mode 100644
--- /dev/null
+++ b/chaco/tests/test_api.py
@@ -0,0 +1,24 @@
+# (C) Copyright 2005-2021 Enthought, Inc., Austin, TX
+# All rights reserved.
+#
+# This software is provided without warranty under the terms of the BSD
+# license included in LICENSE.txt and may be redistributed only under
+# the conditions described in the aforementioned license. The license
+# is also available online at http://www.enthought.com/licenses/BSD.txt
+#
+# Thanks for using Enthought open source!
+
+import unittest
+
+import chaco.api
+
+
+class TestAPI(unittest.TestCase):
+
+    def test_enable_imports(self):
+        """Test for deprecated imports from enable.api"""
+        names = {'marker_trait'}
+        for name in names:
+            with self.subTest(name=name):
+                with self.assertWarns(DeprecationWarning):
+                    getattr(chaco.api, name)
Repository: enthought/chaco

Issue:
Wx BitmapFromBufferRGBA deprecated in favor of Bitmap.FromBufferRGBA
```
c:\users\rporuri\work\github\ets\chaco\chaco\tools\toolbars\toolbar_buttons.py:190: wxPyDeprecationWarning: Call to deprecated item BitmapFromBufferRGBA. Use :meth:`wx.Bitmap.FromBufferRGBA` instead.
  width + 1, height + 1, gc.bmp_array.flatten()
```

Discovered when running `examples/demo/depth.py`


Discussion:

Resolving patch:
diff --git a/chaco/tools/toolbars/toolbar_buttons.py b/chaco/tools/toolbars/toolbar_buttons.py
--- a/chaco/tools/toolbars/toolbar_buttons.py
+++ b/chaco/tools/toolbars/toolbar_buttons.py
@@ -196,7 +196,7 @@ def perform(self, event):
     def _perform_wx(self, width, height, gc):
         import wx
 
-        bitmap = wx.BitmapFromBufferRGBA(
+        bitmap = wx.Bitmap.FromBufferRGBA(
             width + 1, height + 1, gc.bmp_array.flatten()
         )
         data = wx.BitmapDataObject()


Test patch:
Repository: bids-standard/pybids

Issue:
Force UTF-8 encoding anywhere JSON files are read in
Per an issue on the mailing list, we should explicitly force UTF-8 encoding whenever we work with JSON files, because the BIDS spec already mandates UTF-8 for spec compliance. Otherwise we risk failure on platforms where the default encoding is something else.


Discussion:

Resolving patch:
diff --git a/bids/grabbids/bids_layout.py b/bids/grabbids/bids_layout.py
--- a/bids/grabbids/bids_layout.py
+++ b/bids/grabbids/bids_layout.py
@@ -5,7 +5,6 @@
 from os.path import dirname
 from os.path import abspath
 from os.path import join as pathjoin
-from os.path import basename
 
 from grabbit import Layout
 
@@ -48,12 +47,15 @@ def _get_nearest_helper(self, path, extension, type=None, **kwargs):
     def get_metadata(self, path, **kwargs):
 
         potentialJSONs = self._get_nearest_helper(path, '.json', **kwargs)
-        if not isinstance(potentialJSONs, list): return potentialJSONs
+
+        if not isinstance(potentialJSONs, list):
+            return potentialJSONs
 
         merged_param_dict = {}
         for json_file_path in reversed(potentialJSONs):
             if os.path.exists(json_file_path):
-                param_dict = json.load(open(json_file_path, "r"))
+                param_dict = json.load(open(json_file_path, "r",
+                                            encoding='utf-8'))
                 merged_param_dict.update(param_dict)
 
         return merged_param_dict


Test patch:
Repository: bids-standard/pybids

Issue:
Fieldmaps - _magnitude2.nii[.gz] is optional
As per these lines:

https://github.com/INCF/pybids/blob/800d15053952991c9cd4a00cf0039288d489ca12/bids/grabbids/bids_layout.py#L143-L148

when a fieldmap type is identified as `'phasediff'` then pybids understands that there is always a `_magnitude2.nii[.gz]` file. However, this is maked as optional in the specification.


Discussion:

Resolving patch:
diff --git a/bids/grabbids/bids_layout.py b/bids/grabbids/bids_layout.py
--- a/bids/grabbids/bids_layout.py
+++ b/bids/grabbids/bids_layout.py
@@ -143,9 +143,11 @@ def _get_fieldmaps(self, path):
                         cur_fieldmap = {"phasediff": file.filename,
                                         "magnitude1": file.filename.replace(
                                             "phasediff", "magnitude1"),
-                                        "magnitude2": file.filename.replace(
-                                            "phasediff", "magnitude2"),
                                         "type": "phasediff"}
+                        magnitude2 = file.filename.replace(
+                            "phasediff", "magnitude2")
+                        if os.path.isfile(magnitude2):
+                            cur_fieldmap['magnitude2'] = magnitude2
                     elif file.type == "phase1":
                         cur_fieldmap["phase1"] = file.filename
                         cur_fieldmap["magnitude1"] = \


Test patch:
Repository: bids-standard/pybids

Issue:
BIDSLayout.get_nearest_helper() does not anticipate absent 'type' entity
Happens with openfmri ds000002 due to contained derivatives:

```
  File "/home/mih/.local/lib/python2.7/site-packages/bids/grabbids/bids_layout.py", line 45, in get_metadata
    potentialJSONs = self.get_nearest_helper(path, '.json', **kwargs)
  File "/home/mih/.local/lib/python2.7/site-packages/bids/grabbids/bids_layout.py", line 37, in get_nearest_helper
    type = self.files[path].entities['type']
KeyError: 'type'
()
> /home/mih/.local/lib/python2.7/site-packages/bids/grabbids/bids_layout.py(37)get_nearest_helper()
-> type = self.files[path].entities['type']
(Pdb) self.files[path].entities
{u'subject': '01'}
(Pdb) path
u'/tmp/openfmri/ds000002/derivatives/mriqc/anatomical_sub-01.pdf'
```


Discussion:

Resolving patch:
diff --git a/bids/grabbids/bids_layout.py b/bids/grabbids/bids_layout.py
--- a/bids/grabbids/bids_layout.py
+++ b/bids/grabbids/bids_layout.py
@@ -62,7 +62,11 @@ def _get_nearest_helper(self, path, extension, type=None, **kwargs):
                 "BIDS project." % path)
 
         if not type:
-            # Constrain the search to .json files with the same type as target
+            if 'type' not in self.files[path].entities:
+                raise ValueError(
+                    "File '%s' does not have a valid type definition, most "
+                    "likely because it is not a valid BIDS file." % path
+                )
             type = self.files[path].entities['type']
 
         tmp = self.get_nearest(path, extensions=extension, all_=True,


Test patch:
Repository: bids-standard/pybids

Issue:
analysis: Block creation ignores input collections
When creating an `Analysis` object, you can optionally specify the collections to use, instead of loading them from the `Layout`
E.g.:

    collections = {
        'run': load_variables(bids_layout,
                              derivatives='only',
                              task='some_task',
                              level='run',
                              **entities).get_collections('run')[0]
        }

    bids_analysis = Analysis(bids_layout, model, collections=collections)

Looks like currently, the `collections` argument is ignored, and just saved. When blocks are created, the collections are always loaded up from the layout, which means any "custom" collections are ignored. In my case, this means "derivative" events can't be passed into the Analysis object. 


Discussion:
This is a bug, but the solution is probably to drop the `collections` argument, rather than allowing custom collections to be passed. In principle, it should be possible to add constraints to collection loading as extra `kwargs` to `Analysis.setup`.

What's preventing derivative events from being loaded properly? In theory if files are indexed properly at `Layout` construction, `Layout.get_collections` should use them no matter where they live. It's possible that's failing for some reason, but if so, that's probably where a fix is called for.
I've tested that and that works. The Layout indexes just fine, this was mostly just leftover code from how you previously 'injected' events into `Analysis`. 

Agree dropping collections argument would be good, as its confusing 

Resolving patch:
diff --git a/bids/analysis/analysis.py b/bids/analysis/analysis.py
--- a/bids/analysis/analysis.py
+++ b/bids/analysis/analysis.py
@@ -19,10 +19,6 @@ class Analysis(object):
         model (str or dict): a BIDS model specification. Can either be a
             string giving the path of the JSON model spec, or an already-loaded
             dict containing the model info.
-        collections (dict): An optional dictionary containing all variable
-            collections to use. Keys are level names ('run', 'session', etc.);
-            values are lists of BIDSVariableCollections. If None, collections
-            will be read from the current layout.
         sampling_rate (int): Optional sampling rate (in Hz) to use when
             resampling variables internally. If None, the package-wide default
             will be used.
@@ -31,11 +27,9 @@ class Analysis(object):
             available.
     '''
 
-    def __init__(self, layout, model, collections=None, sampling_rate=None,
-                 scan_length=None):
+    def __init__(self, layout, model, sampling_rate=None, scan_length=None):
 
         self.sampling_rate = sampling_rate
-        self.collections = collections
         self.scan_length = scan_length
 
         if not isinstance(layout, BIDSLayout):


Test patch:
Repository: bids-standard/pybids

Issue:
analysis: groupby defaults to included "run", but could be None
When applying transformations, it seems the default groupby is `['run', 'subject']`.

However, this is can be a problem because some runs dont have a run number (if there is only one run, it seems to be optional under the BIDS spec). In this case, a pandas `KeyError` will occur. 


Discussion:
Thanks--this should be an easy fix in the base `Transformation` class; will get to it soon.

Resolving patch:
diff --git a/bids/analysis/transformations/base.py b/bids/analysis/transformations/base.py
--- a/bids/analysis/transformations/base.py
+++ b/bids/analysis/transformations/base.py
@@ -91,7 +91,7 @@ def _setup(self, collection, variables, *args, **kwargs):
         >= 3.3, we can't override both new and init. '''
         self.collection = collection
         self.variables = listify(variables)
-        self.groupby = kwargs.pop('groupby', ['run', 'subject'])
+        self.groupby = kwargs.pop('groupby', None)
         self.output = listify(kwargs.pop('output', None))
         self.output_prefix = kwargs.pop('output_prefix', None)
         self.output_suffix = kwargs.pop('output_suffix', None)


Test patch:
diff --git a/bids/analysis/tests/test_transformations.py b/bids/analysis/tests/test_transformations.py
--- a/bids/analysis/tests/test_transformations.py
+++ b/bids/analysis/tests/test_transformations.py
@@ -39,7 +39,7 @@ def test_product(collection):
 
 def test_scale(collection):
     transform.scale(collection, variables=['RT', 'parametric gain'],
-                    output=['RT_Z', 'gain_Z'])
+                    output=['RT_Z', 'gain_Z'], groupby=['run', 'subject'])
     ents = collection['RT'].index
     groupby = pd.core.groupby._get_grouper(ents, ['run', 'subject'])[0]
     z1 = collection['RT_Z'].values
@@ -79,7 +79,7 @@ def test_orthogonalize_sparse(collection):
     pg_pre = collection['parametric gain'].values
     rt = collection['RT'].values
     transform.orthogonalize(collection, variables='parametric gain',
-                            other='RT')
+                            other='RT', groupby=['run', 'subject'])
     pg_post = collection['parametric gain'].values
     vals = np.c_[rt.values, pg_pre.values, pg_post.values]
     df = pd.DataFrame(vals, columns=['rt', 'pre', 'post'])