internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: google-deepmind/dm-haiku

Issue:
Jax version upgrade (AttributeError: CallPrimitive)
Using the current version of master 66f9c69 of Haiku, I am getting the following error on Colab
```
AttributeError                            Traceback (most recent call last)
<ipython-input-3-3a9e6adbfff5> in <module>()
----> 1 import haiku as hk

/usr/local/lib/python3.6/dist-packages/haiku/__init__.py in <module>()
     17 
     18 from haiku import data_structures
---> 19 from haiku import experimental
     20 from haiku import initializers
     21 from haiku import nets

/usr/local/lib/python3.6/dist-packages/haiku/experimental.py in <module>()
     22 from haiku._src.base import custom_getter
     23 from haiku._src.base import ParamContext
---> 24 from haiku._src.dot import to_dot
     25 from haiku._src.lift import lift
     26 from haiku._src.module import profiler_name_scopes

/usr/local/lib/python3.6/dist-packages/haiku/_src/dot.py in <module>()
     23 
     24 from haiku._src import data_structures
---> 25 from haiku._src import module
     26 from haiku._src import utils
     27 import jax

/usr/local/lib/python3.6/dist-packages/haiku/_src/module.py in <module>()
     26 from haiku._src import base
     27 from haiku._src import data_structures
---> 28 from haiku._src import named_call
     29 from haiku._src import utils
     30 import jax.numpy as jnp

/usr/local/lib/python3.6/dist-packages/haiku/_src/named_call.py in <module>()
     29 
     30 # Registering named call as a primitive
---> 31 named_call_p = core.CallPrimitive('named_call')
     32 # named_call is implemented as a plain core.call and only diverges
     33 # under compilation (see named_call_translation_rule)

AttributeError: module 'jax.core' has no attribute 'CallPrimitive'
```

I believe that's because Haiku now requires `jax>=0.1.71`, while the version by default on Colab is `jax==0.1.69`. `CallPrimitive` was introduced in jax 0.1.71.
https://github.com/google/jax/blob/1545a29e6d69a7b3c7fdf9a49b38004759a9fbfa/jax/core.py#L1106-L1115

To reproduce (inside a Colab):
```python
import jax
print(jax.__version__)  # 0.1.69

!pip install -q git+https://github.com/deepmind/dm-haiku
import haiku as hk
```

Run `!pip install -q --upgrade jax jaxlib` first in your Colab to fix this issue.


Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -37,8 +37,8 @@ def _parse_requirements(requirements_txt_path):
 _VERSION = _get_version()
 
 EXTRA_PACKAGES = {
-    'jax': ['jax>=0.1.55'],
-    'jaxlib': ['jaxlib>=0.1.37'],
+    'jax': ['jax>=0.1.71'],
+    'jaxlib': ['jaxlib>=0.1.49'],
 }
 
 setup(


Test patch:
Repository: google-deepmind/dm-haiku

Issue:
hk.without_apply_rng changes function type Transformed -> TransformedWithState
`hk.without_apply_rng` returns a `TransformedWithState` object irrespective of the input type.

```python
import haiku as hk

def f():
  w = hk.get_parameter("w", [], init=jnp.zeros)
  return w

g = hk.without_apply_rng(hk.transform(f))

assert isinstance(f, hk.Transformed)  # ok
assert isinstance(g, hk.Transformed)  # fails
```


Discussion:

Resolving patch:
diff --git a/haiku/_src/transform.py b/haiku/_src/transform.py
--- a/haiku/_src/transform.py
+++ b/haiku/_src/transform.py
@@ -150,19 +150,20 @@ def check_rng_kwarg(kwargs):
     def apply_fn(params, state, *args, **kwargs):
       check_rng_kwarg(kwargs)
       return f.apply(params, state, None, *args, **kwargs)
+    f_new = TransformedWithState(init=f.init, apply=apply_fn)
 
   elif isinstance(f, Transformed):
     def apply_fn(params, *args, **kwargs):
       check_rng_kwarg(kwargs)
       return f.apply(params, None, *args, **kwargs)
+    f_new = Transformed(init=f.init, apply=apply_fn)
 
   else:
     raise ValueError("Must be called with the result of `hk.transformed` or "
                      f"`hk.transformed_with_state`, actual {type(f)}")
 
-  tie_in_original_fn(f, f.init, apply_fn)
-
-  return TransformedWithState(init=f.init, apply=apply_fn)
+  tie_in_original_fn(f, f_new.init, f_new.apply)
+  return f_new
 
 
 # TODO(tomhennigan) Remove apply_rng.


Test patch:
diff --git a/haiku/_src/transform_test.py b/haiku/_src/transform_test.py
--- a/haiku/_src/transform_test.py
+++ b/haiku/_src/transform_test.py
@@ -364,6 +364,17 @@ def with_decorator():
     self.assertNotEqual(without_decorator_out, expected_output)
     self.assertEqual(with_decorator_out, expected_output)
 
+  def test_without_apply_rng_output_type(self):
+    def f():
+      w = base.get_parameter("w", [], init=jnp.zeros)
+      return w
+
+    f = transform.without_apply_rng(transform.transform_with_state(f))
+    self.assertIsInstance(f, transform.TransformedWithState)
+
+    f = transform.without_apply_rng(transform.transform(f))
+    self.assertIsInstance(f, transform.Transformed)
+
   def test_new_context(self):
     with base.new_context() as ctx:
       pass
Repository: google-deepmind/dm-haiku

Issue:
Examples are distributed as part of the package
Hi, 

I think the examples are folder are currently packaged as part of the package on PyPI. This means that installing haiku will also install the examples as the package `examples`. Should these be excluded from the distribution?

JAX also has examples in their repo, but those are excluded from packaging in 

https://github.com/google/jax/blob/main/setup.py#L33




Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -51,7 +51,7 @@ def _parse_requirements(requirements_txt_path):
     long_description_content_type='text/markdown',
     author_email='haiku-dev-os@google.com',
     # Contained modules and scripts.
-    packages=find_namespace_packages(exclude=['*_test.py']),
+    packages=find_namespace_packages(exclude=['*_test.py', 'examples']),
     install_requires=_parse_requirements('requirements.txt'),
     extras_require=EXTRA_PACKAGES,
     tests_require=_parse_requirements('requirements-test.txt'),


Test patch:
Repository: google-deepmind/dm-haiku

Issue:
suggestion: remove if-statements from dropout layer
Due to the rate check, it's not possible to modify the rate parameter dynamically without recompiling the entire graph. 
https://github.com/deepmind/dm-haiku/blob/main/haiku/_src/basic.py#L316
 ```python
 if rate < 0 or rate >= 1:
    raise ValueError("rate must be in [0, 1).")

  if rate == 0.0:
    return x
```


Discussion:

Resolving patch:
diff --git a/haiku/_src/basic.py b/haiku/_src/basic.py
--- a/haiku/_src/basic.py
+++ b/haiku/_src/basic.py
@@ -313,11 +313,14 @@ def dropout(rng: PRNGKey, rate: float, x: jnp.ndarray) -> jnp.ndarray:
     than what applications require. A work-around is to pass `rate` with a lower
     precision, e.g. using `np.float16(rate)`.
   """
-  if rate < 0 or rate >= 1:
-    raise ValueError("rate must be in [0, 1).")
-
-  if rate == 0.0:
-    return x
+  try:
+    if rate < 0 or rate >= 1:
+      raise ValueError("rate must be in [0, 1).")
+
+    if rate == 0.0:
+      return x
+  except jax.errors.ConcretizationTypeError:
+    pass
 
   keep_rate = 1.0 - rate
   keep = jax.random.bernoulli(rng, keep_rate, shape=x.shape)


Test patch:
diff --git a/haiku/_src/basic_test.py b/haiku/_src/basic_test.py
--- a/haiku/_src/basic_test.py
+++ b/haiku/_src/basic_test.py
@@ -71,6 +71,10 @@ def test_sequential(self):
   def test_dropout_connects(self):
     basic.dropout(base.next_rng_key(), 0.25, jnp.ones([3, 3]))
 
+  @test_utils.transform_and_run
+  def test_dropout_dynamic_range(self):
+    jax.jit(basic.dropout)(base.next_rng_key(), 0.25, jnp.ones([3, 3]))
+
   def test_batchapply(self):
 
     def raises(a, b):
Repository: google-deepmind/dm-haiku

Issue:
Throw better error when `split_rng` is True in `hk.vmap` at init time
ref: https://github.com/google/jax/discussions/11297

Because `hk.vmap` sets `out_axes` to `None` for parameters, we can't ever `split_rng` at init time. 

Currently we get this JAX error:
```
ValueError: vmap has mapped output but out_axes is None
```
but I think we can just throw an error whenever you split_rng at init time.


Discussion:

Resolving patch:
diff --git a/haiku/_src/stateful.py b/haiku/_src/stateful.py
--- a/haiku/_src/stateful.py
+++ b/haiku/_src/stateful.py
@@ -814,7 +814,19 @@ def mapped_fun(*args):
       saved_rng = state.rng
       state = InternalState(state.params, state.state, rng)
 
-    out, state = mapped_pure_fun(args, state)
+    try:
+      out, state = mapped_pure_fun(args, state)
+    except ValueError as err:
+      if "out_axes" in str(err):
+        # TODO(lenamartens): add error for state too.
+        raise ValueError("hk.vmap does not support setting split_rng to True "
+                         "during initialization because it assumes parameters "
+                         "are always shared along the mapped dimension. "
+                         "Consider switching the value of `split_rng` to False "
+                         "during initialization through `hk.running_init()`."
+                         ) from err
+      else:
+        raise err
 
     if split_rng:
       state = InternalState(state.params, state.state, saved_rng)


Test patch:
diff --git a/haiku/_src/stateful_test.py b/haiku/_src/stateful_test.py
--- a/haiku/_src/stateful_test.py
+++ b/haiku/_src/stateful_test.py
@@ -21,6 +21,7 @@
 from absl.testing import parameterized
 from haiku._src import base
 from haiku._src import base_test
+from haiku._src import initializers
 from haiku._src import module
 from haiku._src import stateful
 from haiku._src import test_utils
@@ -619,6 +620,18 @@ def test_vmap_split_rng(self):
           np.array_equal(a, b),
           msg=f"Keys should not be equal, but {a_name} == {b_name}")
 
+  @test_utils.transform_and_run(run_apply=False)
+  def test_vmap_split_rng_better_out_axes_error(self):
+    def creates_params(_):
+      base.get_parameter("mapped",
+                         (), jnp.float32,
+                         init=initializers.TruncatedNormal())
+    f = stateful.vmap(creates_params, split_rng=True)
+    x = jnp.arange(4)
+    with self.assertRaisesRegex(ValueError,
+                                "split_rng to True during initialization"):
+      f(x)
+
   def test_while_loop_rejected_in_init(self):
     def f():
       stateful.while_loop(lambda x: x.all(), lambda x: not x, 1)
Repository: dpgmediamagazines/django-arctic

Issue:
partial base_data_table.html is used by inline list views but its outdated.
Please let listview use this partial, so when there are updates (e.g. functionality for column_list) the inline listview is also updated.



Discussion:

Resolving patch:
diff --git a/arctic/generics.py b/arctic/generics.py
--- a/arctic/generics.py
+++ b/arctic/generics.py
@@ -165,7 +165,6 @@ def ordering_url(self, field):
 
         return (path + '?' + query_params.urlencode(safe=','), direction)
 
-
     def get_list_display(self):
         """
         Creates a list of dictionaries with the field names, labels,
@@ -186,22 +185,22 @@ def get_list_display(self):
                 item = {}
                 if isinstance(field_name, tuple):
                     # custom property that is not a field of the model
-                    item['name'] = prefix + field_name[0]
+                    name = field_name[0]
                     item['label'] = field_name[1]
                 else:
-                    item['name'] = prefix + field_name
+                    name = field_name
                     item['label'] = model._meta.get_field(field_name).verbose_name
-                if item['name'] in self.column_links.keys():
-                    item['column_link'] = self.column_links[item['name']]
-                if item['name'] in self.column_widgets.keys():
-                    item['widget'] = self.column_widgets[item['name']]
+                item['name'] = prefix + name
+                if name in self.column_links.keys():
+                    item['column_link'] = self.column_links[name]
+                if name in self.column_widgets.keys():
+                    item['widget'] = self.column_widgets[name]
                 if item['name'] in self.ordering_fields:
                     item['order_url'], item['order_direction'] = self.ordering_url(item['name'])
                 result.append(item)
 
         return result
 
-
     def get_list_items(self, objects):
         items = []
         if not self.list_display:


Test patch:
Repository: dpgmediamagazines/django-arctic

Issue:
ListView: keep all tool links in single dropdown 
Currently, if I have multiple tool links, e.g.:

tool_links = [
        ('Create admin', 'adminpanel:add_staff_user'),
        ('Create advertiser', 'adminpanel:add_user')
    ]

in the template it displayed as two duplicated items:
![arctic_bug_printscreen](https://cloud.githubusercontent.com/assets/3986031/19804081/d682588c-9d14-11e6-8099-e6a86e5ebbb9.png)



Discussion:

Resolving patch:
diff --git a/arctic/generics.py b/arctic/generics.py
--- a/arctic/generics.py
+++ b/arctic/generics.py
@@ -210,6 +210,7 @@ class ListView(View, base.ListView):
     action_links = []  # "Action" links on item level. For example "Edit"
     field_links = {}
     field_classes = {}
+    tool_links_icon = 'fa-wrench'
     tool_links = []   # Global links. For Example "Add object"
     prefix = ''  # Prefix for embedding multiple list views in detail view
 
@@ -414,6 +415,9 @@ def get_tool_links(self):
                                            'icon': icon})
             return allowed_tool_links
 
+    def get_tool_links_icon(self):
+        return self.tool_links_icon
+
     def get_prefix(self):
         return self.prefix + '-' if self.prefix else ''
 
@@ -475,6 +479,7 @@ def get_context_data(self, **kwargs):
         context['list_items'] = self.get_list_items(context['object_list'])
         context['action_links'] = self.get_action_links()
         context['tool_links'] = self.get_tool_links()
+        context['tool_links_icon'] = self.get_tool_links_icon()
         if self.filter_fields or self.search_fields:
             context['has_filter'] = True
             context['filter'] = self.filterset


Test patch:
Repository: dpgmediamagazines/django-arctic

Issue:
Allow custom username field(not only `username`) in users application
Currently model should have both `username` and `email` fields to work properly with all functionality inside `users` part of arctic. 
It might not be handy in certain cases(for instance when model consist only from `email` field that acts as USERNAME_FIELD)



Discussion:

Resolving patch:
diff --git a/arctic/users/forms.py b/arctic/users/forms.py
--- a/arctic/users/forms.py
+++ b/arctic/users/forms.py
@@ -12,6 +12,12 @@
 User = get_user_model()
 UserRole = get_user_role_model()
 
+# it would be even nicer to raise an error here to explicitly
+# ask user to set these properties but we need backwards compatibility
+DEFAULT_FIELDS = (User.USERNAME_FIELD, 'email', 'is_active')
+FIELDS_CREATE = getattr(User, 'FIELDS_CREATE', DEFAULT_FIELDS)
+FIELDS_UPDATE = getattr(User, 'FIELDS_UPDATE', DEFAULT_FIELDS)
+
 
 class UserRoleForm(forms.ModelForm):
     class Meta:
@@ -22,7 +28,7 @@ class Meta:
 class UserCreationForm(user_forms.UserCreationForm):
     class Meta:
         model = User
-        fields = ('username', 'email', 'is_active',)
+        fields = FIELDS_CREATE
 
 
 class UserCreationMultiForm(MultiModelForm):
@@ -55,7 +61,7 @@ class UserChangeForm(forms.ModelForm):
 
     class Meta:
         model = User
-        fields = ('username', 'email', 'is_active',)
+        fields = FIELDS_UPDATE
 
     def save(self, commit=True):
         user = super(UserChangeForm, self).save(commit=False)
diff --git a/arctic/users/views.py b/arctic/users/views.py
--- a/arctic/users/views.py
+++ b/arctic/users/views.py
@@ -9,22 +9,26 @@
 
 User = get_user_model()
 UserRole = get_user_role_model()
+username_field = User.USERNAME_FIELD
 
 
 class UserListView(ListView):
     page_title = _('Users')
     paginate_by = 20
     model = UserRole
-    fields = [('user__username', 'Username'), 'role__name', 'user__is_active',
-              'user__last_login']
-    ordering_fields = ['user__username', 'role__name', 'user__last_login']
-    search_fields = ['user__username']
+    fields = [('user__{}'.format(username_field), 'Username'),
+              'role__name', 'user__is_active', 'user__last_login']
+
+    ordering_fields = ['user__{}'.format(username_field),
+                       'role__name', 'user__last_login']
+
+    search_fields = ['user__{}'.format(username_field)]
     filter_fields = ['user__is_active']
     # action_links = [
     #     ('delete', 'users:delete', 'fa-trash'),
     # ]
     field_links = {
-        'user__username': 'users:detail',
+        'user__{}'.format(username_field): 'users:detail',
     }
     tool_links = [
         (_('Create Users'), 'users:create', 'fa-plus'),


Test patch:
Repository: dpgmediamagazines/django-arctic

Issue:
support for django 1.10
The current install doesn't work with django 1.10 as django-extra-views is lacking support for django 1.10 at the moment. 

We currently use a install from github/sanoma/django-extra-views, however because django arctic has still django-extra-views 0.7.1 as requirement our deployment process overwrites it. 




Discussion:
The current master branch of django-extra-views supports Django 1.10, so we can pin the current master on the requirements until a proper version is released on PyPI
check, but bear in mind that setup.py currently reads requirements/base.txt for it requirements. setup.py doesn't allow pinning of commits like we use to do in requirement files (It need to be in dependency_links). 

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -10,6 +10,11 @@
 
 try:
     REQUIREMENTS = open('requirements/base.txt').read()
+    # setup.py does not accept link dependencies mixed with PyPI ones, so
+    # the django-extra-views package name and its github link are setup here,
+    # another reference is kept in requirements/test.txt. When a new version
+    # of django-extra-views is released this setup can be simplified.
+    REQUIREMENTS += '\ndjango-extra-views==0.8.0'
 except:
     REQUIREMENTS = None
 
@@ -29,13 +34,17 @@
         'Programming Language :: Python :: 2.7',
         'Programming Language :: Python :: 3',
         'Programming Language :: Python :: 3.3',
-        'Programming Language :: Python :: 3.4',
         'Programming Language :: Python :: 3.5',
+        'Programming Language :: Python :: 3.6',
     ],
 
     version=__VERSION__,
     long_description=README,
     install_requires=REQUIREMENTS,
+    dependency_links=['https://github.com/AndrewIngram/' +\
+                      'django-extra-views/tarball/' +\
+                      'dd5d6b877945eeca6ee04930a7fa441e66a586b0' +\
+                      '#egg=django-extra-views-0.8.0'],
     packages=find_packages(),
     include_package_data=True,
     license='MIT',


Test patch:
diff --git a/requirements/test.txt b/requirements/test.txt
--- a/requirements/test.txt
+++ b/requirements/test.txt
@@ -1,4 +1,10 @@
 -r base.txt
+# setup.py does not accept link dependencies mixed with PyPI ones, so 
+# django-extra-views is kept here for testing purposes, and another reference 
+# in setup.py. When a new version of django-extra-views is released this setup
+# can be simplified.
+https://github.com/AndrewIngram/django-extra-views/tarball/dd5d6b877945eeca6ee04930a7fa441e66a586b0#egg=django-extra-views-0.8.0
+
 pytest==3.0.6
 pytest-cov==2.4.0
 pytest-django==3.1.2
Repository: dpgmediamagazines/django-arctic

Issue:
Fix float labels for some field types
Currently float labels are breaking visually for the following field types:

- Styled dropdown (works good for multi select)
- Disabled text input
- Numeric Input
- File upload Input

It could be useful to change the dashboard to display all possible fields with float labels so it's easy to check them.


Discussion:

Resolving patch:
diff --git a/example/config/arctic.py b/example/config/arctic.py
--- a/example/config/arctic.py
+++ b/example/config/arctic.py
@@ -1,5 +1,5 @@
 ARCTIC_SITE_NAME = 'Arctic Example'
-ARCTIC_FORM_DISPLAY = 'stacked'
+ARCTIC_FORM_DISPLAY = 'float-label'
 
 # Menu format:
 # (('menu label', 'named url', 'optional icon class',


Test patch:
Repository: dpgmediamagazines/django-arctic

Issue:
Problem with reversing url for action button if `submit` or `cancel` buttons only
Now we're not able to specify url for submit button with object id. 
`form_action` is expected only for other type of button (not submit), so while it's parsing for submit button `obj` is not assigned yet, what throws error.  


Discussion:

Resolving patch:
diff --git a/arctic/mixins.py b/arctic/mixins.py
--- a/arctic/mixins.py
+++ b/arctic/mixins.py
@@ -165,6 +165,11 @@ def get_actions(self):  # noqa: C901
 
         allowed_actions = []
         last_submit_index = -1
+        try:
+            obj = self.get_object()
+        except AttributeError:
+            obj = None
+
         for action in self.actions:
             # check permission based on named_url
             if (action[1] in ("cancel", "submit")) or view_from_url(
@@ -193,9 +198,6 @@ def get_actions(self):  # noqa: C901
                         obj = self.get_object()
                     except AttributeError:
                         obj = None
-                    allowed_action["url"] = self.in_modal(
-                        reverse_url(action[1], obj)
-                    )
                 if len(action) == 3:
                     if action[2] == "left":
                         allowed_action["position"] = "left"


Test patch:
Repository: dpgmediamagazines/django-arctic

Issue:
Confirmation dialog title shows gibberish instead of object name
In case of delete confirmation string representation of View class is shown instead of the object being deleted:

![afbeelding](https://user-images.githubusercontent.com/400638/49448141-8b7cab00-f7d8-11e8-92e8-b88c08410c9d.png)



Discussion:

Resolving patch:
diff --git a/arctic/mixins.py b/arctic/mixins.py
--- a/arctic/mixins.py
+++ b/arctic/mixins.py
@@ -191,7 +191,7 @@ def get_actions(self):  # noqa: C901
                         view_from_url(action[1]), action[1]
                     )
                     allowed_action["modal"] = self.get_modal_link(
-                        action[1], self
+                        action[1], obj
                     )
                     allowed_action["type"] = "link"
                     allowed_action["url"] = self.in_modal(


Test patch:
Repository: dpgmediamagazines/django-arctic

Issue:
DeletionMixin response
now it has following implementation:  
```    
def delete(self, request, *args, **kwargs):
        self.object = self.get_object()
        if Article.objects.pending().filter(pk=self.object.pk).exists():
            self.success_url = reverse_lazy('articles:pending-list')
        success_url = self.get_success_url()
        self.object.delete()
        return HttpResponseRedirect(success_url)
```

and in `def get(self, request, *args, **kwargs):` method it has: 

```        
if can_delete and self.redirect:
            messages.success(request, self.get_success_message(self.object))
            self.delete(request, *args, **kwargs)
            return redirect(self.get_success_url())
```

Normally, if ”delete” method return HttpResponse – it should be also returned by ”get”method, not generating it’s own response.  


Discussion:

Resolving patch:
diff --git a/arctic/generics.py b/arctic/generics.py
--- a/arctic/generics.py
+++ b/arctic/generics.py
@@ -873,8 +873,7 @@ def get(self, request, *args, **kwargs):
 
         if can_delete and self.redirect:
             messages.success(request, self.get_success_message(self.object))
-            self.delete(request, *args, **kwargs)
-            return redirect(self.get_success_url())
+            return self.delete(request, *args, **kwargs)
 
         context = self.get_context_data(
             object=self.object,


Test patch: