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

Issue:
Relative Number for tab index
Add a setting to display relative tab number, similar to relative line numbers in vim:

![image](https://user-images.githubusercontent.com/13348080/126780567-6107bfab-da68-4a10-aedc-4f76fe28b736.png)

This would make it effortless to switch tabs e.g. `7J`, without having to do arithmetic.


Discussion:
Looked at the docs. It seems you could add a `relative_index` placeholder to the `FormatString` type. See https://qutebrowser.org/doc/help/settings.html#tabs.title.format.
I just implemented this. I'll make a PR in a bit.

Resolving patch:
diff --git a/qutebrowser/mainwindow/tabwidget.py b/qutebrowser/mainwindow/tabwidget.py
--- a/qutebrowser/mainwindow/tabwidget.py
+++ b/qutebrowser/mainwindow/tabwidget.py
@@ -136,18 +136,31 @@ def update_tab_title(self, idx, field=None):
                 (fmt is None or ('{' + field + '}') not in fmt)):
             return
 
+        def right_align(text):
+            return str(text).rjust(len(str(self.count())))
+
+        def left_align(text):
+            return str(text).ljust(len(str(self.count())))
+
+        bar = self.tabBar()
+        cur_idx = bar.currentIndex()
+        if idx == cur_idx:
+            rel_idx = left_align(idx + 1) + " "
+        else:
+            rel_idx = " " + right_align(abs(idx - cur_idx))
+
         fields = self.get_tab_fields(idx)
         fields['current_title'] = fields['current_title'].replace('&', '&&')
         fields['index'] = idx + 1
-        fields['aligned_index'] = str(idx + 1).rjust(len(str(self.count())))
+        fields['aligned_index'] = right_align(idx + 1)
+        fields['relative_index'] = rel_idx
 
         title = '' if fmt is None else fmt.format(**fields)
-        tabbar = self.tabBar()
 
         # Only change the tab title if it changes, setting the tab title causes
         # a size recalculation which is slow.
-        if tabbar.tabText(idx) != title:
-            tabbar.setTabText(idx, title)
+        if bar.tabText(idx) != title:
+            bar.setTabText(idx, title)
 
     def get_tab_fields(self, idx):
         """Get the tab field data."""
@@ -305,6 +318,7 @@ def insertTab(self, idx, page, icon_or_text, text_or_empty=None):
     def _on_current_changed(self, index):
         """Emit the tab_index_changed signal if the current tab changed."""
         self.tabBar().on_current_changed()
+        self.update_tab_titles()
         self.tab_index_changed.emit(index, self.count())
 
     @pyqtSlot()


Test patch:
Repository: qutebrowser/qutebrowser

Issue:
confirm_quit=downloads should not prompt with more than one window
<!-- If this is a bug report, please remember to mention your version info from
`:open qute:version` or `qutebrowser --version` -->

(I feel like I have already seen this somewhere...)

With tabs_are_windows and confirm_quit=downloads, Qutebrowser will prompt for confirmation when quitting any window, even if there is more than one open.
I'd expect that it only prompted when only one window was left, because that would interrupt the download.  Otherwise, the prompt is a useless annoyance.



Discussion:
That setting is broken with multiple window indeed... I'm tracking related issues in #632 but I should probably rename that to make it more obvious.

Resolving patch:
diff --git a/qutebrowser/mainwindow/mainwindow.py b/qutebrowser/mainwindow/mainwindow.py
--- a/qutebrowser/mainwindow/mainwindow.py
+++ b/qutebrowser/mainwindow/mainwindow.py
@@ -620,13 +620,15 @@ def _confirm_quit(self):
             True if closing is okay, False if a closeEvent should be ignored.
         """
         tab_count = self.tabbed_browser.widget.count()
+        window_count = len(objreg.window_registry)
         download_count = self._download_model.running_downloads()
         quit_texts = []
         # Ask if multiple-tabs are open
         if 'multiple-tabs' in config.val.confirm_quit and tab_count > 1:
             quit_texts.append("{} tabs are open.".format(tab_count))
-        # Ask if multiple downloads running
-        if 'downloads' in config.val.confirm_quit and download_count > 0:
+        # Ask if downloads running
+        if ('downloads' in config.val.confirm_quit and download_count > 0 and
+                window_count <= 1):
             quit_texts.append("{} {} running.".format(
                 download_count,
                 "download is" if download_count == 1 else "downloads are"))


Test patch:
Repository: qutebrowser/qutebrowser

Issue:
Allow turning off counts
A qutebrowser with emacs-like bindings is [almost possible](https://gitlab.com/jgkamat/qutemacs/blob/master/qutemacs.py) - however, typing number keys in insert mode isn't possible as they're always handled even if unbound. There should probably be a setting to prevent that from happening.


Discussion:
A workaround that works for now is to, for example, `:bind 1 fake-key 1`
historically related https://github.com/qutebrowser/qutebrowser/issues/3307
I will take a shot at this.

Taken from IRC, so I don't forget:
> the place to look would be qutebrowser/keyinput/basekeyparser.py - probably just have a setting to disable counts (in configdata.yml) and then abort early in _match_count if it's set or so.

Resolving patch:
diff --git a/qutebrowser/keyinput/basekeyparser.py b/qutebrowser/keyinput/basekeyparser.py
--- a/qutebrowser/keyinput/basekeyparser.py
+++ b/qutebrowser/keyinput/basekeyparser.py
@@ -254,6 +254,9 @@ def _match_key_mapping(
     def _match_count(self, sequence: keyutils.KeySequence,
                      dry_run: bool) -> bool:
         """Try to match a key as count."""
+        if not config.val.input.match_counts:
+            return False
+
         txt = str(sequence[-1])  # To account for sequences changed above.
         if (txt in string.digits and self._supports_count and
                 not (not self._count and txt == '0')):


Test patch:
diff --git a/tests/unit/keyinput/test_basekeyparser.py b/tests/unit/keyinput/test_basekeyparser.py
--- a/tests/unit/keyinput/test_basekeyparser.py
+++ b/tests/unit/keyinput/test_basekeyparser.py
@@ -346,3 +346,14 @@ def test_clear_keystring_empty(qtbot, keyparser):
     keyparser._sequence = keyseq('')
     with qtbot.assert_not_emitted(keyparser.keystring_updated):
         keyparser.clear_keystring()
+
+
+def test_respect_config_when_matching_counts(keyparser, config_stub):
+    """Don't match counts if disabled in the config."""
+    config_stub.val.input.match_counts = False
+
+    info = keyutils.KeyInfo(Qt.Key_1, Qt.NoModifier)
+    keyparser.handle(info.to_event())
+
+    assert not keyparser._sequence
+    assert not keyparser._count
Repository: qutebrowser/qutebrowser

Issue:
Missing `f` prefix on f-strings
Some strings looks like they're meant to be f-strings but are missing the `f` prefix meaning variable interpolation won't happen.

https://github.com/qutebrowser/qutebrowser/blob/07ce0349837fffc221184857be56517a2d208bd8/qutebrowser/misc/sql.py#L486
https://github.com/qutebrowser/qutebrowser/blob/07ce0349837fffc221184857be56517a2d208bd8/qutebrowser/browser/webkit/http.py#L162
https://github.com/qutebrowser/qutebrowser/blob/07ce0349837fffc221184857be56517a2d208bd8/scripts/dev/change_release.py#L59
https://github.com/qutebrowser/qutebrowser/blob/07ce0349837fffc221184857be56517a2d208bd8/scripts/dev/change_release.py#L61

I found this issue automatically. I'm a bot. Beep Boop 🦊. See other issues I found in your repo [here](https://codereview.doctor/qutebrowser/qutebrowser)


Discussion:

Resolving patch:
diff --git a/qutebrowser/browser/webkit/http.py b/qutebrowser/browser/webkit/http.py
--- a/qutebrowser/browser/webkit/http.py
+++ b/qutebrowser/browser/webkit/http.py
@@ -159,7 +159,7 @@ def parse_content_disposition(reply):
         # os.path.basename later.
         try:
             value = bytes(reply.rawHeader(content_disposition_header))
-            log.network.debug("Parsing Content-Disposition: {value!r}")
+            log.network.debug(f"Parsing Content-Disposition: {value!r}")
             content_disposition = ContentDisposition.parse(value)
             filename = content_disposition.filename()
         except ContentDispositionError as e:
diff --git a/qutebrowser/misc/sql.py b/qutebrowser/misc/sql.py
--- a/qutebrowser/misc/sql.py
+++ b/qutebrowser/misc/sql.py
@@ -483,7 +483,7 @@ def delete(self, field: str, value: Any) -> None:
         q = self.database.query(f"DELETE FROM {self._name} where {field} = :val")
         q.run(val=value)
         if not q.rows_affected():
-            raise KeyError('No row with {field} = "{value}"')
+            raise KeyError(f'No row with {field} = "{value!r}"')
         self.changed.emit()
 
     def _insert_query(self, values: Mapping[str, Any], replace: bool) -> Query:
diff --git a/scripts/dev/change_release.py b/scripts/dev/change_release.py
--- a/scripts/dev/change_release.py
+++ b/scripts/dev/change_release.py
@@ -56,9 +56,9 @@ def change_release_description(release, filename, description):
     """Change a release description to the given new one."""
     assets = [asset for asset in release.assets() if asset.name == filename]
     if not assets:
-        raise Error("No assets found for {filename}")
+        raise Error(f"No assets found for {filename}")
     if len(assets) > 1:
-        raise Error("Multiple assets found for {filename}: {assets}")
+        raise Error(f"Multiple assets found for {filename}: {assets}")
 
     asset = assets[0]
     asset.edit(filename, description)


Test patch:
Repository: qutebrowser/qutebrowser

Issue:
"Search result vanished" with search-next and no result
When doing `/thisdoesnotexist` and then pressing `n`, "Search result vanished..." gets displayed. We probably shouldn't allow using `search-next` with no search result at all?

Regression introduced in e15bda307e42c288b926f578e7bf8c610e4767af.


Discussion:
FTR: from experiencing that message for 1.5 months of using the QT6 branch I've got impression the problem is purely cosmetic. I.e. it doesn't seem to have any other effect besides displaying an odd message.
That's accurate - but it's still confusing and a regression, and should be easy to fix.
Moving this back to v3.0.0 - should be an easy fix, so I'd rather get it done instead of confusing people with a regression.
I will give this a try on the weekend.

Resolving patch:
diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py
--- a/qutebrowser/browser/commands.py
+++ b/qutebrowser/browser/commands.py
@@ -1597,8 +1597,7 @@ def _search_cb(self, found, *, text):
     def _search_navigation_cb(self, result):
         """Callback called from :search-prev/next."""
         if result == browsertab.SearchNavigationResult.not_found:
-            # FIXME check if this actually can happen...
-            message.warning("Search result vanished...")
+            self._search_cb(found=False, text=self._tabbed_browser.search_text)
             return
         elif result == browsertab.SearchNavigationResult.found:
             return


Test patch:
diff --git a/tests/end2end/features/search.feature b/tests/end2end/features/search.feature
--- a/tests/end2end/features/search.feature
+++ b/tests/end2end/features/search.feature
@@ -147,6 +147,14 @@ Feature: Searching on a page
         And I run :search-next
         Then the error "No search done yet." should be shown
 
+    # https://github.com/qutebrowser/qutebrowser/issues/7275
+    @qtwebkit_skip
+    Scenario: Jumping to next without matches
+        When I run :search doesnotmatch
+        And I wait for the warning "Text 'doesnotmatch' not found on page!"
+        And I run :search-next
+        Then the warning "Text 'doesnotmatch' not found on page!" should be shown
+
     Scenario: Repeating search in a second tab (issue #940)
         When I open data/search.html in a new tab
         And I run :search foo
@@ -222,6 +230,14 @@ Feature: Searching on a page
         And I run :search-prev
         Then the error "No search done yet." should be shown
 
+    # https://github.com/qutebrowser/qutebrowser/issues/7275
+    @qtwebkit_skip
+    Scenario: Jumping to previous without matches
+        When I run :search doesnotmatch
+        And I wait for the warning "Text 'doesnotmatch' not found on page!"
+        And I run :search-prev
+        Then the warning "Text 'doesnotmatch' not found on page!" should be shown
+
     ## wrapping
 
     Scenario: Wrapping around page
Repository: qutebrowser/qutebrowser

Issue:
prompt_queue is None at shutdown
Seeing this in various crash reports:

```pytb
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/qutebrowser/misc/quitter.py", line 225, in shutdown
    if prompt.prompt_queue.shutdown():
AttributeError: 'NoneType' object has no attribute 'shutdown'
```

https://crashes.qutebrowser.org/lists?search=prompt_queue.shutdown


Discussion:
As per #7791, this e.g. happens when hitting ctrl-c without qutebrowser being fully started yet, e.g. with the "QtWebEngine version change" popup:

```
$ QUTE_QT_WRAPPER=PyQt6 qutebrowser -B ~/qutetest  # then press ctrl+c
^C14:39:48 INFO: SIGINT/SIGTERM received, shutting down!
14:39:48 INFO: Do the same again to forcefully quit.
14:39:48 ERROR: Uncaught exception
```

Resolving patch:
diff --git a/qutebrowser/misc/quitter.py b/qutebrowser/misc/quitter.py
--- a/qutebrowser/misc/quitter.py
+++ b/qutebrowser/misc/quitter.py
@@ -219,7 +219,8 @@ def shutdown(self, status: int = 0,
             status, session))
 
         sessions.shutdown(session, last_window=last_window)
-        prompt.prompt_queue.shutdown()
+        if prompt.prompt_queue is not None:
+            prompt.prompt_queue.shutdown()
 
         # If shutdown was called while we were asking a question, we're in
         # a still sub-eventloop (which gets quit now) and not in the main


Test patch:
Repository: SarthakJariwala/seaborn-image

Issue:
Update pyproject.toml to require matplotlib-scalebar > 0.7.0
The Matplotlib rcParams Dict doesn't get updated to include scalebar.width_fraction until Release v.0.7.0 of matplotlib-scalebar.

i.e. version check in ```./pyproject.toml``` should probably change from:
 ```matplotlib-scalebar = ">=0.6.2,<0.8.0"```
to
```matplotlib-scalebar = ">=0.7.0,<0.8.0"```


Discussion:

Resolving patch:
diff --git a/src/seaborn_image/_datasets.py b/src/seaborn_image/_datasets.py
--- a/src/seaborn_image/_datasets.py
+++ b/src/seaborn_image/_datasets.py
@@ -15,6 +15,7 @@
         # The registry is a dict with file names and their SHA256 hashes
         "PolymerImage.txt": "7b6798865080adf3ecf11e342f3d86d7b52ea0700020a1f062544ee825fb8a0e",
         "Perovskite.txt": "3228eeade5afec3c2b1ed116b2d4fe35877224d2d9bf7b4a17e04a432e6135c5",
+        "cells.tif": "2120cfe08e0396324793a10a905c9bbcb64b117215eb63b2c24b643e1600c8c9",
     },
 )
 
@@ -59,13 +60,12 @@ def load_image(name):
         img = np.loadtxt(path)
 
     elif name == "cells":
-        fname = pooch.retrieve(
-            url="https://github.com/scikit-image/skimage-tutorials/raw/master/images/cells.tif",
-            known_hash="2120cfe08e0396324793a10a905c9bbcb64b117215eb63b2c24b643e1600c8c9",
-        )
-        img = io.imread(fname).T
+        path = POOCH.fetch("cells.tif")
+        img = io.imread(path).T
 
     else:
-        raise ValueError(f"No '{name}' image dataset")
+        raise ValueError(
+            f"No '{name}' image dataset. Available image datasets include: polymer, polymer outliers, fluorescence, cells"
+        )
 
     return img


Test patch:
Repository: SarthakJariwala/seaborn-image

Issue:
Bin colors don't match while using `robust` in `imghist`
Histogram bin colors do not match the corresponding colorbar color while using `robust` parameter `imghist`




Discussion:

Resolving patch:
diff --git a/src/seaborn_image/_general.py b/src/seaborn_image/_general.py
--- a/src/seaborn_image/_general.py
+++ b/src/seaborn_image/_general.py
@@ -610,18 +610,37 @@ def imghist(
     if cbar_log is True:
         _log = True
 
+    # if robust is True, then the histogram only needs to account for the data
+    # that are within the limits of the colorbar axis
+    # This will be the same as percentile value used to set the colorbar min and max
+    if robust:
+        _data_min = np.nanpercentile(data, perc[0])
+        _data_max = np.nanpercentile(data, perc[1])
+
+        data_robust = data[(data > _data_min) & (data < _data_max)]
+    else:
+        data_robust = data
+
     if orientation == "vertical":
         ax2 = f.add_subplot(gs[1], sharey=cax)
 
         n, bins, patches = ax2.hist(
-            data.ravel(), bins=bins, density=True, orientation="horizontal", log=_log
+            data_robust.ravel(),
+            bins=bins,
+            density=True,
+            orientation="horizontal",
+            log=_log,
         )
 
     elif orientation == "horizontal":
         ax2 = f.add_subplot(gs[1], sharex=cax)
 
         n, bins, patches = ax2.hist(
-            data.ravel(), bins=bins, density=True, orientation="vertical", log=_log
+            data_robust.ravel(),
+            bins=bins,
+            density=True,
+            orientation="vertical",
+            log=_log,
         )
 
     if not showticks:


Test patch:
diff --git a/tests/test_general.py b/tests/test_general.py
--- a/tests/test_general.py
+++ b/tests/test_general.py
@@ -207,6 +207,30 @@ def test_imghist_data_is_same_as_input():
     np.testing.assert_array_equal(f.axes[0].images[0].get_array().data, data)
 
 
+def test_imghist_robust_hist_cmap():
+    """Check if the min/max patch color in histogram matches
+    the min/max colors in the colorbar after robust"""
+
+    polymer = isns.load_image("polymer")
+
+    f = isns.imghist(polymer, robust=True, perc=(0.5, 50))
+
+    _min = np.nanpercentile(polymer, 0.5)
+    _max = np.nanpercentile(polymer, 50)
+
+    # check the max patch facecolor and check it against the image cmap max
+    np.testing.assert_array_equal(
+        f.axes[0].images[0].cmap(_max), f.axes[-1].patches[-1].get_facecolor()
+    )
+
+    # check the min patch facecolor and check it against the image cmap min
+    np.testing.assert_array_equal(
+        f.axes[0].images[0].cmap(_min), f.axes[-1].patches[0].get_facecolor()
+    )
+
+    plt.close()
+
+
 @pytest.mark.parametrize("cmap", [None, "acton"])
 @pytest.mark.parametrize("bins", [None, 100])
 @pytest.mark.parametrize("orientation", ["horizontal", "h", "vertical", "v"])
Repository: SarthakJariwala/seaborn-image

Issue:
Update theme to pydata-sphinx-theme



Discussion:

Resolving patch:
diff --git a/docs/conf.py b/docs/conf.py
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -1,10 +1,9 @@
 from datetime import datetime
-import sphinx_bootstrap_theme
 
 
 project = "seaborn-image"
 author = "Sarthak Jariwala"
-copyright = f"{datetime.now().year}, {author}"
+copyright = f"2020 - {datetime.now().year}, {author}"
 extensions = [
     "sphinx.ext.autodoc",
     "sphinx.ext.napoleon",
@@ -29,7 +28,7 @@
     "download_all_examples": False,
     "line_numbers": False,
     "show_memory": False,
-    "thumbnail_size": (500, 500),
+    "thumbnail_size": (1000, 1000),
 }
 
 # nbsphinx settings
@@ -87,27 +86,35 @@
 
 # The theme to use for HTML and HTML Help pages.  See the documentation for
 # a list of builtin themes.
-html_theme = "bootstrap"
+html_theme = "pydata_sphinx_theme"
 
 # Theme options are theme-specific and customize the look and feel of a theme
 # further.  For a list of options available for each theme, see the
 # documentation.
 html_theme_options = {
     "source_link_position": "footer",
-    "bootswatch_theme": "lumen",  # united, simplex
-    "navbar_sidebarrel": False,
-    "bootstrap_version": "3",
-    "navbar_links": [
-        ("Gallery", "auto_examples/index"),
-        ("Reference", "reference"),
-        ("Tutorial", "tutorial"),
-        ("GitHub", "https://github.com/SarthakJariwala/seaborn-image", True),
-        ("Releases", "https://github.com/SarthakJariwala/seaborn-image/releases", True),
+    "icon_links": [
+        {
+            "name": "GitHub",
+            "url": "https://github.com/SarthakJariwala/seaborn-image",
+            "icon": "fab fa-github-square",
+        },
+        {
+            "name": "Twitter",
+            "url": "https://twitter.com/JariwalaSarthak",
+            "icon": "fab fa-twitter-square",
+        },
     ],
+    "use_edit_page_button": True,
 }
 
-html_theme_path = sphinx_bootstrap_theme.get_html_theme_path()
-
+html_context = {
+    "github_url": "https://github.com",
+    "github_user": "SarthakJariwala",
+    "github_repo": "seaborn-image",
+    "github_version": "master",
+    "doc_path": "docs",
+}
 # Add any paths that contain custom themes here, relative to this directory.
 # html_theme_path = []
 


Test patch:
Repository: facebookresearch/fairseq

Issue:
Error for new string format syntax
You forget to revert this line.
Thank you.

```
  File "/home/playma/Research/fairseq-py/fairseq/utils.py", line 53
    raise ValueError(f'Unknown log format: {args.log_format}')
```



Discussion:

Resolving patch:
diff --git a/fairseq/utils.py b/fairseq/utils.py
--- a/fairseq/utils.py
+++ b/fairseq/utils.py
@@ -50,7 +50,7 @@ def build_progress_bar(args, iterator, epoch=None, prefix=None):
     elif args.log_format == 'tqdm':
         bar = progress_bar.tqdm_progress_bar(iterator, epoch, prefix)
     else:
-        raise ValueError(f'Unknown log format: {args.log_format}')
+        raise ValueError('Unknown log format: {}'.format(args.log_format))
     return bar
 
 


Test patch:
Repository: facebookresearch/fairseq

Issue:
bad syntax in preprocess.py
levinth@zt-gpu-lin-1:~/fairseq-py$ python3 preprocess.py --source-lang de --target-lang en   --trainpref $TEXT/train --validpref $TEXT/valid --testpref $TEXT/test   --destdir data-bin/iwslt14.tokenized.de-en
  File "preprocess.py", line 84
    output_text_file = os.path.join(args.destdir, f'{output_prefix}.{lang}')
                                                                          ^
SyntaxError: invalid syntax

replacing line 84 with
output_text_file = os.path.join(args.destdir, '{output_prefix}.{lang}')
appears to have fixed the issue


Discussion:
Yes, good call. This is new format string syntax introduced in Python 3.6, but I'll remove it.

Resolving patch:
diff --git a/preprocess.py b/preprocess.py
--- a/preprocess.py
+++ b/preprocess.py
@@ -81,7 +81,7 @@ def make_dataset(input_prefix, output_prefix, lang, output_format='binary'):
             make_binary_dataset(input_prefix, output_prefix, lang)
         elif output_format == 'raw':
             # Copy original text file to destination folder
-            output_text_file = os.path.join(args.destdir, f'{output_prefix}.{lang}')
+            output_text_file = os.path.join(args.destdir, '{}.{}'.format(output_prefix, lang))
             shutil.copyfile('{}.{}'.format(input_prefix, lang), output_text_file)
 
     make_dataset(args.trainpref, 'train', args.source_lang, args.output_format)


Test patch: