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

Issue:
Deprecate `WSGIMiddleware` in favor of `a2wsgi`
### Checklist

- [X] There are no similar issues or pull requests for this yet.
- [X] I discussed this idea on the [community chat](https://gitter.im/encode/community) and feedback is positive.

### Is your feature related to a problem? Please describe.

I want to deprecate `WSGIMiddleware` and recommend [a2wsgi](https://github.com/abersheeran/a2wsgi) on the documentation.

Right now, the `WSGIMiddleware` is not documented, so not that harmful to deprecate. I expect the deprecation message to inform about `a2wsgi` or recommend the specific page on the docs so users using the middleware can fix the warning easily.

### Describe the solution you would like.

_No response_

### Describe alternatives you considered

_No response_

### Additional context

Gitter conversation about the topic:

![image](https://user-images.githubusercontent.com/7353520/153407199-f31ff3cf-8406-4801-b034-db28601fbca6.png)



Discussion:

Resolving patch:
diff --git a/starlette/middleware/wsgi.py b/starlette/middleware/wsgi.py
--- a/starlette/middleware/wsgi.py
+++ b/starlette/middleware/wsgi.py
@@ -2,11 +2,18 @@
 import math
 import sys
 import typing
+import warnings
 
 import anyio
 
 from starlette.types import Receive, Scope, Send
 
+warnings.warn(
+    "starlette.middleware.wsgi is deprecated and will be removed in a future release. "
+    "Please refer to https://github.com/abersheeran/a2wsgi as a replacement.",
+    DeprecationWarning,
+)
+
 
 def build_environ(scope: Scope, body: bytes) -> dict:
     """


Test patch:
Repository: encode/starlette

Issue:
middleware causes exceptions to not be raised/handled silently
### Discussed in https://github.com/encode/starlette/discussions/1976

<div type='discussions-op-text'>

<sup>Originally posted by **fraser-langton** December  6, 2022</sup>
From [issue in FastAPI](https://github.com/tiangolo/fastapi/issues/5173) - issue was said to be from starlette

Was initially noticed in FastAPI 0.74.0, was fixed after 0.79.0 but has since regressed (FastAPI 0.88.0 it isn't working)

When exceptions are raised on a subapp, the exceptions are not propagated all the way to see in console
In the example code
/info raises an exception and the full stacktrace is seen in console
/private/info does not raise the exception and only `INFO: 127.0.0.1:56308 - "GET /info HTTP/1.1" 500 Internal Server Error` is shown in console

```python
import uvicorn
from fastapi import FastAPI
from starlette.middleware.base import BaseHTTPMiddleware


app = FastAPI()


@app.get("/info")
def info():
    # raises Exception as expected, the traceback is seen in console
    raise Exception


private_api = FastAPI()


@private_api.get("/info")
def info():
    # exception is handled silently, no traceback is seen in console
    raise Exception


app.mount("/private", private_api)


class Middleware(BaseHTTPMiddleware):

    async def dispatch(self, request, call_next):
        return await call_next(request)


app.add_middleware(Middleware)  # when this is removed, the exceptions are raised for all routes


if __name__ == '__main__':
    uvicorn.run(app, port=8000)
```
</div>


Discussion:

Resolving patch:
diff --git a/starlette/middleware/base.py b/starlette/middleware/base.py
--- a/starlette/middleware/base.py
+++ b/starlette/middleware/base.py
@@ -89,8 +89,6 @@ async def body_stream() -> typing.AsyncGenerator[bytes, None]:
                         body = message.get("body", b"")
                         if body:
                             yield body
-                        if not message.get("more_body", False):
-                            break
 
                 if app_exc is not None:
                     raise app_exc


Test patch:
Repository: ydataai/ydata-profiling

Issue:
Add badges for "highly skewed", "zeros"
I enjoy the badges on the report and am happy to submit a PR for this if it isn't being worked on elsewhere.


Discussion:
Would be a nice addition! Please send pull request

Resolving patch:
diff --git a/pandas_profiling/templates.py b/pandas_profiling/templates.py
--- a/pandas_profiling/templates.py
+++ b/pandas_profiling/templates.py
@@ -79,9 +79,9 @@ def template(template_name):
 messages['RECODED'] = u'{0[varname]} is a recoding of {0[correlation_var]} <span class="label label-primary">Rejected</span>'
 messages['HIGH_CARDINALITY'] = u'{varname} has a high cardinality: {0[distinct_count]} distinct values  <span class="label label-warning">Warning</span>'
 messages['n_duplicates'] = u'Dataset has {0[n_duplicates]} duplicate rows <span class="label label-warning">Warning</span>'
-messages['skewness'] = u'{varname} is highly skewed (γ1 = {0[skewness]})'
+messages['skewness'] = u'{varname} is highly skewed (γ1 = {0[skewness]})  <span class="label label-info">Skewed</span>'
 messages['p_missing'] = u'{varname} has {0[n_missing]} / {0[p_missing]} missing values <span class="label label-default">Missing</span>'
 messages['p_infinite'] = u'{varname} has {0[n_infinite]} / {0[p_infinite]} infinite values <span class="label label-default">Infinite</span>'
-messages['p_zeros'] = u'{varname} has {0[n_zeros]} / {0[p_zeros]} zeros'
+messages['p_zeros'] = u'{varname} has {0[n_zeros]} / {0[p_zeros]} zeros <span class="label label-info">Zeros</span>'
 
 message_row = u'<li>{message}</li>'


Test patch:
Repository: ydataai/ydata-profiling

Issue:
Nullable types not fully supported
Using pandas >= 1, columns of nullable integer type with low numbers of distinct values appear as "UNSUPPORTED".

This comes down to the check in `is_numeric` on whether there are infinite values in the series.

https://github.com/pandas-profiling/pandas-profiling/blob/216704bc6643ac691f3d1c513c0328c8cb29d088/src/pandas_profiling/model/base.py#L126

The following code gives a TypeError, which triggers the "except" branch in `get_var_type`

```
import pandas as pd
import numpy as np

series = pd.Series([1, None], dtype="Int64")
has_inf = any(np.inf == s or -np.inf == s for s in series)
```

I think that the following would be better:

```
has_inf = series.isin({np.inf, -np.inf}).any()
```



Discussion:

Resolving patch:
diff --git a/src/pandas_profiling/model/base.py b/src/pandas_profiling/model/base.py
--- a/src/pandas_profiling/model/base.py
+++ b/src/pandas_profiling/model/base.py
@@ -136,7 +136,7 @@ def is_numeric(series: pd.Series, series_description: dict) -> bool:
     return pd.api.types.is_numeric_dtype(series) and (
         series_description["distinct_count_without_nan"]
         >= config["vars"]["num"]["low_categorical_threshold"].get(int)
-        or any(np.inf == s or -np.inf == s for s in series)
+        or series.isin({np.inf, -np.inf}).any()
     )
 
 


Test patch:
diff --git a/tests/issues/test_issue587.py b/tests/issues/test_issue587.py
new file mode 100644
--- /dev/null
+++ b/tests/issues/test_issue587.py
@@ -0,0 +1,18 @@
+"""
+Test for issue 587:
+https://github.com/pandas-profiling/pandas-profiling/issues/587
+"""
+import pandas as pd
+import pytest
+
+from pandas_profiling.model.base import is_numeric, get_counts
+
+
+@pytest.mark.skipif(
+    int(pd.__version__.split(".")[0]) < 1, reason="requires pandas 1 or higher"
+)
+def test_issue587():
+    # Minimal reproducible code
+    series = pd.Series([1, None], dtype="Int64")
+    series_description = get_counts(series)
+    assert is_numeric(series, series_description) == True
Repository: ydataai/ydata-profiling

Issue:
Negative exponents appear positive
**Describe the bug**

Negative exponents do not appear in a profiling report

**To Reproduce**

```python
import numpy as np
import pandas as pd
from pandas_profiling import ProfileReport

data = { 'some_numbers' : (0.0001, 0.00001, 0.00000001, 0.002, 0.0002, 0.00003) * 100}
df = pd.DataFrame(data)
profile = ProfileReport(df, 'No Negative Exponents')
profile.to_file('NoNegativeExponents.html')
```

![no_negative_exponents](https://user-images.githubusercontent.com/1386312/110135651-a7f85b00-7dc6-11eb-8457-67416ade5dea.png)

Minimum should be 1 x 10<sup>-8</sup> rather than 1 x 10<sup>8</sup>. The issue also arises for Mean and Maximum.

**Version information:**

Python 3.7.7 (default, May  6 2020, 11:45:54) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32



**Additional context**

<!--
Add any other context about the problem here.
-->



Discussion:
Good catch. Feel free to make a PR with a fix ([relevant code](https://github.com/pandas-profiling/pandas-profiling/blob/develop/src/pandas_profiling/report/formatters.py#L207)), otherwise I'll pick it up later.

Resolving patch:
diff --git a/src/pandas_profiling/report/formatters.py b/src/pandas_profiling/report/formatters.py
--- a/src/pandas_profiling/report/formatters.py
+++ b/src/pandas_profiling/report/formatters.py
@@ -206,8 +206,10 @@ def fmt_numeric(value: float, precision=10) -> str:
     fmtted = f"{{:.{precision}g}}".format(value)
     for v in ["e+", "e-"]:
         if v in fmtted:
+            sign = "-" if v in "e-" else ""
             fmtted = fmtted.replace(v, " × 10<sup>") + "</sup>"
             fmtted = fmtted.replace("<sup>0", "<sup>")
+            fmtted = fmtted.replace("<sup>", f"<sup>{sign}")
 
     return fmtted
 


Test patch:
diff --git a/tests/unit/test_formatters.py b/tests/unit/test_formatters.py
--- a/tests/unit/test_formatters.py
+++ b/tests/unit/test_formatters.py
@@ -79,6 +79,9 @@ def test_fmt_array(array, threshold, expected):
         (81.000000, 10, "81"),
         (81, 10, "81"),
         (81.999861123123123123, 10, "81.99986112"),
+        (1e20, 10, "1 × 10<sup>20</sup>"),
+        (1e-20, 10, "1 × 10<sup>-20</sup>"),
+        (1e8, 3, "1 × 10<sup>8</sup>"),
     ],
 )
 def test_fmt_numeric(value, precision, expected):
Repository: ydataai/ydata-profiling

Issue:
Phi K correlation variable order
For me all correlation plots show variables in the (domain-specific sensible) order of the columns in my data frame.

Only Phi K shows them in some other order.

Is this a bug or a feature?

Is there a setting to get the "good" order?

This is with pandas 1.3 and pandas-profiling 3.0.0

<img width="879" alt="Screenshot 2021-09-05 at 21 43 55" src="https://user-images.githubusercontent.com/852409/132139566-ba92033b-98fb-4b3d-a869-6c096ed294a1.png">
<img width="907" alt="Screenshot 2021-09-05 at 21 43 45" src="https://user-images.githubusercontent.com/852409/132139567-22e2d9ce-cdc8-4b95-93b2-7445a78ed397.png">



Discussion:
The correlation variables should have the same order, so this is a bug. 
Anyone who is interested, feel free to dig in to see where the issue is.

[Starting point](https://github.com/pandas-profiling/pandas-profiling/blob/develop/src/pandas_profiling/model/pandas/correlations_pandas.py#L116)
@sbrugman Can I give this a shot? ✌🏻 
@abhicantdraw Of course, many thanks!

Resolving patch:
diff --git a/src/pandas_profiling/model/pandas/correlations_pandas.py b/src/pandas_profiling/model/pandas/correlations_pandas.py
--- a/src/pandas_profiling/model/pandas/correlations_pandas.py
+++ b/src/pandas_profiling/model/pandas/correlations_pandas.py
@@ -104,6 +104,8 @@ def pandas_cramers_compute(
 def pandas_phik_compute(
     config: Settings, df: pd.DataFrame, summary: dict
 ) -> Optional[pd.DataFrame]:
+    df_cols_dict = {i: list(df.columns).index(i) for i in df.columns}
+
     intcols = {
         key
         for key, value in summary.items()
@@ -120,14 +122,15 @@ def pandas_phik_compute(
         and 1 < value["n_distinct"] <= config.categorical_maximum_correlation_distinct
     }
     selcols = selcols.union(intcols)
+    selected_cols = sorted(selcols, key=lambda i: df_cols_dict[i])
 
-    if len(selcols) <= 1:
+    if len(selected_cols) <= 1:
         return None
 
     with warnings.catch_warnings():
         warnings.simplefilter("ignore")
         from phik import phik_matrix
 
-        correlation = phik_matrix(df[selcols], interval_cols=list(intcols))
+        correlation = phik_matrix(df[selected_cols], interval_cols=list(intcols))
 
     return correlation


Test patch:
Repository: ydataai/ydata-profiling

Issue:
Incorrect duplicate rows count
### Current Behaviour

The duplicated rows count is different between pandas and pandas-profiling when there are nan's in columns

### Expected Behaviour

The count should be equal

### Data Description

I attach a simple example

![image](https://user-images.githubusercontent.com/61322372/180415055-83fc2fec-fc2a-4921-acf9-0a9a38ccb645.png)


### Code that reproduces the bug

```Python
import pandas as pd
import numpy as np

df = pd.DataFrame({"a": [np.nan, np.nan, 2], "b": [1, 1, 3]})
sum(df.duplicated())

from pandas_profiling import ProfileReport

profile = ProfileReport(df, title="Pandas Profiling Report")
```


### pandas-profiling version

3.2.0

### Dependencies

```Text
numpy==1.22.4
pandas==1.3.3
```


### OS

_No response_

### Checklist

- [X] There is not yet another bug report for this issue in the [issue tracker](https://github.com/ydataai/pandas-profiling/issues)
- [X] The problem is reproducible from this bug report. [This guide](http://matthewrocklin.com/blog/work/2018/02/28/minimal-bug-reports) can help to craft a minimal bug report.
- [X] The issue has not been resolved by the entries listed under [Common Issues](https://pandas-profiling.ydata.ai/docs/master/pages/support_contrib/common_issues.html).


Discussion:
Any update on this?
@SergioG-M is included for the next release. But still under development. 

Resolving patch:
diff --git a/src/pandas_profiling/model/pandas/duplicates_pandas.py b/src/pandas_profiling/model/pandas/duplicates_pandas.py
--- a/src/pandas_profiling/model/pandas/duplicates_pandas.py
+++ b/src/pandas_profiling/model/pandas/duplicates_pandas.py
@@ -35,7 +35,7 @@ def pandas_get_duplicates(
             duplicated_rows = df.duplicated(subset=supported_columns, keep=False)
             duplicated_rows = (
                 df[duplicated_rows]
-                .groupby(supported_columns)
+                .groupby(supported_columns, dropna=False)
                 .size()
                 .reset_index(name=duplicates_key)
             )


Test patch:
Repository: ydataai/ydata-profiling

Issue:
[BUG] 🐛 `TypeCheckError` thrown when initialising a report
### Current Behaviour

Error thrown when initialising a report:

``` txt
TypeCheckError: argument "config_file" (None) did not match any element in the union:
  pathlib.Path: is not an instance of pathlib.Path
  str: is not an instance of str
```

### Expected Behaviour

No error to be thrown.

### Data Description

Happens on all data.

### Code that reproduces the bug

```Python
from ydata_profiling import ProfileReport
from pycaret.datasets import get_data
data = get_data(dataset="germany", verbose=False)
ProfileReport(data, title="Pandas DataFrame")
```


### pandas-profiling version

v4.5.1

### Dependencies

```Text
pandas
numpy
pycaret
```


### OS

Ubuntu

### Checklist

- [X] There is not yet another bug report for this issue in the [issue tracker](https://github.com/ydataai/pandas-profiling/issues)
- [X] The problem is reproducible from this bug report. [This guide](http://matthewrocklin.com/blog/work/2018/02/28/minimal-bug-reports) can help to craft a minimal bug report.
- [X] The issue has not been resolved by the entries listed under [Common Issues](https://pandas-profiling.ydata.ai/docs/master/pages/support_contrib/common_issues.html).


Discussion:

Resolving patch:
diff --git a/src/ydata_profiling/profile_report.py b/src/ydata_profiling/profile_report.py
--- a/src/ydata_profiling/profile_report.py
+++ b/src/ydata_profiling/profile_report.py
@@ -67,7 +67,7 @@ def __init__(
         dark_mode: bool = False,
         orange_mode: bool = False,
         sample: Optional[dict] = None,
-        config_file: Union[Path, str] = None,
+        config_file: Optional[Union[Path, str]] = None,
         lazy: bool = True,
         typeset: Optional[VisionsTypeset] = None,
         summarizer: Optional[BaseSummarizer] = None,


Test patch:
Repository: ydataai/ydata-profiling

Issue:
AttributeError: 'FileDataContext' object has no attribute 'create_expectation_suite'
### Current Behaviour

AttributeError: 'FileDataContext' object has no attribute 'create_expectation_suite'

[Related to this issue](https://docs.greatexpectations.io/docs/changelog/#01549): "[MAINTENANCE] Change all instances of create_expectation_suite to add_expectation_suite in tests, docs, and source code ([#7117](https://github.com/great-expectations/great_expectations/pull/7117))" 

DataContext objects no longer has a method 'create_expectation_suite'.

### Expected Behaviour

[Great expectation test suite](https://docs.profiling.ydata.ai/4.6/integrations/great_expectations/#creating-expectation-suites-with-ydata-profiling): "ydata-profiling provides a simple to_expectation_suite() method that returns a Great Expectations ExpectationSuite object which contains a set of Expectations."

### Data Description

[Dataset can be used from the documentation](https://docs.profiling.ydata.ai/4.6/integrations/great_expectations/#about-great-expectations)

### Code that reproduces the bug

```Python
profile = ProfileReport(
    df, 
    title='Pandas Profiling Report', 
    type_schema=type_schema,
    minimal=True, 
    lazy=False
)
data_context = ge.data_context.DataContext(
    context_root_dir='./gx/'
)
suite = profile.to_expectation_suite(
    data_context=data_context
)
```


### pandas-profiling version

-

### Dependencies

```Text
-
```


### OS

_No response_

### Checklist

- [X] There is not yet another bug report for this issue in the [issue tracker](https://github.com/ydataai/pandas-profiling/issues)
- [X] The problem is reproducible from this bug report. [This guide](http://matthewrocklin.com/blog/work/2018/02/28/minimal-bug-reports) can help to craft a minimal bug report.
- [X] The issue has not been resolved by the entries listed under [Common Issues](https://pandas-profiling.ydata.ai/docs/master/pages/support_contrib/common_issues.html).


Discussion:

Resolving patch:
diff --git a/src/ydata_profiling/expectations_report.py b/src/ydata_profiling/expectations_report.py
--- a/src/ydata_profiling/expectations_report.py
+++ b/src/ydata_profiling/expectations_report.py
@@ -79,7 +79,7 @@ def to_expectation_suite(
         if not data_context:
             data_context = ge.data_context.DataContext()
 
-        suite = data_context.create_expectation_suite(
+        suite = data_context.add_expectation_suite(
             suite_name, overwrite_existing=True
         )
 


Test patch:
Repository: django-haystack/django-haystack

Issue:
"simple" backend doesn't filter by model
When using ModelSearchForm, it simply doesn't filter by model. It shows results from any type of model. I would be okay with this if it were just mentioned as a caveat in the "getting started" documentation, but the documentation made it seem like the simple backend was fully-featured, but merely slow. Another sensible option would be for it to raise an exception whenever you attempt to use filtering options it doesn't support.



Discussion:
Agreed, this had my head spinning for the better part of a day until I finally gave up and installed Whoosh.  Then things started working.

+1


Resolving patch:
diff --git a/haystack/backends/simple_backend.py b/haystack/backends/simple_backend.py
--- a/haystack/backends/simple_backend.py
+++ b/haystack/backends/simple_backend.py
@@ -45,12 +45,16 @@ def search(self, query_string, **kwargs):
         hits = 0
         results = []
         result_class = SearchResult
+        models = connections[self.connection_alias].get_unified_index().get_indexed_models()
 
         if kwargs.get('result_class'):
             result_class = kwargs['result_class']
 
+        if kwargs.get('models'):
+            models = kwargs['models']
+
         if query_string:
-            for model in connections[self.connection_alias].get_unified_index().get_indexed_models():
+            for model in models:
                 if query_string == '*':
                     qs = model.objects.all()
                 else:


Test patch:
diff --git a/tests/simple_tests/tests/simple_backend.py b/tests/simple_tests/tests/simple_backend.py
--- a/tests/simple_tests/tests/simple_backend.py
+++ b/tests/simple_tests/tests/simple_backend.py
@@ -71,6 +71,11 @@ def test_search(self):
         # Ensure that swapping the ``result_class`` works.
         self.assertTrue(isinstance(self.backend.search(u'index document', result_class=MockSearchResult)['results'][0], MockSearchResult))
 
+    def test_filter_models(self):
+        self.backend.update(self.index, self.sample_objs)
+        self.assertEqual(self.backend.search(u'*', models=set([]))['hits'], 24)
+        self.assertEqual(self.backend.search(u'*', models=set([MockModel]))['hits'], 23)
+
     def test_more_like_this(self):
         self.backend.update(self.index, self.sample_objs)
         self.assertEqual(self.backend.search(u'*')['hits'], 24)
Repository: django-haystack/django-haystack

Issue:
Search form <input type="search">
When creating a simple search form for example via:

```
return basic_search(request, template='search.html')
```

... and rendering it in the template like:

```
{{ form.as_p }}
```

It should use a form with `<input type="search" .../>` instead of `<input type="text" .../>`



Discussion:

Resolving patch:
diff --git a/haystack/forms.py b/haystack/forms.py
--- a/haystack/forms.py
+++ b/haystack/forms.py
@@ -19,7 +19,8 @@ def model_choices(using=DEFAULT_ALIAS):
 
 
 class SearchForm(forms.Form):
-    q = forms.CharField(required=False, label=_('Search'))
+    q = forms.CharField(required=False, label=_('Search'),
+                        widget=forms.TextInput(attrs={'type': 'search'}))
 
     def __init__(self, *args, **kwargs):
         self.searchqueryset = kwargs.pop('searchqueryset', None)


Test patch: