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

Issue:
Allow `get_focus_previous` with `numlock` enabled
**Is your feature request related to a problem? Please describe.**
When `numlock` is enabled, `shift+tab` doesn't call `get_focus_previous` for widgets inheriting `FocusBehavior`

**Describe the solution you'd like**
Change this:
https://github.com/kivy/kivy/blob/ed68be56e4d580b00abd8f89705339e824c3b43d/kivy/uix/behaviors/focus.py#L534-L535
to:
```python
if 'shift' in modifiers:
    next = self.get_focus_previous()
```
or if `ctrl+shift+tab` is undesired:
```python
if 'shift' in modifiers and 'ctrl' not in modifiers:
    next = self.get_focus_previous()
```

If the devs approve, I'll submit a pull request



Discussion:
That sounds like a fine change indeed, refusing ctrl-shift-tab seems a bit arbitrary, so i would go for the first version, but i don't have a hard opinion either way.

Resolving patch:
diff --git a/kivy/uix/behaviors/focus.py b/kivy/uix/behaviors/focus.py
--- a/kivy/uix/behaviors/focus.py
+++ b/kivy/uix/behaviors/focus.py
@@ -531,7 +531,9 @@ def keyboard_on_key_down(self, window, keycode, text, modifiers):
         key was consumed.
         '''
         if keycode[1] == 'tab':  # deal with cycle
-            if ['shift'] == modifiers:
+            if {'ctrl', 'alt', 'meta', 'super', 'compose'} & modifiers:
+                return False
+            if 'shift' in modifiers:
                 next = self.get_focus_previous()
             else:
                 next = self.get_focus_next()


Test patch:
Repository: kivy/kivy

Issue:
Dropdown opening from data item in RecycleView is jumping down at refresh of RV-data/-layout
**Software Versions**
* Python: 3.6.9
* OS: Ubuntu 18.04
* Kivy: 2.0.0
* Kivy installation method: pip

A `Dropdown` attached to a `data` item of a `RecycleView` (RV) is jumping down and up if `data` of the `RecycleView` gets updated/refreshed.

**Expected behavior**
The `Dropdown` `y` position should not be recalculated if the `parent` of the item widget where the `Dropdown` is attached is `None`.

**To Reproduce**
Create a `RecycleView` with `Button` items, which are displaying a `Dropdown` when the user clicks on the `Button` item. Create a `Clock` timer to periodically update the `data` property of the RV. Now click on an item to open the `Dropdown`. Now you can see that the `Dropdown` is not staying fixed under the attaching item/button-widget - instead, it is jumping down and up again every time the `data` gets updated.

**Code and Logs and screenshots**

![RV_Dropdown_repos_bug_gimp_opti](https://user-images.githubusercontent.com/3755886/108263573-5d3bd980-715e-11eb-871b-376f32415a28.gif)

As you can see in the animation above, the `y` position of the item gets wrongly calculated if `parent` is `None`.

For to workaround overwrite the `_reposition` method of the `Dropdown` widget to prevent the recalculation of the `y` position if the `parent` is None:

```python
    def _reposition(self, *largs):
        if self.attach_to and not self.attach_to.parent:
            return
        super()._reposition(*largs)
```

**Additional context**
On refresh of RV's `data` property, the items will temporarily be removed from the RV, which sets the `parent` property of the item to `None`. This breaks the calculation of the item screen position (not adding the y-offset of the `ScrollView`) and the `Dropdown` is jumping down. As soon as the `parent` of the item is getting reset, the screen position gets calculated again and the `Dropdown` is jumping back up (to its original/correct position, underneath the attaching item).

I will create PR to fix this within `Dropdown._reposition`.



Discussion:

Resolving patch:
diff --git a/kivy/uix/dropdown.py b/kivy/uix/dropdown.py
--- a/kivy/uix/dropdown.py
+++ b/kivy/uix/dropdown.py
@@ -321,7 +321,7 @@ def _reposition(self, *largs):
         # coordinate system
         win = self._win
         widget = self.attach_to
-        if not widget or not win:
+        if not widget or not widget.parent or not win:
             return
         wx, wy = widget.to_window(*widget.pos)
         wright, wtop = widget.to_window(widget.right, widget.top)


Test patch:
Repository: kivy/kivy

Issue:
kivy.uix.Video._on_eos might be called after unoad.
**Software Versions**
* Python: 3.7
* OS: linux
* Kivy: 2.0.0
* Kivy installation method: pip

**Describe the bug**
When using ffpyplayer based video implementation, it's possible that ``eos`` gets set from frame fetching thread after the video has been unload, which results in an ``AttributeError``, since ``self._video`` gets set to ``None`` in ``kivy.uix.Video.unload``.

**Proposed fix**
Add additional check whether ``self._video`` is set in ``_do_eos`` (https://github.com/kivy/kivy/blob/master/kivy/uix/video.py#L260)

```python
    def _on_eos(self, *largs):
        if not self._video or self._video.eos != 'loop':
            self.state = 'stop'
            self.eos = True
```

Any objections? Otherwise i'd create a PR for this.


Discussion:
Yeah, that seems to make sense.

Resolving patch:
diff --git a/kivy/uix/video.py b/kivy/uix/video.py
--- a/kivy/uix/video.py
+++ b/kivy/uix/video.py
@@ -257,7 +257,7 @@ def _on_video_frame(self, *largs):
         self.canvas.ask_update()
 
     def _on_eos(self, *largs):
-        if self._video.eos != 'loop':
+        if not self._video or self._video.eos != 'loop':
             self.state = 'stop'
             self.eos = True
 


Test patch:
Repository: kivy/kivy

Issue:
ScrollView effect_cls bug
**Software Versions**
* Python: 3.9.7
* OS: Win 10
* Kivy: v2.0.0
* Kivy installation method: pip

**Describe the bug**
I have a ScrollView with ScrollEffect and a simple BoxLayout on it, but if I try to scroll and resize later, the BoxLayout scrolls down regardless of whether it has like or not.
I showed this in a video I posted on youtube (not listed):
 - https://youtu.be/j3qYRGJ2BI8

**Expected behavior**
BoxLayout couldn't do this, I want it to be at the top of the screen when I resize the window.

**To Reproduce**
```
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.button import Button

KV = """
<BugScroll>:
    ScrollView:
        effect_cls:'ScrollEffect'
        BoxLayout:
            size_hint_y:None
            height:self.minimum_height
            orientation:'vertical'
            id:box
"""
Builder.load_string(KV)

class BugScroll(BoxLayout):
    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        for i in range(100):
            self.ids.box.add_widget(Button(size_hint_y=None, height=55, text=str(i)))

class Program(App):
    def build(self):
        return BugScroll()

if __name__ == '__main__':
    Program().run()

```


Discussion:

Resolving patch:
diff --git a/kivy/effects/scroll.py b/kivy/effects/scroll.py
--- a/kivy/effects/scroll.py
+++ b/kivy/effects/scroll.py
@@ -19,6 +19,7 @@ class as a base effect for our :class:`~kivy.uix.scrollview.ScrollView` widget.
 __all__ = ('ScrollEffect', )
 
 
+from time import time
 from kivy.effects.kinetic import KineticEffect
 from kivy.uix.widget import Widget
 from kivy.properties import NumericProperty, ObjectProperty
@@ -91,7 +92,7 @@ def reset(self, pos):
         self.velocity = 0
         if self.history:
             val = self.history[-1][1]
-            super(ScrollEffect, self).start(val, None)
+            self.history = [(time(), val)]
 
     def on_value(self, *args):
         scroll_min = self.min


Test patch:
Repository: kivy/kivy

Issue:
Setup Platform Override for Raspberry Pi CI Builds
**Is your feature request related to a problem? Please describe.**

The Raspberry Pi support is only enabled if `setup.py` detects it's running on a Raspberry Pi via the `/opt/vc/include/bcm_host.h` file, but then goes on to check the `/proc/cpuinfo` to identify that it's not running on a Raspberry Pi 4 hardware. That is fair enough, but does not detect correctly in the `pi-gen` environment as the CPU is not a Raspberry Pi.

There is the flag / env variable `use_rpi`/`USE_RPI`, which can be used to force cythonization of the `egl` and `bcm` modules, but the compilation fails, as the [setup.py:631-663](https://github.com/kivy/kivy/blob/master/setup.py#L631-L663) requires `platform` to be set to `rpi` and ignores `use_rpi`.

**Describe the solution you'd like**
Allow overriding the `platform` in setup.py via ENV variable, or include a check for `use_rpi`, so the compilation works.

There should be a warning in the Docs that the Raspberry Pi version with `egl_rpi` support _must_ be compiled locally on a Raspberry Pi at the moment.
If the solution as described above is implemented, the docs could instead mention to use the override flag for a QEMU enabled CI build.

**Describe alternatives you've considered**

* Building on the Raspberry Pi was the originally foreseen use case for this, but is not practical for creating a pre-built image.
* I could prebuild Kivy on a Raspberry Pi and copy the build outputs over / put them in a repo somewhere and use them from there.

I will try the above suggestion and submit a pull request.

**Additional context**
I am trying to build a Raspberry Pi image based on the raspberrypi/pi-gen toolchain. The image is built in a container on some x64 server using QEMU's emulation for ARM processors in order to build a disk image for a Raspberry Pi. This is what is also used for building the official Raspbian / RaspberryOS images.

Installing `kivy[base]` as wheel comes without `egl_rpi` python prebuilts, so I can't use it for my current use case.



Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -112,9 +112,13 @@ def get_isolated_env_paths():
     platform = 'ios'
 # proprietary broadcom video core drivers
 if exists('/opt/vc/include/bcm_host.h'):
+    used_pi_version = pi_version
+    # Force detected Raspberry Pi version for cross-builds, if needed
+    if 'KIVY_RPI_VERSION' in environ:
+        used_pi_version = int(environ['KIVY_RPI_VERSION'])
     # The proprietary broadcom video core drivers are not available on the
     # Raspberry Pi 4
-    if (pi_version or 4) < 4:
+    if (used_pi_version or 4) < 4:
         platform = 'rpi'
 # use mesa video core drivers
 if environ.get('VIDEOCOREMESA', None) == '1':


Test patch:
Repository: kivy/kivy

Issue:
ScrollView and RecycleView difference
Hello, could you put a disclaimer on the page with ScrollView that it is not optimized for big data and point to RecycleView (**I spent about 10 hours to figure out why my application in .apk had 4 fps**)
I hope this helps someone


Discussion:

Resolving patch:
diff --git a/kivy/uix/scrollview.py b/kivy/uix/scrollview.py
--- a/kivy/uix/scrollview.py
+++ b/kivy/uix/scrollview.py
@@ -7,6 +7,10 @@
 The :class:`ScrollView` widget provides a scrollable/pannable viewport that is
 clipped at the scrollview's bounding box.
 
+.. note::
+    Use :class:`~kivy.uix.recycleview.RecycleView` for generating large
+    numbers of widgets in order to display many data items.
+
 
 Scrolling Behavior
 ------------------


Test patch:
Repository: kivy/kivy

Issue:
Extra position in undo list after all? 'shifted' characters.
**Software Versions**
* Python: 3.7.3
* OS: Linux Fedora 30
* Kivy: 2.1.0
* Kivy installation method: rpm

**Describe the bug**
In TextInput after write letters using `shift` I get extra position in undo list with empty ('delsel', cIdx, '')
cIdx - is cursor index that same as letter write with shift. So after is ('insert', cIdx, cIdx+1)
''       - empty string

The effect: `ctrl+z` have to be press twice. Second just move cursor.

**Expected behavior**
Only one position in undo list like other letters.

**To Reproduce**
from kivy.app import runTouchApp
from kivy.uix.textinput import TextInput

koTxt=TextInput(text = 'sdfdsf dfg ds fdsf gffg fdg fgf dgdsfds\nasfds fdgf gfd gfd af sfds',size_hint=(1,1))

runTouchApp(koTxt)
quit()

**Code and Logs and screenshots**
{'undo_command': ('delsel', 13, ''), 'redo_command': (13, 13)}
{'undo_command': ('insert', 13, 14), 'redo_command': (13, '*')}



Discussion:
Can I take up this issue?
Hi.
Are you asking me?
Sorry I am new on Git Hub. Do whatever is necessary.

Radek

Resolving patch:
diff --git a/kivy/uix/textinput.py b/kivy/uix/textinput.py
--- a/kivy/uix/textinput.py
+++ b/kivy/uix/textinput.py
@@ -1440,7 +1440,8 @@ def delete_selection(self, from_undo=False):
         self.scroll_x = scroll_x
         self.scroll_y = scroll_y
         # handle undo and redo for delete selection
-        self._set_unredo_delsel(a, b, text[a:b], from_undo)
+        if text[a:b]:
+            self._set_unredo_delsel(a, b, text[a:b], from_undo)
         self.cancel_selection()
         self.cursor = self.get_cursor_from_index(a)
 


Test patch:
Repository: kivy/kivy

Issue:
Markup [sup] followed by [sub] doesn't work
**Software Versions**
* Python: 3.10.6
* OS: Windows 10 
* Kivy: 2.1.0
* Kivy installation method: conda

**Describe the bug**
If you make a button with `button = Button(text='1[sup]2[/sup][sub]3[/sub]', markup=True)`, the 2 and 3 are both superscript.

![image](https://user-images.githubusercontent.com/58611/208555412-5a60d5e9-2cc8-4ef1-bb4b-fd3a2a066244.png)

With a space between them, it displays correctly:

![image](https://user-images.githubusercontent.com/58611/208555541-d933d739-84bf-4905-af8c-abe03236b4e7.png)


**Expected behavior**
It should display the 2 as superscript and the 3 as subscript

**To Reproduce**

```python
from kivy.app import App
from kivy.uix.button import Button

class MyApp(App):
    def build(self):
        button = Button(text= '1[sup]2[/sup][sub]3[/sub]', markup=True)
        return button

if __name__ == '__main__':
    MyApp().run()
```


Discussion:
Hi, I have looked into this and found it is related to the logic in *render_lines* of *markup.py*:

<img width="348" alt="image" src="https://github.com/kivy/kivy/assets/123660683/d6ed331e-2b7c-45d9-933c-d66ca570e02a">

When there is a space (or other "normal script" text) between `[\sup]` and `[sub]` (or `[\sub]` and `[sup]`), `psp` and `pph` "reset" 0 and `script_pos` is evaluated as expected.  Without the space, the values "carry over" and `script_pos` is the same for a subscript that "immediately" follows a superscript (no space) (and vice versa).

I would like to correct this bug, but before I make any changes, I have a couple of questions about this part of the code:
1. What do the variables `pph` and `psp` represent?  It appears to be something related to the sub-/superscript positions, but it's not clear what.
2. Why are they set at the end of the iteration such that the next iteration uses those values (if necessary)?  Removing these/setting to 0 at the start of each iteration seems to be the obvious fix, but I would want to understand the risks implicit in doing so.

Resolving patch:
diff --git a/kivy/core/text/markup.py b/kivy/core/text/markup.py
--- a/kivy/core/text/markup.py
+++ b/kivy/core/text/markup.py
@@ -484,12 +484,13 @@ def render_lines(self, lines, options, render_text, y, size):
                 wh = options['line_height'] * word.lh
                 # calculate sub/super script pos
                 if options['script'] == 'superscript':
-                    script_pos = max(0, psp if psp else self.get_descent())
+                    script_pos = max(0, psp if psp and (wh < pph)
+                                     else self.get_descent())
                     psp = script_pos
                     pph = wh
                 elif options['script'] == 'subscript':
                     script_pos = min(lh - wh, ((psp + pph) - wh)
-                                     if pph else (lh - wh))
+                                     if pph and (wh < pph) else (lh - wh))
                     pph = wh
                     psp = script_pos
                 else:


Test patch:
Repository: kivy/kivy

Issue:
Navigation drawer MDNavigationDrawerItem cursor pointing highlight at wrong position 
**Software Versions**
Environment:
Windows 10 22H2 Build 19045
Python 3.10.5
Kivy 2.2.1
KivyMD 1.2.0.dev0 from master branch

**Describe the bug**
Navigation drawer MDNavigationDrawerItem cursor pointing highlight at wrong position .

**Expected behavior**
cursor position should be correct

**To Reproduce**
check the attachment video


**Additional context**
[Please check the discussion here.](https://github.com/kivymd/KivyMD/issues/1549)

https://github.com/kivy/kivy/assets/16678329/4c7076fe-1bf7-4f1b-9c33-bd0fc0299f3b




Discussion:

Resolving patch:
diff --git a/kivy/core/window/window_sdl2.py b/kivy/core/window/window_sdl2.py
--- a/kivy/core/window/window_sdl2.py
+++ b/kivy/core/window/window_sdl2.py
@@ -397,6 +397,7 @@ def _update_density_and_dpi(self):
             try:
                 hwnd = windll.user32.GetActiveWindow()
                 self.dpi = float(windll.user32.GetDpiForWindow(hwnd))
+                self._density = self.dpi / 96
             except AttributeError:
                 pass
         else:


Test patch:
Repository: espnet/espnet

Issue:
merge_json behavior when no labels.
@kamo-naoyuki, I've found that there is a case when we don't have any label output in some utterances for the switchboard evaluation data (`rt03`). But current `data2json.sh` cannot allow such cases 
https://github.com/espnet/espnet/blob/master/utils/merge_scp2json.py#L210-L214
Can you relax this?
This check is good for the training data, but it excludes such utterances in the evaluation set, and makes the evaluation different from other benchmarks.


Discussion:

Resolving patch:
diff --git a/utils/merge_scp2json.py b/utils/merge_scp2json.py
--- a/utils/merge_scp2json.py
+++ b/utils/merge_scp2json.py
@@ -6,6 +6,7 @@
 
 import argparse
 import codecs
+from distutils.util import strtobool
 from io import open
 import json
 import logging
@@ -58,6 +59,9 @@ def shape(x):
                         help='The json files except for the input and outputs')
     parser.add_argument('--verbose', '-V', default=1, type=int,
                         help='Verbose option')
+    parser.add_argument('--allow-one-column', type=strtobool, default=False,
+                        help='Allow one column in input scp files. '
+                             'In this case, the value will be empty string.')
     parser.add_argument('--out', '-O', type=str,
                         help='The output filename. '
                              'If omitted, then output to sys.stdout')
@@ -162,7 +166,7 @@ def shape(x):
         for ls_list in (input_lines, output_lines, lines):
             for ls in ls_list:
                 for line in ls:
-                    if line == ''or first == '':
+                    if line == '' or first == '':
                         if line != first:
                             concat = sum(
                                 input_infos + output_infos + infos, [])
@@ -208,11 +212,16 @@ def shape(x):
                 for line, info in zip(line_list, info_list):
                     sps = line.split(None, 1)
                     if len(sps) < 2:
-                        raise RuntimeError(
-                            'Format error {}th line in {}: '
-                            ' Expecting "<key> <value>":\n>>> {}'
-                            .format(nutt, info[1], line))
-                    uttid, value = sps
+                        if not args.allow_one_column:
+                            raise RuntimeError(
+                                'Format error {}th line in {}: '
+                                ' Expecting "<key> <value>":\n>>> {}'
+                                .format(nutt, info[1], line))
+                        uttid = sps[0]
+                        value = ''
+                    else:
+                        uttid, value = sps
+
                     key = info[0]
                     type_func = info[2]
                     value = value.rstrip()


Test patch:
Repository: espnet/espnet

Issue:
matplotlib.use('Agg') fail
It result in plot fail 
```
_tkinter.TclError: no display name and no $DISPLAY environment variable
```
I fixed this by applying a patch on `espnet/nets/pytorch_backend/transformer/plot.py`
```
@@ -1,5 +1,6 @@
 import logging
-
+import matplotlib
+matplotlib.use('Agg')
 import matplotlib.pyplot as plt

 from espnet.asr import asr_utils
```


Discussion:
Oh yes, it's better to have that (we put everywhere except for this file).
Could you make a PR? (or @ShigekiKarita, can you do it?)

ok, I'll make a PR.

Resolving patch:
diff --git a/espnet/nets/pytorch_backend/transformer/plot.py b/espnet/nets/pytorch_backend/transformer/plot.py
--- a/espnet/nets/pytorch_backend/transformer/plot.py
+++ b/espnet/nets/pytorch_backend/transformer/plot.py
@@ -1,8 +1,7 @@
 import logging
 
-import matplotlib.pyplot as plt
-
 from espnet.asr import asr_utils
+import matplotlib.pyplot as plt
 
 
 def _plot_and_save_attention(att_w, filename):


Test patch:
Repository: espnet/espnet

Issue:
V.6.0.0 asr_train with transformer raise error
Given that the argument `atype` was moved to e2e_asr.py, the asr.py will raise error in chainer backend when the config is set to train the transformer.

```
Traceback (most recent call last):
  File "/export/db/espnet/egs/voxforge/asr1/../../../espnet/bin/asr_train.py", line 341, in <module>
    main(sys.argv[1:])
  File "/export/db/espnet/egs/voxforge/asr1/../../../espnet/bin/asr_train.py", line 325, in main
    train(args)
  File "/export/db/espnet/espnet/asr/chainer_backend/asr.py", line 81, in train
    if args.atype not in ['noatt', 'dot', 'location']:
AttributeError: 'Namespace' object has no attribute 'atype'
```

not sure if it is required to remove:

```python
    # check attention type
    if args.atype not in ['noatt', 'dot', 'location']:
        raise NotImplementedError('chainer supports only noatt, dot, and location attention.')
```
or not move to another part. Let me know to submit a PR


Discussion:
It seems that following lines are duplicated.
https://github.com/espnet/espnet/blob/8c810b713b0b47b94e8bf4faed33d5d7eb1e5a42/espnet/asr/chainer_backend/asr.py#L80-L82
https://github.com/espnet/espnet/blob/8c810b713b0b47b94e8bf4faed33d5d7eb1e5a42/espnet/nets/chainer_backend/rnn/attentions.py#L248-L258

We should remove first one.
BTW, in the latter one, we should use `raise NotImplementedError` instead of `logging.error` and `sys.exit()`.
Also, this error will be also caused in master.

Resolving patch:
diff --git a/espnet/asr/chainer_backend/asr.py b/espnet/asr/chainer_backend/asr.py
--- a/espnet/asr/chainer_backend/asr.py
+++ b/espnet/asr/chainer_backend/asr.py
@@ -77,10 +77,6 @@ def train(args):
     logging.info('#input dims : ' + str(idim))
     logging.info('#output dims: ' + str(odim))
 
-    # check attention type
-    if args.atype not in ['noatt', 'dot', 'location']:
-        raise NotImplementedError('chainer supports only noatt, dot, and location attention.')
-
     # specify attention, CTC, hybrid mode
     if args.mtlalpha == 1.0:
         mtl_mode = 'ctc'
diff --git a/espnet/nets/chainer_backend/rnn/attentions.py b/espnet/nets/chainer_backend/rnn/attentions.py
--- a/espnet/nets/chainer_backend/rnn/attentions.py
+++ b/espnet/nets/chainer_backend/rnn/attentions.py
@@ -2,9 +2,7 @@
 import chainer.functions as F
 import chainer.links as L
 
-import logging
 import numpy as np
-import sys
 
 from espnet.nets.chainer_backend.nets_utils import linear_tensor
 
@@ -253,7 +251,5 @@ def att_for(args):
     elif args.atype == 'noatt':
         att = NoAtt()
     else:
-        logging.error(
-            "Error: need to specify an appropriate attention architecture")
-        sys.exit()
+        raise NotImplementedError('chainer supports only noatt, dot, and location attention.')
     return att


Test patch: