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

Issue:
Hist:divide is broken
```
An exception was caught!
Traceback (most recent call last):
  File "totw.py", line 363, in <module>
    ratio = Hist.divide(hist, hstack)
  File "/Users/kratsg/.virtualenvs/TakeOverTheWorld/lib/python2.7/site-packages/rootpy/plotting/hist.py", line 454, in divide
    ROOT.TH1.Divide(ratio, h1, h2, c1, c2, option)
TypeError: none of the 3 overloaded methods succeeded. Full details:
  Bool_t TH1::Divide(const TH1* h1) =>
    takes at most 1 arguments (5 given)
  Bool_t TH1::Divide(TF1* f1, Double_t c1 = 1) =>
    takes at most 2 arguments (5 given)
  Bool_t TH1::Divide(const TH1* h1, const TH1* h2, Double_t c1 = 1, Double_t c2 = 1, Option_t* option = "") =>
    could not convert argument 2
```

This is defined here: https://github.com/rootpy/rootpy/blob/master/rootpy/plotting/hist.py#L451-L459

```
ROOT 5.34/23 (heads/v5-34-00-patches@v5-34-22-106-g4a0dea3, Nov 19 2014, 08:46:00 on macosx64)
```

and

```
rootpy (0.8.0)
```



Discussion:
Ahh, it looks like it doesn't like `THStack` objects for any of the arguments unfortunately. Could potentially avoid the error by doing something like

```
if hasattr(hist, 'GetHistogram'):
  hist = hist.GetHistogram()
```

in the code.

Yes, thanks! I'll add that.


Resolving patch:
diff --git a/rootpy/plotting/hist.py b/rootpy/plotting/hist.py
--- a/rootpy/plotting/hist.py
+++ b/rootpy/plotting/hist.py
@@ -450,6 +450,10 @@ def bins_xyz(self, ix, iy=0, iz=0, proxy=True):
 
     @classmethod
     def divide(cls, h1, h2, c1=1., c2=1., option='', fill_value=None):
+        if hasattr(h1, 'GetHistogram'):
+            h1 = h1.GetHistogram()
+        if hasattr(h2, 'GetHistogram'):
+            h2 = h2.GetHistogram()
         ratio = h1.Clone()
         ROOT.TH1.Divide(ratio, h1, h2, c1, c2, option)
         if fill_value is not None:


Test patch:
Repository: rootpy/rootpy

Issue:
UnboundLocalError: local variable 'hlist' referenced before assignment
Hi everyone,

The variable `hlist` is not defined in this block: https://github.com/rootpy/rootpy/blob/master/rootpy/plotting/root2matplotlib.py#L451.

I believe that adding the line below should fix this issue:

``` python
 hlist = _maybe_reversed(hists, reverse)
```

Here is the traceback for reference:

``` bash
Traceback (most recent call last):
  File "/Users/quentin/software/tauperf/sk", line 158, in <module>
    data_test[data_test['is_sig'] == 0]['weight'])
  File "/Users/quentin/software/tauperf/tauperf/plotting/mpl.py", line 45, in score_plot
    rmpl.bar([hsig, hbkg], stacked=False)
  File "/Users/quentin/Library/Python/2.7/lib/python/site-packages/rootpy/plotting/root2matplotlib.py", line 451, in bar
    for h in hlist:
UnboundLocalError: local variable 'hlist' referenced before assignment
```

Cheers,
Quentin



Discussion:
Thanks for reporting this! Fixing now...


Resolving patch:
diff --git a/rootpy/plotting/root2matplotlib.py b/rootpy/plotting/root2matplotlib.py
--- a/rootpy/plotting/root2matplotlib.py
+++ b/rootpy/plotting/root2matplotlib.py
@@ -448,6 +448,7 @@ def bar(hists,
                     snap=snap,
                     logy=logy)
     else:
+        hlist = _maybe_reversed(hists, reverse)
         for h in hlist:
             returns.append(_bar(h, xerr=xerr, yerr=yerr,
                                 axes=axes, **kwargs))


Test patch:
diff --git a/rootpy/plotting/tests/test_root2matplotlib.py b/rootpy/plotting/tests/test_root2matplotlib.py
--- a/rootpy/plotting/tests/test_root2matplotlib.py
+++ b/rootpy/plotting/tests/test_root2matplotlib.py
@@ -36,7 +36,9 @@ def test_bar():
     h1 = h.Clone()
     stack = HistStack([h, h1])
     rplt.bar(stack)
-    rplt.bar([h, h1])
+    rplt.bar([h, h1], stacked=True)
+    rplt.bar([h, h1], stacked=False)
+    rplt.bar([h, h1], stacked=False, reverse=True)
 
 
 @with_setup(setup_func)
Repository: rootpy/rootpy

Issue:
Error when using root_open: 'TDirectory' object has no attribute 'func'
As above:

`AttributeError: 'TDirectory' object has no attribute 'func'`


Discussion:
Which version of ROOT and python?
ROOT 6.09/02, Python 3.6.1
Can you paste the full stacktrace?
(sorry, clicked wrong button and reopened issue)
```
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-3-ab852ddef913> in <module>()
----> 1 file = root_open('out.root')

/usr/lib/python3.6/site-packages/rootpy/io/file.py in root_open(filename, mode)
    135 
    136     filename = expand_path(filename)
--> 137     prev_dir = ROOT.gDirectory.func()
    138     root_file = ROOT.R.TFile.Open(filename, mode)
    139     if not root_file:

AttributeError: 'TDirectory' object has no attribute 'func'
```
I haven't tested 6.09/02 yet. Looks like the ROOT devs must have removed that attr. This will be an easy fix.
The `.func` attribute is used elsewhere too (plotting for instance).

On May 9, 2017 12:59 PM, "Noel Dawe" <notifications@github.com> wrote:

> I haven't tested 6.09/02 yet. Looks like the ROOT devs must have removed
> that attr. This will be an easy fix.
>
> —
> You are receiving this because you authored the thread.
> Reply to this email directly, view it on GitHub
> <https://github.com/rootpy/rootpy/issues/747#issuecomment-300141884>, or mute
> the thread
> <https://github.com/notifications/unsubscribe-auth/ADjiNR1crPkS6qUQm9Cx1mavX2GEJ2Vmks5r4FU9gaJpZM4NVKRg>
> .
>

True, but I can just patch one in on rootpy.ROOT and fix it everywhere.

Resolving patch:
diff --git a/rootpy/ROOT.py b/rootpy/ROOT.py
--- a/rootpy/ROOT.py
+++ b/rootpy/ROOT.py
@@ -130,8 +130,7 @@ def R(self):
     gPad = proxy_global("gPad")
     gVirtualX = proxy_global("gVirtualX")
 
-    if ROOT_VERSION < (5, 32, 0):  # pragma: no cover
-        # handle versions of ROOT older than 5.32.00
+    if ROOT_VERSION < (5, 32, 0) or ROOT_VERSION >= (6, 9, 2):  # pragma: no cover
         gDirectory = proxy_global("gDirectory", no_expand_macro=True)
         gFile = proxy_global("gFile", no_expand_macro=True)
         gInterpreter = proxy_global("gInterpreter", no_expand_macro=True)


Test patch:
Repository: rootpy/rootpy

Issue:
Bin labels are lost with `rootpy.plotting.util.draw`
The [documentation](https://github.com/rootpy/rootpy/blob/master/rootpy/plotting/utils.py#L49) of `rootpy.plotting.util.draw` indicates that if you do not specify axes, the axes of the first plottable will be used. But [here](https://github.com/rootpy/rootpy/blob/master/rootpy/plotting/utils.py#L110) a temporary histo is created, so any bin labels that were set in the first plottable are lost. For example:

```
import rootpy
from rootpy.plotting import Hist
from rootpy.plotting.utils import draw

h = Hist(10, 0., 10.)
h.Fill(2.)
for i in range(10):
    h.xaxis.SetBinLabel(i + 1, 'bin {}'.format(i + 1))

draw(h)
```

Why not just use the first plottable? I've implemented it [here](https://github.com/annawoodard/rootpy/commit/6c2b77dd2cd8539478c67367d088c6872123835b) but wanted to document the issue first (because maybe I'm missing something obvious) before opening a PR. 


Discussion:

Resolving patch:
diff --git a/rootpy/plotting/utils.py b/rootpy/plotting/utils.py
--- a/rootpy/plotting/utils.py
+++ b/rootpy/plotting/utils.py
@@ -107,12 +107,13 @@ def draw(plottables, pad=None, same=False,
         if ylimits is not None:
             ymin, ymax = ylimits
         if not same:
-            # draw and get the axes with a temporary histogram
-            axeshist = Hist(1, 0, 1)
-            axeshist.Draw('AXIS')
-            # ignore axes from user if any
-            xaxis = axeshist.xaxis
-            yaxis = axeshist.yaxis
+            obj = plottables.pop(0)
+            if isinstance(obj, ROOT.THStack):
+                obj.SetMinimum(ymin)
+                obj.SetMaximum(ymax)
+            obj.Draw()
+            xaxis = obj.xaxis
+            yaxis = obj.yaxis
         # draw the plottables
         for i, obj in enumerate(plottables):
             if i == 0 and isinstance(obj, ROOT.THStack):


Test patch:
Repository: rootpy/rootpy

Issue:
Setting color/fillcolor at same time causes incorrect error
```
{'color': 'red', 'legendstyle': 'f', 'fillcolor': 'red'}
--------------------
An exception was caught!
Traceback (most recent call last):
  File "TakeOverTheWorld/totw.py", line 303, in <module>
    hist.decorate(**hist_styles)
  File "/Users/kratsg/.virtualenvs/TOTW/lib/python2.7/site-packages/rootpy/plotting/base.py", line 194, in decorate
    's' if len(incompatible) != 1 else ''))
IndexError: tuple index out of range
```

https://github.com/rootpy/rootpy/blob/7fea56851620348f35ccaf987a30e63c8d62225f/rootpy/plotting/base.py#L187-L192


Discussion:

Resolving patch:
diff --git a/rootpy/plotting/base.py b/rootpy/plotting/base.py
--- a/rootpy/plotting/base.py
+++ b/rootpy/plotting/base.py
@@ -186,7 +186,7 @@ def decorate(self, other=None, **kwargs):
                     incompatible.append(othercolor)
             if incompatible:
                 raise ValueError(
-                    "Setting both the `color` and the `{1}` attribute{2} "
+                    "Setting both the `color` and the `{0}` attribute{1} "
                     "is ambiguous. Please set only one.".format(
                         ', '.join(incompatible),
                         's' if len(incompatible) != 1 else ''))


Test patch:
diff --git a/rootpy/plotting/tests/test_plottable.py b/rootpy/plotting/tests/test_plottable.py
--- a/rootpy/plotting/tests/test_plottable.py
+++ b/rootpy/plotting/tests/test_plottable.py
@@ -3,7 +3,7 @@
 from rootpy.plotting import Hist
 from rootpy import asrootpy
 import ROOT
-from nose.tools import assert_equals
+from nose.tools import assert_equals, raises
 
 
 def test_plottable_clone():
@@ -21,6 +21,11 @@ def test_plottable_clone():
     assert_equals(c.markercolor, 'red')
 
 
+@raises(ValueError)
+def test_ambiguous_color():
+    Hist(10, 0, 1, color='red', fillcolor='blue')
+
+
 def test_plottable_asrootpy():
     hist = ROOT.TH1D("hist", "", 10, 0, 1)
     hist.SetLineColor(3)
Repository: rootpy/rootpy

Issue:
`Efficiency.__iadd__` is broken
I think the implementation of iadd for rootpy.plotting.Efficiency might be broken.
The culprit line is https://github.com/rootpy/rootpy/blob/master/rootpy/plotting/hist.py#L2562.

I think the fix is very straightforward though:
```py
super(Efficiency, self).Add(other)
```
ie. remove the `self` argument in `Add()`.



Discussion:
Good catch. You're right. Fixing that now

Resolving patch:
diff --git a/rootpy/info.py b/rootpy/info.py
--- a/rootpy/info.py
+++ b/rootpy/info.py
@@ -9,7 +9,7 @@
                     |_|    |___/
       {0}
 """
-__version__ = '0.9.1.dev0'
+__version__ = '0.9.2.dev0'
 __url__ = 'http://rootpy.github.com/rootpy'
 __repo_url__ = 'https://github.com/rootpy/rootpy/'
 __download_url__ = ('http://pypi.python.org/packages/source/r/'
diff --git a/rootpy/plotting/hist.py b/rootpy/plotting/hist.py
--- a/rootpy/plotting/hist.py
+++ b/rootpy/plotting/hist.py
@@ -2559,7 +2559,7 @@ def __add__(self, other):
         return copy
 
     def __iadd__(self, other):
-        super(Efficiency, self).Add(self, other)
+        super(Efficiency, self).Add(other)
         return self
 
     def __iter__(self):


Test patch:
Repository: rootpy/rootpy

Issue:
basestring
Hi there
I found the following issue:
If I'm using the F1 object from rootpy.plotting and try to access a parameter using [parnr] (the __getitem__) methode, I get the following error:
`NameError: name 'basestring' is not defined`
I'm using python 3.6 which doesn't has the basestring data type anymore..

https://github.com/rootpy/rootpy/blob/457e074056a916fff848978ef68b7f5107856e47/rootpy/plotting/func.py#L63


Discussion:

Resolving patch:
diff --git a/rootpy/plotting/func.py b/rootpy/plotting/func.py
--- a/rootpy/plotting/func.py
+++ b/rootpy/plotting/func.py
@@ -4,7 +4,7 @@
 from ..decorators import snake_case_methods
 from .base import Plottable
 from ..base import NameOnlyObject
-
+import six
 
 __all__ = [
     'F1',
@@ -17,7 +17,7 @@ class ParProxy(object):
         def __init__(self, fcn, idx):
             self.fcn_ = fcn
             self.idx_ = idx
-        
+
         @property
         def index(self):
             return self.idx_
@@ -25,7 +25,7 @@ def index(self):
         @property
         def name(self):
             return self.fcn_.GetParName(self.idx_)
-        
+
         @name.setter
         def name(self, val):
             return self.fcn_.SetParName(self.idx_, val)
@@ -55,14 +55,14 @@ def limits(self):
 
         @limits.setter
         def limits(self, val):
-            if not hastattr(val, '__len__') and len(val) != 2:
+            if not hasattr(val, '__len__') and len(val) != 2:
                 raise RuntimeError('Function limits must be a tuple size 2')
             self.fcn_.SetParLimits(self.idx_, val[0], val[1])
 
     def __getitem__(self, value):
-        if isinstance(value, basestring):
+        if isinstance(value, six.string_types):
             idx = self.GetParNumber(value)
-        elif isinstance(value, int):
+        elif isinstance(value, six.integer_types):
             idx = value
         else:
             raise ValueError('Function index must be a integer or a string')


Test patch:
Repository: rootpy/rootpy

Issue:
Unable to set errorlow for a graph
There is a bug in `rootpy.plotting.graph`, setting exl or eyl trough a GraphPoint throws an AttributeError:
```python
from rootpy.plotting import Graph
g = Graph(name="test",type='asymm')
g[0] = (1,1)
g[0].y.error_hi = 0.1
g[0].y.error_low = 0.1
```


Discussion:

Resolving patch:
diff --git a/rootpy/plotting/graph.py b/rootpy/plotting/graph.py
--- a/rootpy/plotting/graph.py
+++ b/rootpy/plotting/graph.py
@@ -93,7 +93,7 @@ def error_low(self, val):
                 if self.isdefault: return
                 getattr(
                     self.graph_,
-                    'voidSetPointE{0}low'.format(self.axis_.upper())
+                    'SetPointE{0}low'.format(self.axis_.upper())
                     )(self.index_, val)
 
 


Test patch:
Repository: carpentries/amy

Issue:
Add links to past and future events to site pages
Each site's page should show past and future events at that site (including ones that are still being negotiated).



Discussion:
Greg, I will take this one if you like

David

FYI, the code in PR #45 should make retrieving past/future events for a particular site as simple as:

`my_site_object.event_set.upcoming_events()` or `my_site_object.event_set.past_events()` respectively.

@davidmerand yes please and thank you.


Resolving patch:
diff --git a/workshops/views.py b/workshops/views.py
--- a/workshops/views.py
+++ b/workshops/views.py
@@ -37,8 +37,10 @@ def all_sites(request):
 def site_details(request, site_domain):
     '''List details of a particular site.'''
     site = Site.objects.get(domain=site_domain)
+    events = Event.objects.filter(site=site)
     context = {'title' : 'Site {0}'.format(site),
-               'site' : site}
+               'site' : site,
+               'events' : events}
     return render(request, 'workshops/site.html', context)
 
 class SiteCreate(CreateView):


Test patch:
Repository: carpentries/amy

Issue:
Create form for adding new person
The app should allow admins to add a single new person, either by adding a row to the "display all persons" page and editing in place, or via a form, or both.



Discussion:

Resolving patch:
diff --git a/workshops/models.py b/workshops/models.py
--- a/workshops/models.py
+++ b/workshops/models.py
@@ -102,6 +102,9 @@ def __str__(self):
             email = ' <{0}>'.format(self.email)
         return '{0}{1}'.format(self.fullname(), email)
 
+    def get_absolute_url(self):
+        return reverse('person_details', args=[str(self.id)])
+
 #------------------------------------------------------------
 
 class Project(models.Model):
diff --git a/workshops/urls.py b/workshops/urls.py
--- a/workshops/urls.py
+++ b/workshops/urls.py
@@ -1,5 +1,6 @@
 from django.conf.urls import url
 from .views import AirportCreate, AirportUpdate, \
+                   PersonCreate, PersonUpdate, \
                    SiteCreate, SiteUpdate, \
                    TaskCreate, TaskUpdate, \
                    CohortCreate, CohortUpdate, \
@@ -22,6 +23,8 @@
 
     url(r'^persons/?$', views.all_persons, name='all_persons'),
     url(r'^person/(?P<person_id>[\w\.-]+)/?$', views.person_details, name='person_details'),
+    url(r'^person/(?P<person_id>[\w\.-]+)/edit$', PersonUpdate.as_view(), name='person_edit'),
+    url(r'^persons/add/$', PersonCreate.as_view(), name='person_add'),
 
     url(r'^events/?$', views.all_events, name='all_events'),
     url(r'^event/(?P<event_slug>[\w\.-]+)/?$', views.event_details, name='event_details'),
diff --git a/workshops/views.py b/workshops/views.py
--- a/workshops/views.py
+++ b/workshops/views.py
@@ -125,6 +125,18 @@ def person_details(request, person_id):
                'person' : person}
     return render(request, 'workshops/person.html', context)
 
+
+class PersonCreate(CreateView):
+    model = Person
+    fields = '__all__'
+
+
+class PersonUpdate(UpdateView):
+    model = Person
+    fields = '__all__'
+    pk_url_kwarg = 'person_id'
+
+
 #------------------------------------------------------------
 
 def all_events(request):


Test patch:
Repository: carpentries/amy

Issue:
Display of persons should show what badges they have and how often they've taught/helped/hosted
The inline display of a person's information in the "all persons" page, and the display on the "show single person" page, should both show what badges that person has (if any) and how often they have been an instructor or helper.

The display of how often they've instructed/helped should somehow link to the workshops they've taught at or helped at.



Discussion:

Resolving patch:
diff --git a/workshops/views.py b/workshops/views.py
--- a/workshops/views.py
+++ b/workshops/views.py
@@ -102,22 +102,23 @@ def all_persons(request):
 def person_details(request, person_id):
     '''List details of a particular person.'''
     person = Person.objects.get(id=person_id)
+    awards = Award.objects.filter(person__id=person_id)
+    tasks = Task.objects.filter(person__id=person_id)
     context = {'title' : 'Person {0}'.format(person),
-               'person' : person}
+               'person' : person,
+               'awards' : awards,
+               'tasks' : tasks}
     return render(request, 'workshops/person.html', context)
 
-
 class PersonCreate(CreateView):
     model = Person
     fields = '__all__'
 
-
 class PersonUpdate(UpdateView):
     model = Person
     fields = '__all__'
     pk_url_kwarg = 'person_id'
 
-
 #------------------------------------------------------------
 
 def all_events(request):


Test patch:
Repository: carpentries/amy

Issue:
Add page displaying all badges
There should be a single page displaying all of the badges we award.



Discussion:

Resolving patch:
diff --git a/workshops/urls.py b/workshops/urls.py
--- a/workshops/urls.py
+++ b/workshops/urls.py
@@ -40,6 +40,9 @@
     url(r'^cohort/(?P<cohort_name>[\w\.-]+)/edit$', CohortUpdate.as_view(), name='cohort_edit'),
     url(r'^cohorts/add/$', CohortCreate.as_view(), name='cohort_add'),
 
+    url(r'^badges/?$', views.all_badges, name='all_badges'),
+    url(r'^badge/(?P<badge_name>[\w\.-]+)/?$', views.badge_details, name='badge_details'),
+
     url(r'^match/?$', views.match, name='match'),
 
     url(r'^export/(?P<name>[\w\.-]+)/?$', views.export, name='export'),
diff --git a/workshops/views.py b/workshops/views.py
--- a/workshops/views.py
+++ b/workshops/views.py
@@ -255,6 +255,30 @@ class CohortUpdate(UpdateView):
 
 #------------------------------------------------------------
 
+def all_badges(request):
+    '''List all badges.'''
+
+    all_badges = Badge.objects.order_by('name')
+    for b in all_badges:
+        b.num_awarded = Award.objects.filter(badge_id=b.id).count()
+    context = {'title' : 'All Badges',
+               'all_badges' : all_badges}
+    return render(request, 'workshops/all_badges.html', context)
+
+
+def badge_details(request, badge_name):
+    '''Show who has a particular badge.'''
+
+    badge = Badge.objects.get(name=badge_name)
+    all_awards = Award.objects.filter(badge_id=badge.id)
+    awards = _get_pagination_items(request, all_awards)
+    context = {'title' : 'Badge {0}'.format(badge.title),
+               'badge' : badge,
+               'all_awards' : awards}
+    return render(request, 'workshops/badge.html', context)
+
+#------------------------------------------------------------
+
 def match(request):
     '''Search for instructors.'''
 


Test patch:
Repository: carpentries/amy

Issue:
Cannot validate events, missing `check_file` function
I can't validate events, because `check_file` function is missing.

```
Environment:


Request Method: GET
Request URL: http://127.0.0.1:8000/workshops/event/2012-02-20-itcp/validate

Django Version: 1.7.1
Python Version: 2.7.9
Installed Applications:
('django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'workshops')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware')


Traceback:
File "/home/piotr/workspace/anaconda/envs/amy/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
  111.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/piotr/workspace/amy/workshops/views.py" in validate_event
  287.             valid, error_messages = check_file(page_url, response.text)

Exception Type: NameError at /workshops/event/2012-02-20-itcp/validate
Exception Value: global name 'check_file' is not defined
```



Discussion:
That might have been in @cudevmaxwell's original implementation?

I don't believe so. This is referring to this function, right?

https://github.com/swcarpentry/amy/blob/master/workshops/check.py#L364

OK, time to write a validation function :-)

Looks like from `from workshops.check import check_file`  is missing.


Resolving patch:
diff --git a/workshops/views.py b/workshops/views.py
--- a/workshops/views.py
+++ b/workshops/views.py
@@ -15,6 +15,8 @@
 from workshops.forms import SearchForm, InstructorsForm, PersonBulkAddForm
 from workshops.util import earth_distance
 
+from workshops.check import check_file
+
 from workshops.models import \
     Airport, \
     Award, \


Test patch: