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

Issue:
provide a setting for user specified path to store cython compiled files
### Problem Description

String based coefficients with time-dependent Hamiltonians in qutip 4.7 causes compiled files (.so, .o, .cpp files) to be stored into a hidden folder `.pyxbld` in the user's home directory. This is a problem because, when using qutip on an HPC cluster (the cluster uses Red Hat Enterprise Linux 8), I submit multiple qutip simulation jobs to the cluster, each of which generating cached file in my home directory and using up my storage. Qutip is not aware of these files and they are never deleted.

The root cause of the problem is in the top level __init__.py, on line 72, `_pyxbuilder.install()`, which calls the install() function in qutip.cy.pyxbuilder, on line 47:

```
def install():
    """Install the pyximport interface."""
    return pyximport.install(setup_args={'include_dirs': [np.get_include()]})
```
Since the `build_dir` keyword argument is not supplied to `pyximport.install`, the default path is used.

### Proposed Solution

Supply an option in `qutip.settings`, or `qutiprc`, or `qutip.solver.Options` to specify a custom path for the compiled files. This path is then passed to `pyximport.install` as the `build_dir` argument when `__init__.py` is run, upon first import of qutip.

### Alternate Solutions

_No response_

### Additional Context

_No response_


Discussion:

Resolving patch:
diff --git a/qutip/core/coefficient.py b/qutip/core/coefficient.py
--- a/qutip/core/coefficient.py
+++ b/qutip/core/coefficient.py
@@ -245,6 +245,9 @@ class CompilationOptions(QutipOptions):
 
     clean_on_error : bool [True]
         When writing a cython file that cannot be imported, erase it.
+
+    build_dir: str [None]
+        cythonize's build_dir.
     """
     _link_flags = ""
     _compiler_flags = ""
@@ -275,6 +278,7 @@ class CompilationOptions(QutipOptions):
         "link_flags": _link_flags,
         "extra_import": "",
         "clean_on_error": True,
+        "build_dir": None,
     }
     _settings_name = "compile"
 
@@ -554,7 +558,9 @@ def compile_code(code, file_name, parsed, c_opt):
                 include_dirs=[np.get_include()],
                 language='c++'
             )
-            ext_modules = cythonize(coeff_file, force=True)
+            ext_modules = cythonize(
+                coeff_file, force=True, build_dir=c_opt['build_dir']
+            )
             setup(ext_modules=ext_modules)
         except Exception as e:
             if c_opt['clean_on_error']:


Test patch:
Repository: qutip/qutip

Issue:
Quantum Object not rendered properly in Latex when using the VSCode IDE
### Bug Description

When printing a Qobj in Jupyter Notebooks of the VSCode IDE, the output is rendered as raw text rather than as Latex equation.

### Code to Reproduce the Bug

```shell
import qutip as qt
qt.fock(2,0)
```


### Code Output

```shell
Quantum object: dims=[[2], [1]], shape=(2, 1), type='ket'\begin{equation*}\left(\begin{array}{{11}c}1\0\end{array}\right)\end{equation}
```


### Expected Behaviour

The output should instead look like:

`Quantum object: dims=[[2], [1]], shape=(2, 1), type='ket'`

![image](https://github.com/qutip/qutip/assets/57567043/74f251bc-54b3-463f-b7b8-86091a939d48)


### Your Environment

```shell
QuTiP Version:      5.0.0.dev0+nogit
Numpy Version:      1.24.3
Scipy Version:      1.10.1
Cython Version:     0.29.33
Matplotlib Version: 3.7.1
Python Version:     3.8.16
Number of CPUs:     8
BLAS Info:          OPENBLAS
INTEL MKL Ext:      False
Platform Info:      Darwin (x86_64)
```


### Additional Context

I see already there are some errors in the latex code output. 
- `\end{equation}` -> `\end{equation*}`
- `{{11}c}`: is this format correct?. I would rather do: `{cc}`


Discussion:
Seeing this on `5.0.0.dev` with VSCode Insiders. Calling 
```python
import qutip as qt
qt.fock(2, 0)._repr_latex_()
```  
yields `"Quantum object: dims=[[2], [1]], shape=(2, 1), type='ket'\\begin{equation*}\\left(\\begin{array}{*{11}c}1\\\\0\\end{array}\\right)\\end{equation*}"`. So the missing "equation" asterisk is being interpreted as markdown when displayed I think, and matching an asterisk in the column alignment argument `*{11}c`.
```python
from IPython.display import display, Math
Math(qt.fock(2, 0)._repr_latex_())
```
results in ```ParseError: KaTeX parse error: {equation*} can be used only in display mode.```

Resolving patch:
diff --git a/qutip/core/qobj.py b/qutip/core/qobj.py
--- a/qutip/core/qobj.py
+++ b/qutip/core/qobj.py
@@ -603,10 +603,10 @@ def _repr_latex_(self):
             cols.append(None)
             cols += list(range(n_cols - half_length, n_cols))
         # Make the data array.
-        data = r'\begin{equation*}\left(\begin{array}{*{11}c}'
+        data = r'$$\left(\begin{array}{cc}'
         data += r"\\".join(_latex_row(row, cols, self.data.to_array())
                            for row in rows)
-        data += r'\end{array}\right)\end{equation*}'
+        data += r'\end{array}\right)$$'
         return self._str_header() + data
 
     def __and__(self, other):


Test patch:
Repository: qutip/qutip

Issue:
QuTiP 4.7.4: incompatibility with the latest scipy (1.12.0)
https://github.com/qutip/qutip/blob/f5149616a4071a273e7e48a63d956836739c4569/qutip/parallel.py#L7

When the latest scipy version is used (1.12.0), QuTiP (4.7.4) cannot be imported since `from scipy import array` is no longer supported in scipy.

Code to reproduce the bug: 
`import qutip`

Output:
```
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Cell In[1], line 1
----> 1 import qutip

File ~/anaconda3/envs/test/lib/python3.11/site-packages/qutip/__init__.py:133
    131 # graphics
    132 from qutip.bloch import *
--> 133 from qutip.visualization import *
    134 from qutip.orbital import *
    135 from qutip.bloch3d import *

File ~/anaconda3/envs/test/lib/python3.11/site-packages/qutip/visualization.py:24
     22 from qutip.qobj import Qobj, isket
     23 from qutip.states import ket2dm
---> 24 from qutip.wigner import wigner
     25 from qutip.tensor import tensor
     26 from qutip.matplotlib_utilities import complex_phase_cmap

File ~/anaconda3/envs/test/lib/python3.11/site-packages/qutip/wigner.py:19
     17 import qutip
     18 from qutip import Qobj, ket2dm, jmat
---> 19 from qutip.parallel import parfor
     20 from qutip.cy.sparse_utils import _csr_get_diag
     21 from qutip.sparse import eigh

File ~/anaconda3/envs/test/lib/python3.11/site-packages/qutip/parallel.py:7
      1 """
      2 This function provides functions for parallel execution of loops and function
      3 mappings, using the builtin Python module multiprocessing.
      4 """
      5 __all__ = ['parfor', 'parallel_map', 'serial_map']
----> 7 from scipy import array
      8 import multiprocessing
      9 from functools import partial

ImportError: cannot import name 'array' from 'scipy' (/Users/konstantin/anaconda3/envs/test/lib/python3.11/site-packages/scipy/__init__.py)
```



Discussion:
The deprecation warning from `scipy==1.11` reads
`DeprecationWarning: scipy.array is deprecated and will be removed in SciPy 2.0.0, use numpy.array instead`.

However, clearly this functionality broke before that release; with some discussion here: 
- https://github.com/scipy/scipy/issues/19065#issuecomment-1678439743
- https://github.com/scipy/scipy/pull/19067


Resolving patch:
diff --git a/qutip/parallel.py b/qutip/parallel.py
--- a/qutip/parallel.py
+++ b/qutip/parallel.py
@@ -4,7 +4,7 @@
 """
 __all__ = ['parfor', 'parallel_map', 'serial_map']
 
-from scipy import array
+from numpy import array
 import multiprocessing
 from functools import partial
 import os


Test patch:
Repository: qutip/qutip

Issue:
Typos in qutip.expect()'s docstring
### Bug Description

Two words in the docstring contain typos. See below.

### Code to Reproduce the Bug

```shell
from qutip import expect
print(expect.__doc__)
```


### Code Output

```shell
Parameters
----------
oper : qobj/array-like
    A single or a `list` or operators for expectation value.

state : qobj/array-like
    A single or a `list` of quantum states or density matrices.

Returns
-------
expt : float/complex/array-like
    Expectation value.  ``real`` if `oper` is Hermitian, ``complex``
    otherwise. A (nested) array of expectaction values of state or operator
    are arrays.
```


### Expected Behaviour

Parameters
----------
oper : qobj/array-like
    A single or a `list` **~~or~~** **_of_** operators for expectation value.

state : qobj/array-like
    A single or a `list` of quantum states or density matrices.

Returns
-------
expt : float/complex/array-like
    Expectation value.  ``real`` if `oper` is Hermitian, ``complex``
    otherwise. A (nested) array of expectaction values **~~of~~** **_if_** state or operator
    are arrays.

### Your Environment

```shell
QuTiP Version:      4.7.5
Numpy Version:      1.26.4
Scipy Version:      1.11.4
Cython Version:     None
Matplotlib Version: 3.8.3
Python Version:     3.12.2
Number of CPUs:     8
BLAS Info:          Generic
OPENMP Installed:   False
INTEL MKL Ext:      False
Platform Info:      Windows (AMD64)
```


### Additional Context

_No response_


Discussion:

Resolving patch:
diff --git a/qutip/core/expect.py b/qutip/core/expect.py
--- a/qutip/core/expect.py
+++ b/qutip/core/expect.py
@@ -16,7 +16,7 @@ def expect(oper, state):
     Parameters
     ----------
     oper : qobj/array-like
-        A single or a `list` or operators for expectation value.
+        A single or a `list` of operators for expectation value.
 
     state : qobj/array-like
         A single or a `list` of quantum states or density matrices.
@@ -25,8 +25,8 @@ def expect(oper, state):
     -------
     expt : float/complex/array-like
         Expectation value.  ``real`` if ``oper`` is Hermitian, ``complex``
-        otherwise. A (nested) array of expectaction values of state or operator
-        are arrays.
+        otherwise. A (nested) array of expectaction values if ``state`` or
+        ``oper`` are arrays.
 
     Examples
     --------


Test patch:
Repository: qutip/qutip

Issue:
Add `dtype` to the printed output of `Qobj`.
### Problem Description

`Qobj` and `QobjEvo` have the new property dtype that can greatly affect performance.
However, this new information can be hard to find. Having it included in the output of `__repr__` could help.

### Proposed Solution

An an dtype entry in `Qobj._str_header`.

### Alternate Solutions

_No response_

### Additional Context

First advanced in #2328.


Discussion:
Can I work on this issue, @Ericgig ?
@rochisha0 Sure!

Resolving patch:
diff --git a/qutip/core/qobj.py b/qutip/core/qobj.py
--- a/qutip/core/qobj.py
+++ b/qutip/core/qobj.py
@@ -533,6 +533,7 @@ def _str_header(self):
             "Quantum object: dims=" + str(self.dims),
             "shape=" + str(self._data.shape),
             "type=" + repr(self.type),
+            "dtype=" + str(type(self.type)),
         ])
         if self.type in ('oper', 'super'):
             out += ", isherm=" + str(self.isherm)


Test patch:
Repository: translate/pootle

Issue:
Core: drop MySQL dependence on MyISAM
Core depends on MyISAM at the moment because of low level features used for changeid tracking.  We need to migrate that to a more general approach that works on InnoDB and other supported DB engines.
- [x] Make resources list work in all DB backends (#3539)
- [x] Switch revision counter to Redis (#3364)
- [x] Ensure tests run on InnoDB (#3777)



Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -43,7 +43,7 @@ def parse_requirements(file_name):
     requirements = []
     for line in open(file_name, 'r').read().split('\n'):
         # Ignore comments, blank lines and included requirements files
-        if re.match(r'(\s*#)|(\s*$)|(-r .*$)', line):
+        if re.match(r'(\s*#)|(\s*$)|((-r|--allow-external|--allow-unverified) .*$)', line):
             continue
 
         if re.match(r'\s*-e\s+', line):


Test patch:
diff --git a/requirements/tests.txt b/requirements/tests.txt
--- a/requirements/tests.txt
+++ b/requirements/tests.txt
@@ -1,5 +1,3 @@
--r deploy.txt
-
 factory_boy
 pytest
-pytest-django>=2.6.1
+pytest-django>=2.6.1,<2.7
Repository: translate/pootle

Issue:
Pick the changes done in releasing docs in stable/2.6.0



Discussion:

Resolving patch:
diff --git a/docs/conf.py b/docs/conf.py
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -45,16 +45,16 @@
 
 # General information about the project.
 project = u'Pootle'
-copyright = u'2004-2014, Translate'
+copyright = u'2004-2015, Translate'
 
 # The version info for the project you're documenting, acts as replacement for
 # |version| and |release|, also used in various other places throughout the
 # built documents.
 #
 # The short X.Y version.
-version = '2.5.1'
+version = '2.7.0'
 # The full version, including alpha/beta/rc tags.
-release = '2.5.1-alpha1'
+release = '2.7.0-alpha1'
 
 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.


Test patch:
Repository: translate/pootle

Issue:
Make resource list work on sqlite and Postgres (SUBSTRING_INDEX)
In https://github.com/translate/pootle/blob/master/pootle/apps/pootle_project/models.py#L329 we make use of SUBSTRING_INDEX.  [SUBSTRING_INDEX](http://dev.mysql.com/doc/refman/5.6/en/string-functions.html#function_substring-index) is not available on sqlite or on Postgress so we'll need to have custom SQL there for those databases.



Discussion:
Possible solutions:
-  [Postgres](http://www.postgresql.org/message-id/469833CE.1020409@alteeve.com)
- SQLite use [instr() and substr()](https://www.sqlite.org/lang_corefunc.html)

Also see [SO16177969](https://stackoverflow.com/questions/16177969/converting-mysql-query-to-sqlite-substring-index) for sqlite


Resolving patch:
diff --git a/pootle/apps/pootle_project/models.py b/pootle/apps/pootle_project/models.py
--- a/pootle/apps/pootle_project/models.py
+++ b/pootle/apps/pootle_project/models.py
@@ -324,10 +324,7 @@ def resources(self):
         resources_path = ''.join(['/%/', self.code, '/%'])
 
         sql_query = '''
-        SELECT DISTINCT
-            REPLACE(pootle_path,
-                    CONCAT(SUBSTRING_INDEX(pootle_path, '/', 3), '/'),
-                    '')
+        SELECT pootle_path
         FROM (
             SELECT pootle_path
             FROM pootle_store_store
@@ -339,13 +336,17 @@ def resources(self):
         '''
         cursor = connection.cursor()
         cursor.execute(sql_query, [resources_path, resources_path])
-
         results = cursor.fetchall()
 
         # Flatten tuple and sort in a list
-        resources = list(reduce(lambda x,y: x+y, results))
-        resources.sort(key=get_path_sortkey)
+        resources = set()
+        for result in results:
+            s = result[0]
+            s = s[s.find("/", s.find("/", 1) + 1) + 1:]
+            resources.add(s)
 
+        resources = list(resources)
+        resources.sort(key=get_path_sortkey)
         cache.set(cache_key, resources, settings.OBJECT_CACHE_TIMEOUT)
 
         return resources


Test patch:
Repository: translate/pootle

Issue:
REGEXP not present in PostgreSQL
Postgres [fails on Travis tests](https://travis-ci.org/dwaynebailey/pootle/jobs/50400894#L2516) because of the use of [NOT REGEXP](http://dev.mysql.com/doc/refman/5.1/en/regexp.html#operator_not-regexp)

The equivalent in Postgres is to use [POSIX Regular Expressions](http://www.postgresql.org/docs/9.3/static/functions-matching.html#FUNCTIONS-POSIX-REGEXP)



Discussion:

Resolving patch:
diff --git a/pootle/core/decorators.py b/pootle/core/decorators.py
--- a/pootle/core/decorators.py
+++ b/pootle/core/decorators.py
@@ -24,6 +24,7 @@
 from django.contrib.auth import get_user_model
 from django.core.exceptions import PermissionDenied
 from django.core.urlresolvers import reverse
+from django.db import connection
 from django.http import Http404
 from django.shortcuts import get_object_or_404, redirect
 from django.utils.translation import ugettext as _
@@ -208,6 +209,9 @@ def set_project_resource(request, path_obj, dir_path, filename):
     disabled_tps = list(disabled_tps)
     disabled_tps.append('/templates/')
     disabled_tps_regex = '^%s' % u'|'.join(disabled_tps)
+    sql_not_regex = 'NOT REGEXP'
+    if connection.vendor == 'postgresql':
+        sql_not_regex = '!~'
 
     if filename:
         query_pootle_path = query_pootle_path + filename
@@ -217,14 +221,14 @@ def set_project_resource(request, path_obj, dir_path, filename):
         resources = Store.objects.extra(
             where=[
                 'pootle_store_store.pootle_path LIKE %s',
-                'pootle_store_store.pootle_path NOT REGEXP %s',
+                'pootle_store_store.pootle_path ' + sql_not_regex + ' %s',
             ], params=[query_pootle_path, disabled_tps_regex]
         ).select_related('translation_project__language')
     else:
         resources = Directory.objects.extra(
             where=[
                 'pootle_app_directory.pootle_path LIKE %s',
-                'pootle_app_directory.pootle_path NOT REGEXP %s',
+                'pootle_app_directory.pootle_path ' + sql_not_regex + ' %s',
             ], params=[query_pootle_path, disabled_tps_regex]
         ).select_related('parent')
 


Test patch:
Repository: translate/pootle

Issue:
Add default project descriptions
In order to get `initdb` running on `core` we had to drop the project [descriptions] since these move to staticpages on core.  This bug is to add those back.

To achieve that initdb should create static pages for these default projects that contain the content previously held in the [descriptions](https://github.com/translate/pootle/blob/96edf539/pootle/core/initdb.py#L300-L306).



Discussion:
Commit where description were dropped on initdb: https://github.com/translate/pootle/commit/078457ab#diff-7f8c84076d131103c0e7ea24c457f1b4R274


Resolving patch:
diff --git a/pootle/core/initdb.py b/pootle/core/initdb.py
--- a/pootle/core/initdb.py
+++ b/pootle/core/initdb.py
@@ -29,6 +29,7 @@
 from pootle_app.models.permissions import PermissionSet, get_pootle_permission
 from pootle_language.models import Language
 from pootle_project.models import Project
+from staticpages.models import StaticPage as Announcement
 
 
 def initdb():
@@ -256,21 +257,6 @@ def create_default_projects():
 
     en = require_english()
 
-    #criteria = {
-    #    'code': u"pootle",
-    #    'source_language': en,
-    #    'fullname': u"Pootle",
-    #    'description': ('<div dir="ltr" lang="en">Interface translations for '
-    #                    'Pootle.<br />See the <a href="http://'
-    #                    'pootle.locamotion.org">official Pootle server</a> '
-    #                    'for the translations of Pootle.</div>')
-    #    'checkstyle': "standard",
-    #    'localfiletype': "po",
-    #    'treestyle': "auto",
-    #}
-    #pootle = Project(**criteria)
-    #pootle.save()
-
     criteria = {
         'code': u"tutorial",
         'source_language': en,
@@ -282,6 +268,20 @@ def create_default_projects():
     tutorial = Project(**criteria)
     tutorial.save()
 
+    criteria = {
+        'active': True,
+        'title': "Project instructions",
+        'body': ('<div dir="ltr" lang="en">Tutorial project where users can '
+                 'play with Pootle and learn more about translation and '
+                 'localisation.<br />For more help on localisation, visit the '
+                 '<a href="http://docs.translatehouse.org/projects/'
+                 'localization-guide/en/latest/guide/start.html">localisation '
+                 'guide</a>.</div>'),
+        'virtual_path': "announcements/projects/"+tutorial.code,
+    }
+    ann = Announcement(**criteria)
+    ann.save()
+
 
 def create_default_languages():
     """Create the default languages."""


Test patch:
Repository: translate/pootle

Issue:
Confusing sentence in permissions view
There is a permission called "Can review translations" that confused me as I thought that there are also reviewers beside suggesters and translators! Hopefully you fix it so that it lands in 2.7.0.



Discussion:

Resolving patch:
diff --git a/pootle/core/initdb.py b/pootle/core/initdb.py
--- a/pootle/core/initdb.py
+++ b/pootle/core/initdb.py
@@ -124,7 +124,7 @@ def create_pootle_permissions():
             'codename': "translate",
         },
         {
-            'name': _("Can review translations"),
+            'name': _("Can review suggestions"),
             'codename': "review",
         },
         {


Test patch:
Repository: translate/pootle

Issue:
Reports: add custom mark data to daily activity charts
It's necessary to insert custom mark data provided by external app to daily activity charts on admin reports page.



Discussion:

Resolving patch:
diff --git a/pootle/apps/evernote_reports/views.py b/pootle/apps/evernote_reports/views.py
--- a/pootle/apps/evernote_reports/views.py
+++ b/pootle/apps/evernote_reports/views.py
@@ -13,6 +13,7 @@
 
 from django.conf import settings
 from django.contrib.auth import get_user_model
+from django.core.exceptions import ImproperlyConfigured
 from django.core.urlresolvers import reverse
 from django.http import HttpResponse, HttpResponseNotFound, HttpResponseBadRequest
 from django.shortcuts import render_to_response
@@ -30,7 +31,7 @@
 from pootle.core.utils.timezone import make_aware, make_naive
 from pootle.core.views import AjaxResponseMixin
 from pootle_misc.util import (ajax_required, jsonify, get_date_interval,
-                              get_max_month_datetime)
+                              get_max_month_datetime, import_func)
 from pootle_profile.views import (NoDefaultUserMixin, TestUserFieldMixin,
                                   DetailView)
 from pootle_statistics.models import ScoreLog
@@ -418,7 +419,7 @@ def get_activity_data(request, user, month):
         scores = list(scores.order_by(SCORE_TRANSLATION_PROJECT))
         json['grouped'] = get_grouped_paid_words(scores, user, month)
         scores.sort(key=lambda x: x.creation_time)
-        json['daily'] = get_daily_activity(scores, start, end)
+        json['daily'] = get_daily_activity(user, scores, start, end)
         json['summary'] = get_summary(scores, start, end)
         tasks = get_paid_tasks(user, start, end)
         for task in tasks:
@@ -449,7 +450,7 @@ def user_date_prj_activity(request):
     return HttpResponse(response, content_type="application/json")
 
 
-def get_daily_activity(scores, start, end):
+def get_daily_activity(user, scores, start, end):
     result_translated = {
         'label': PaidTask.get_task_type_title(
             PaidTaskTypes.TRANSLATION),
@@ -469,6 +470,17 @@ def get_daily_activity(scores, start, end):
         'nonempty': False,
     }
 
+    if settings.POOTLE_REPORTS_MARK_FUNC:
+        try:
+            get_mark_data = import_func(settings.POOTLE_REPORTS_MARK_FUNC)
+            result['data'].append({
+                'data': [],
+                'marks': {'show': True},
+                'markdata': get_mark_data(user, start, end)
+            })
+        except ImproperlyConfigured:
+            pass
+
     saved_date = None
     current_day_score = 0
     translated_group = {}


Test patch: