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

Issue:
spotify: spotify_updated is always a "null" date
I just checked the `spotify_updated` values and all the values are `1969-12-31 19:00:00`, which prevents the use of any date-related queries. 
 
I have seen this elsewhere, but cannot figure out how to fix the issue. Here's how the date is currently being saved

https://github.com/beetbox/beets/blob/44a7cc74bfe673bcf960c5dc18716b38e33d5ad0/beetsplug/spotify.py#L651

Any idea how to fix it?



Discussion:
Aha—it looks like that code is assuming that a `DateField` can use a `datetime` object as its value. Unfortunately, that's not the case:
https://github.com/beetbox/beets/blob/44a7cc74bfe673bcf960c5dc18716b38e33d5ad0/beets/library.py#L120

You'll want to use `time.time()` instead of `datetime.datetime.now()`, as in this assignment to the `added` field:
https://github.com/beetbox/beets/blob/44a7cc74bfe673bcf960c5dc18716b38e33d5ad0/beets/dbcore/db.py#L599

Resolving patch:
diff --git a/beetsplug/spotify.py b/beetsplug/spotify.py
--- a/beetsplug/spotify.py
+++ b/beetsplug/spotify.py
@@ -19,7 +19,6 @@
 
 import base64
 import collections
-import datetime
 import json
 import re
 import time
@@ -648,7 +647,7 @@ def _fetch_info(self, items, write, force):
                 if feature in self.spotify_audio_features.keys():
                     item[self.spotify_audio_features[feature]] = \
                         audio_features[feature]
-            item['spotify_updated'] = datetime.datetime.now()
+            item['spotify_updated'] = time.time()
             item.store()
             if write:
                 item.try_write()


Test patch:
Repository: beetbox/beets

Issue:
[Spotify] Do not try to reimport album if it is permanently removed from Spotify
### Problem

Spotify often removes content from its library. There are two types of content removal:

In the first type, only the tracks are removed, but the data is still available. See [this](https://open.spotify.com/album/1t1AmX5GwiKa0UYESMJG2E) for example. Here's how it appears:
<img width="592" alt="image" src="https://github.com/beetbox/beets/assets/18319734/92c6618d-dbef-4c1e-82a1-f861838d2380">

In the second type, everything is removed. See [this](https://open.spotify.com/album/61galBMmvNvVtuFjeRndZ4) for example. Here's how it appears (notice there is no information available here):

<img width="427" alt="image" src="https://github.com/beetbox/beets/assets/18319734/5b2adbfa-aca6-40b8-8375-e1b2591b5e4a">

(Re)Import is perfectly fine for the first type of content as the data is still available. However, (re)importing (with `search-id`) in case of the second type of removal removes all the metadata. 

<img width="418" alt="image" src="https://github.com/beetbox/beets/assets/18319734/9f96059d-3e09-4f27-998b-27afc7ce586f">

We should add a check to see if valid data is being returned from Spotify before applying the metadata. 


Discussion:

Resolving patch:
diff --git a/beetsplug/spotify.py b/beetsplug/spotify.py
--- a/beetsplug/spotify.py
+++ b/beetsplug/spotify.py
@@ -219,6 +219,9 @@ def album_for_id(self, album_id):
         album_data = self._handle_response(
             requests.get, self.album_url + spotify_id
         )
+        if album_data['name'] == "":
+            self._log.debug("Album removed from Spotify: {}", album_id)
+            return None
         artist, artist_id = self.get_artist(album_data['artists'])
 
         date_parts = [


Test patch:
Repository: beetbox/beets

Issue:
Fetchart uses incorrect field for spotify_album_id
Fetchart currently uses `album.mb_albumid` to get `spotify_album_id`. This assumes `mb_albumid` has the `spotify_album_id`, which may be the case after the initial import with Spotify. However, `mb_albumid` can be overwritten with a valid `mb_albumid`, which will result in an error. 

We should be using `spotify_album_id` instead, which will always have the right value. 


Discussion:

Resolving patch:
diff --git a/beetsplug/fetchart.py b/beetsplug/fetchart.py
--- a/beetsplug/fetchart.py
+++ b/beetsplug/fetchart.py
@@ -956,7 +956,11 @@ def available(cls, log, config):
         return HAS_BEAUTIFUL_SOUP
 
     def get(self, album, plugin, paths):
-        url = self.SPOTIFY_ALBUM_URL + album.mb_albumid
+        try:
+            url = self.SPOTIFY_ALBUM_URL + album.items().get().spotify_album_id
+        except AttributeError:
+            self._log.debug('Fetchart: no Spotify album ID found')
+            return
         try:
             response = requests.get(url)
             response.raise_for_status()


Test patch:
Repository: beetbox/beets

Issue:
auto_keep broken by playlist feature
the quick n dirty playlist feature in this commit:
https://github.com/beetbox/beets/commit/861bc69df55cb3d4d20da6082878542ff42d85d8
broken auto_keep:

https://github.com/beetbox/beets/blob/79435c3b6f682d30cac169c97f978491dfd8f80d/beetsplug/convert.py#L204
When auto_keep is true, then this line fails because _get_opts_and_config was modified to return 8 values (+ playlist) instead of 7 and this check wasn't updated.


Discussion:
@JOJ0 do you happen to have the bandwidth to fix this?

Maybe, if someone were motivated to do some cleanup, it could make sense to refactor this: Instead of using a gigantic tuple, we might set the parsed options as class attributes (unless there's a reason not to do that), or use a dataclass to replace the tuple.

Resolving patch:
diff --git a/beetsplug/convert.py b/beetsplug/convert.py
--- a/beetsplug/convert.py
+++ b/beetsplug/convert.py
@@ -200,8 +200,8 @@ def auto_convert(self, config, task):
     def auto_convert_keep(self, config, task):
         if self.config['auto_keep']:
             empty_opts = self.commands()[0].parser.get_default_values()
-            (dest, threads, path_formats, fmt,
-             pretend, hardlink, link) = self._get_opts_and_config(empty_opts)
+            (dest, threads, path_formats, fmt, pretend,
+             hardlink, link, playlist) = self._get_opts_and_config(empty_opts)
 
             items = task.imported_items()
             self._parallel_convert(dest, False, path_formats, fmt,


Test patch:
Repository: beetbox/beets

Issue:
embyupdate: Allow direct configuration of user ID for private users
In the embyupdate.py plugin, if the admin user listed in the beets config is hidden from login screens, the embyupdate plugin will fail and not find the username. 

I am using an API key, which is server wide so the username does not really matter. Therefore the get_user function should just return the user provided in the beets config

We should also allow for the emby user ID (string/hash) to be supplied directly from the beets config to avoid this situation. 

can this change be made please? 


Discussion:
Sounds very reasonable! Any chance you could try putting together a PR to show how this would work?

Resolving patch:
diff --git a/beetsplug/embyupdate.py b/beetsplug/embyupdate.py
--- a/beetsplug/embyupdate.py
+++ b/beetsplug/embyupdate.py
@@ -167,6 +167,7 @@ def update(self, lib):
         port = config['emby']['port'].get()
         username = config['emby']['username'].get()
         password = config['emby']['password'].get()
+        userid = config['emby']['userid'].get()
         token = config['emby']['apikey'].get()
 
         # Check if at least a apikey or password is given.
@@ -174,16 +175,18 @@ def update(self, lib):
             self._log.warning('Provide at least Emby password or apikey.')
             return
 
-        # Get user information from the Emby API.
-        user = get_user(host, port, username)
-        if not user:
-            self._log.warning(f'User {username} could not be found.')
-            return
+        if not userid:
+            # Get user information from the Emby API.
+            user = get_user(host, port, username)
+            if not user:
+                self._log.warning(f'User {username} could not be found.')
+                return
+            userid = user[0]['Id']
 
         if not token:
             # Create Authentication data and headers.
             auth_data = password_data(username, password)
-            headers = create_headers(user[0]['Id'])
+            headers = create_headers(userid)
 
             # Get authentication token.
             token = get_token(host, port, headers, auth_data)
@@ -194,7 +197,7 @@ def update(self, lib):
                 return
 
         # Recreate headers with a token.
-        headers = create_headers(user[0]['Id'], token=token)
+        headers = create_headers(userid, token=token)
 
         # Trigger the Update.
         url = api_url(host, port, '/Library/Refresh')


Test patch:
Repository: beetbox/beets

Issue:
Sidebar scrolling in docs not working and general adjustment ideas
I was too lazy for a PR but I a quickfixed the sidebar in Alabaster. It did not stay "in place" like we had it before. More adjustments might come in proper PR.

**_~Well, the fix does not work in master but it does work on my local docs build!~_**

Update: Actually the sidebar scrolling did work, probably there was some caching issue with my local browser, so that is [x] DONE

Anyway, we should take care of docs build and customization. Some ideas:

- Explicitely state Alabaster as the theme to use.
- Set the pic we have for the beetbox organization as the logo in the docs. (Or do we have a logo or does someone want to design one?
- Default to "latest" version of the docs
- ...I might add some more ideas here...

Might be related: https://github.com/beetbox/beets/issues/4912

_Originally posted by @JOJ0 in https://github.com/beetbox/beets/issues/4644#issuecomment-1728881928_
            


Discussion:
I don't imagine anyone actually wants this, but I did design a _really_ basic beets logo a _very_ long time ago. I truly think literally anyone could do a better job than this, but here it is nonetheless.
![logo](https://github.com/beetbox/beets/assets/188033/05367b6e-5db5-43f5-8b85-2018153e609c)

At least it's minimalistic like a logo imho should be and YOU made it! I do like it actually! Let's use it. If someone comes up with something, also ok! Anyone? ;-)

Oh! And I just realized it's been in place as the discourse logo since ages! 😆

Resolving patch:
diff --git a/docs/conf.py b/docs/conf.py
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -59,5 +59,16 @@
     ),
 ]
 
-# Options for Alabaster theme
-html_theme_options = {"fixed_sidebar": True}
+# Options for pydata theme
+html_theme = 'pydata_sphinx_theme'
+html_theme_options = {
+    'collapse_navigation': True,
+    "logo": {
+        "text": "beets",
+    },
+    "pygment_light_style": "bw",
+}
+html_title = "beets"
+html_logo = "_static/beets_logo.png"
+html_static_path = ['_static']
+html_css_files = ['beets.css']
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -132,7 +132,7 @@ def build_manpages():
         ],
         "docs": [
             "sphinx",
-            "sphinx_rtd_theme",
+            "pydata_sphinx_theme",
         ],
         # Plugin (optional) dependencies:
         "absubmit": ["requests"],


Test patch:
Repository: beetbox/beets

Issue:
fetchart: Fetch cover art from discogs
I have the experience that discogs usually provides the best artwork at least for the music I need to tag and Amazon either does not have an image or it is..frankly speaking...crap.



Discussion:
I imagine this feature will depend on the discogs library, in which case this should be made an optional dependency. This way, people can still use fetchart without installing anything but can install the client library to find more art.

Also, it would be great if this integrated with the discogs plugin by detecting when an album is tagged from discogs (by looking at its source URL) and avoiding a second fuzzy search—just directly look up the art for that exact release.


Resolving patch:
diff --git a/beetsplug/discogs.py b/beetsplug/discogs.py
--- a/beetsplug/discogs.py
+++ b/beetsplug/discogs.py
@@ -425,6 +425,8 @@ def get_album_info(self, result):
             catalogno = result.data["labels"][0].get("catno")
             labelid = result.data["labels"][0].get("id")
 
+        cover_art_url = self.select_cover_art(result)
+
         # Additional cleanups (various artists name, catalog number, media).
         if va:
             artist = config["va_name"].as_str()
@@ -474,8 +476,19 @@ def get_album_info(self, result):
             discogs_albumid=discogs_albumid,
             discogs_labelid=labelid,
             discogs_artistid=artist_id,
+            cover_art_url=cover_art_url,
         )
 
+    def select_cover_art(self, result):
+        """Returns the best candidate image, if any, from a Discogs `Release` object."""
+        if result.data.get("images") and len(result.data.get("images")) > 0:
+            # The first image in this list appears to be the one displayed first
+            # on the release page - even if it is not flagged as `type: "primary"` - and
+            # so it is the best candidate for the cover art.
+            return result.data.get("images")[0].get("uri")
+
+        return None
+
     def format(self, classification):
         if classification:
             return (
diff --git a/beetsplug/fetchart.py b/beetsplug/fetchart.py
--- a/beetsplug/fetchart.py
+++ b/beetsplug/fetchart.py
@@ -1098,7 +1098,7 @@ def get(self, album, plugin, paths):
         image_url = None
         try:
             # look for cover_art_url on album or first track
-            if album.cover_art_url:
+            if album.get("cover_art_url"):
                 image_url = album.cover_art_url
             else:
                 image_url = album.items().get().cover_art_url


Test patch:
Repository: beetbox/beets

Issue:
Bring back NO_COLOR support?
Back in 2019 I added support for the [NO_COLOR environment variable](https://no-color.org/). This was removed in be290e54441987fdb80437f7982f4d5ad01bac59 as part of a refactor. Unless I'm mistaken it seems there's no way to disable colors from the command line anymore. It must be done in the config file. That's really inconvenient.

What was the reason for removing `NO_COLOR` support? Could it be brought back?



Discussion:
I'm very sorry about this. There was no particular reason this does not work anymore. I assume it is just an oversight that this was kicked out in our recent major UI overhaul PR. I also don't have an immediate answer on how difficult it will be to bring that feature back. If you happen to have insight and resources on how to proceed that would be super-helpful and very much appreciated.

Sorry again and thanks a lot for the report! Very helpful already! 


No worries! I think the solution should be as simple as bringing back the `"NO_COLOR" in os.environ` check. I'll test this and have a PR up later.
That sounds perfect!!! Thanks!

Resolving patch:
diff --git a/beets/ui/__init__.py b/beets/ui/__init__.py
--- a/beets/ui/__init__.py
+++ b/beets/ui/__init__.py
@@ -591,7 +591,7 @@ def colorize(color_name, text):
     """Colorize text if colored output is enabled. (Like _colorize but
     conditional.)
     """
-    if config["ui"]["color"]:
+    if config["ui"]["color"] and "NO_COLOR" not in os.environ:
         global COLORS
         if not COLORS:
             # Read all color configurations and set global variable COLORS.


Test patch:
Repository: beetbox/beets

Issue:
Remove unused functions
## Description

Remove unused functions. Fixes #5103.

The function `ex_varassign` is never called. The function `ex_lvalue` is only called by `ex_varassign`.

## To Do

<!--
- If you believe one of below checkpoints is not required for the change you
  are submitting, cross it out and check the box nonetheless to let us know.
  For example: - [x] ~Changelog~
- Regarding the changelog, often it makes sense to add your entry only once
  reviewing is finished. That way you might prevent conflicts from other PR's in
  that file, as well as keep the chance high your description fits with the
  latest revision of your feature/fix.
- Regarding documentation, bugfixes often don't require additions to the docs.
- Please remove the descriptive sentences in braces from the enumeration below,
  which helps to unclutter your PR description.
-->

- [ ] Documentation. (If you've added a new command-line flag, for example, find the appropriate page under `docs/` to describe it.)
- [x] Changelog. (Add an entry to `docs/changelog.rst` to the bottom of one of the lists near the top of the document.)
- [ ] Tests. (Very much encouraged but not strictly required.)



Discussion:

Resolving patch:
diff --git a/beets/util/functemplate.py b/beets/util/functemplate.py
--- a/beets/util/functemplate.py
+++ b/beets/util/functemplate.py
@@ -58,11 +58,6 @@ def __init__(self, values, functions):
 # Code generation helpers.
 
 
-def ex_lvalue(name):
-    """A variable load expression."""
-    return ast.Name(name, ast.Store())
-
-
 def ex_rvalue(name):
     """A variable store expression."""
     return ast.Name(name, ast.Load())
@@ -75,15 +70,6 @@ def ex_literal(val):
     return ast.Constant(val)
 
 
-def ex_varassign(name, expr):
-    """Assign an expression into a single variable. The expression may
-    either be an `ast.expr` object or a value to be used as a literal.
-    """
-    if not isinstance(expr, ast.expr):
-        expr = ex_literal(expr)
-    return ast.Assign([ex_lvalue(name)], expr)
-
-
 def ex_call(func, args):
     """A function-call expression with only positional parameters. The
     function may be an expression or the name of a function. Each


Test patch:
Repository: qutip/qutip

Issue:
_version2int can't always correctly parse version info
I built latest cython, which happens to be version 0.21a1.

Running any qutip code throws a warning:
QuTiP warning: Cython setup failed: invalid literal for int() with base 10: '21a1'

This is due to _version2int() not properly parsing the version info in __init__.py. commenting it out, works (and qutip code runs).

Is this on purpose (so say only certain, non-dev, versions are supported)? or should _version2int() be more robust? 

.



Discussion:
Thanks for reporting this. The function should be more robust... We have had this problem several times before, especially with Cython which seem to come up with new version postfix every once in a while... There are a list of special cases in the version2int function. A new special case for version numbers ending with 'a...' should be added.

no need to thank me!... thank YOU for writing qutip ;)

I think distutils.version handles this issue out-of-the-box.


Resolving patch:
diff --git a/qutip/utilities.py b/qutip/utilities.py
--- a/qutip/utilities.py
+++ b/qutip/utilities.py
@@ -389,6 +389,6 @@ def view_methods(Q):
 
 def _version2int(version_string):
     str_list = version_string.split(
-        "-dev")[0].split("rc")[0].split("b")[0].split("post")[0].split('.')
+        "-dev")[0].split("rc")[0].split("a")[0].split("b")[0].split("post")[0].split('.')
     return sum([int(d if len(d) > 0 else 0) * (100 ** (3 - n))
                 for n, d in enumerate(str_list[:3])])


Test patch:
Repository: qutip/qutip

Issue:
Mcsolve suppress progress?
It would be nice to have an easy way in options to suppress the mcsolve progress output.



Discussion:

Resolving patch:
diff --git a/qutip/mcsolve.py b/qutip/mcsolve.py
--- a/qutip/mcsolve.py
+++ b/qutip/mcsolve.py
@@ -58,7 +58,7 @@
 from qutip.rhs_generate import _td_format_check, _td_wrap_array_str
 import qutip.settings
 from qutip.settings import debug
-from qutip.ui.progressbar import TextProgressBar
+from qutip.ui.progressbar import TextProgressBar, BaseProgressBar
 
 if debug:
     import inspect
@@ -75,7 +75,7 @@
 
 
 def mcsolve(H, psi0, tlist, c_ops, e_ops, ntraj=None,
-            args={}, options=Options()):
+            args={}, options=Options(), progress_bar=TextProgressBar()):
     """Monte-Carlo evolution of a state vector :math:`|\psi \\rangle` for a
     given Hamiltonian and sets of collapse operators, and possibly, operators
     for calculating expectation values. Options for the underlying ODE solver
@@ -139,6 +139,10 @@ def C1_coeff(t,args):
         Arguments for time-dependent Hamiltonian and collapse operator terms.
     options : Options
         Instance of ODE solver options.
+    progress_bar: TextProgressBar
+        Optional instance of BaseProgressBar, or a subclass thereof, for
+        showing the progress of the simulation. Set to None to disable the
+        progress bar.
 
     Returns
     -------
@@ -169,10 +173,10 @@ def C1_coeff(t,args):
         e_ops_dict = None
 
     config.options = options
-    if isinstance(ntraj, list):
-        config.progress_bar = TextProgressBar(max(ntraj))
+    if progress_bar:
+        config.progress_bar = progress_bar
     else:
-        config.progress_bar = TextProgressBar(ntraj)
+        config.progress_bar = BaseProgressBar()
 
     # set num_cpus to the value given in qutip.settings if none in Options
     if not config.options.num_cpus:
@@ -518,7 +522,10 @@ def run(self):
             args = (mc_alg_out, self.config.options,
                     self.config.tlist, self.num_times, self.seeds)
 
-            self.config.progress_bar.start(self.config.ntraj)
+            if isinstance(self.config.ntraj, list):
+                self.config.progress_bar.start(max(self.config.ntraj))
+            else:
+                self.config.progress_bar.start(self.config.ntraj)
             self.parallel(args, self)
             self.config.progress_bar.finished()
 
diff --git a/qutip/mesolve.py b/qutip/mesolve.py
--- a/qutip/mesolve.py
+++ b/qutip/mesolve.py
@@ -166,6 +166,10 @@ def mesolve(H, rho0, tlist, c_ops, e_ops, args={}, options=None,
     options : :class:`qutip.Options`
         with options for the ODE solver.
 
+    progress_bar: TextProgressBar
+        Optional instance of BaseProgressBar, or a subclass thereof, for
+        showing the progress of the simulation.
+
     Returns
     -------
 


Test patch:
Repository: qutip/qutip

Issue:
Hadamard transform normalisation factor incorrect
The qip.hadamard_transform function does not return return expected output. 

Tested with N=1 in Python 2.7 and factor is 0.5 rather than 1/sqrt(2). 

The 2*_(-N / 2) would need to be something like 2_(-N / 2.0) to ensure float division

Hadamard transform normalisation factor incorrect
The qip.hadamard_transform function does not return return expected output. 

Tested with N=1 in Python 2.7 and factor is 0.5 rather than 1/sqrt(2). 

The 2*_(-N / 2) would need to be something like 2_(-N / 2.0) to ensure float division



Discussion:

Resolving patch:
diff --git a/qutip/qip/gates.py b/qutip/qip/gates.py
--- a/qutip/qip/gates.py
+++ b/qutip/qip/gates.py
@@ -30,7 +30,7 @@
 #    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 #    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ###############################################################################
-
+from __future__ import division
 
 __all__ = ['rx', 'ry', 'rz', 'sqrtnot', 'snot', 'phasegate', 'cphase', 'cnot',
            'csign', 'berkeley', 'swapalpha', 'swap', 'iswap', 'sqrtswap',


Test patch:
Repository: qutip/qutip

Issue:
Qobj trunc_neg causing Travis errors
The tests for this are sometimes erroring in Travis
See test result for #424 
ERROR: Test Qobj: trunc_neg works for non-diagonal opers.

I saw a conversation about this somewhere, but can't find it now



Discussion:
I'll take a look, then, figure out why it's giving an IndexError.


Resolving patch:
diff --git a/qutip/qobj.py b/qutip/qobj.py
--- a/qutip/qobj.py
+++ b/qutip/qobj.py
@@ -1241,8 +1241,9 @@ def trunc_neg(self, method="clip"):
             
             acc = 0.0
             dim = self.shape[0]
+            n_eigs = len(eigvals)
             
-            for idx in reversed(range(dim)):
+            for idx in reversed(range(n_eigs)):
                 if eigvals[idx] + acc / (idx + 1) >= 0:
                     break
                 else:


Test patch: