czlll/Loc-Bench_V0.1 huggingface dataset:
Repository: vitalik/django-ninja
Issue category: Bug Report

[BUG] Object of type Url is not JSON serializable
**Describe the bug**
django-ninja = "^1.3.0"

Using `HttpUrl` (or, I suspect, any *Url class) for a schema used in a response results in json serialization error. This is the same type of issue as #717.

```pytb
Traceback (most recent call last):
  File "/home/adys/.cache/pypoetry/virtualenvs/fabrile-backend-fklT6p4J-py3.10/lib/python3.10/site-packages/ninja/operation.py", line 121, in run
    return self._result_to_response(request, result, temporal_response)
  File "/home/adys/.cache/pypoetry/virtualenvs/fabrile-backend-fklT6p4J-py3.10/lib/python3.10/site-packages/ninja/operation.py", line 278, in _result_to_response
    return self.api.create_response(
  File "/home/adys/.cache/pypoetry/virtualenvs/fabrile-backend-fklT6p4J-py3.10/lib/python3.10/site-packages/ninja/main.py", line 453, in create_response
    content = self.renderer.render(request, data, response_status=status)
  File "/home/adys/.cache/pypoetry/virtualenvs/fabrile-backend-fklT6p4J-py3.10/lib/python3.10/site-packages/ninja/renderers.py", line 25, in render
    return json.dumps(data, cls=self.encoder_class, **self.json_dumps_params)
  File "/usr/lib/python3.10/json/__init__.py", line 238, in dumps
    **kw).encode(obj)
  File "/usr/lib/python3.10/json/encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/usr/lib/python3.10/json/encoder.py", line 257, in iterencode
    return _iterencode(o, 0)
  File "/home/adys/.cache/pypoetry/virtualenvs/fabrile-backend-fklT6p4J-py3.10/lib/python3.10/site-packages/ninja/responses.py", line 28, in default
    return super().default(o)
  File "/home/adys/.cache/pypoetry/virtualenvs/fabrile-backend-fklT6p4J-py3.10/lib/python3.10/site-packages/django/core/serializers/json.py", line 106, in default
    return super().default(o)
  File "/usr/lib/python3.10/json/encoder.py", line 179, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type Url is not JSON serializable
```


Functions to edit:
ninja/responses.py:NinjaJSONEncoder.default

Patch:
diff --git a/ninja/responses.py b/ninja/responses.py
index babd366e..6a0fd4ca 100644
--- a/ninja/responses.py
+++ b/ninja/responses.py
@@ -1,10 +1,11 @@
 from enum import Enum
-from ipaddress import IPv4Address, IPv6Address
+from ipaddress import IPv4Address, IPv4Network, IPv6Address, IPv6Network
 from typing import Any, FrozenSet
 
 from django.core.serializers.json import DjangoJSONEncoder
 from django.http import JsonResponse
 from pydantic import BaseModel
+from pydantic_core import Url
 
 __all__ = [
     "NinjaJSONEncoder",
@@ -21,7 +22,9 @@ class NinjaJSONEncoder(DjangoJSONEncoder):
     def default(self, o: Any) -> Any:
         if isinstance(o, BaseModel):
             return o.model_dump()
-        if isinstance(o, (IPv4Address, IPv6Address)):
+        if isinstance(o, Url):
+            return str(o)
+        if isinstance(o, (IPv4Address, IPv4Network, IPv6Address, IPv6Network)):
             return str(o)
         if isinstance(o, Enum):
             return str(o)
Repository: pandas-dev/pandas
Issue category: Bug Report

DOC: Incorrect deprecation example for `is_period_dtype`
### Pandas version checks

- [X] I have checked that the issue still exists on the latest versions of the docs on `main` [here](https://pandas.pydata.org/docs/dev/)


### Location of the documentation

https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.api.types.is_period_dtype.html#pandas.api.types.is_period_dtype

### Documentation problem

Suggests the user use `isinstance(dtype, pd.Period)` instead, when they really need to use `Use isinstance(dtype, pd.PeriodDtype)`

### Suggested fix for documentation

Update message to reference correct class


Functions to edit:
pandas/core/dtypes/common.py:is_period_dtype

Patch:
diff --git a/pandas/core/dtypes/common.py b/pandas/core/dtypes/common.py
index 6fa21d9410187..b0c8ec1ffc083 100644
--- a/pandas/core/dtypes/common.py
+++ b/pandas/core/dtypes/common.py
@@ -430,7 +430,7 @@ def is_period_dtype(arr_or_dtype) -> bool:
     Check whether an array-like or dtype is of the Period dtype.
 
     .. deprecated:: 2.2.0
-        Use isinstance(dtype, pd.Period) instead.
+        Use isinstance(dtype, pd.PeriodDtype) instead.
 
     Parameters
     ----------
Repository: pandas-dev/pandas
Issue category: Bug Report

DOC: methods in see also section in the  pandas.DataFrame.size  are not hyperlinks
### Pandas version checks

- [X] I have checked that the issue still exists on the latest versions of the docs on `main` [here](https://pandas.pydata.org/docs/dev/)


### Location of the documentation

https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.size.html

### Documentation problem

In the see also section the `ndarray.size` method is listed, but it is not hyperlinks and thus the reader cannot navigate with ease but has to look for them instead. 

### Suggested fix for documentation

Add numpy.ndarray.size in the docstring. 


Functions to edit:
pandas/core/generic.py:NDFrame.size

Patch:
diff --git a/pandas/core/generic.py b/pandas/core/generic.py
index d1aa20501b060..de7fb3682fb4f 100644
--- a/pandas/core/generic.py
+++ b/pandas/core/generic.py
@@ -665,7 +665,7 @@ def size(self) -> int:
 
         See Also
         --------
-        ndarray.size : Number of elements in the array.
+        numpy.ndarray.size : Number of elements in the array.
 
         Examples
         --------
Repository: pandas-dev/pandas
Issue category: Feature Request

DOC: Add examples for float_format in to_csv documentation
### Pandas version checks

- [X] I have checked that the issue still exists on the latest versions of the docs on `main` [here](https://pandas.pydata.org/docs/dev/)


### Location of the documentation

https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.to_csv.html

### Documentation problem

The float_format parameter in to_csv is explained but lacks examples. Users might struggle to understand how to apply this parameter effectively without concrete examples in the documentation.

### Suggested fix for documentation

I suggest adding examples for float_format to make the documentation more beginner-friendly. Examples could include:

```
# Format floats to two decimal places
df.to_csv("example1.csv", float_format="%.2f")

# Use scientific notation
df.to_csv("example2.csv", float_format="{:.2e}".format)
```


Functions to edit:
pandas/core/generic.py:NDFrame.to_csv

Patch:
diff --git a/pandas/core/generic.py b/pandas/core/generic.py
index a6be17a654aa7..3a48cc8a66076 100644
--- a/pandas/core/generic.py
+++ b/pandas/core/generic.py
@@ -3878,6 +3878,14 @@ def to_csv(
         >>> import os  # doctest: +SKIP
         >>> os.makedirs("folder/subfolder", exist_ok=True)  # doctest: +SKIP
         >>> df.to_csv("folder/subfolder/out.csv")  # doctest: +SKIP
+
+        Format floats to two decimal places:
+
+        >>> df.to_csv("out1.csv", float_format="%.2f")  # doctest: +SKIP
+
+        Format floats using scientific notation:
+
+        >>> df.to_csv("out2.csv", float_format="{{:.2e}}".format)  # doctest: +SKIP
         """
         df = self if isinstance(self, ABCDataFrame) else self.to_frame()
Repository: pandas-dev/pandas
Issue category: Feature Request

DOC: Missing type hint for squeeze method
### Pandas version checks

- [X] I have checked that the issue still exists on the latest versions of the docs on `main` [here](https://pandas.pydata.org/docs/dev/)


### Location of the documentation

https://github.com/pandas-dev/pandas/blob/main/pandas/core/generic.py

### Documentation problem

The squeeze method is missing a type hint. 

### Suggested fix for documentation

Adding a type hint to the squeeze method to be consistent with the rest of the code. 


Functions to edit:
pandas/core/generic.py:NDFrame.squeeze

Patch:
diff --git a/pandas/core/generic.py b/pandas/core/generic.py
index 039bdf9c36ee7..a6be17a654aa7 100644
--- a/pandas/core/generic.py
+++ b/pandas/core/generic.py
@@ -838,7 +838,7 @@ def pop(self, item: Hashable) -> Series | Any:
         return result
 
     @final
-    def squeeze(self, axis: Axis | None = None):
+    def squeeze(self, axis: Axis | None = None) -> Scalar | Series | DataFrame:
         """
         Squeeze 1 dimensional axis objects into scalars.
Repository: pandas-dev/pandas
Issue category: Bug Report

DOC: Fix docstring typo
### Pandas version checks

- [X] I have checked that the issue still exists on the latest versions of the docs on `main` [here](https://pandas.pydata.org/docs/dev/)


### Location of the documentation

https://github.com/pandas-dev/pandas/blob/main/pandas/core/series.py

### Documentation problem

The docstring for the __arrow_c_stream__ method in the Series class uses the word "behaviour".

### Suggested fix for documentation

Suggested to rewrite as "behavior", which is the American English spelling, to maintain consistency with the rest of the Pandas codebase.


Functions to edit:
pandas/core/series.py:Series.__arrow_c_stream__
pandas/core/series.py:Series.drop_duplicates
pandas/core/series.py:Series.sort_values
pandas/core/series.py:Series.swaplevel

Patch:
diff --git a/pandas/core/series.py b/pandas/core/series.py
index 35b576da87ed7..4fa8b86fa4c16 100644
--- a/pandas/core/series.py
+++ b/pandas/core/series.py
@@ -567,7 +567,7 @@ def __arrow_c_stream__(self, requested_schema=None):
         Export the pandas Series as an Arrow C stream PyCapsule.
 
         This relies on pyarrow to convert the pandas Series to the Arrow
-        format (and follows the default behaviour of ``pyarrow.Array.from_pandas``
+        format (and follows the default behavior of ``pyarrow.Array.from_pandas``
         in its handling of the index, i.e. to ignore it).
         This conversion is not necessarily zero-copy.
 
@@ -2226,7 +2226,7 @@ def drop_duplicates(
         5     hippo
         Name: animal, dtype: object
 
-        With the 'keep' parameter, the selection behaviour of duplicated values
+        With the 'keep' parameter, the selection behavior of duplicated values
         can be changed. The value 'first' keeps the first occurrence for each
         set of duplicated entries. The default value of keep is 'first'.
 
@@ -3451,7 +3451,7 @@ def sort_values(
         4     5.0
         dtype: float64
 
-        Sort values ascending order (default behaviour)
+        Sort values ascending order (default behavior)
 
         >>> s.sort_values(ascending=True)
         1     1.0
@@ -4098,7 +4098,7 @@ def swaplevel(
 
         In the following example, we will swap the levels of the indices.
         Here, we will swap the levels column-wise, but levels can be swapped row-wise
-        in a similar manner. Note that column-wise is the default behaviour.
+        in a similar manner. Note that column-wise is the default behavior.
         By not supplying any arguments for i and j, we swap the last and second to
         last indices.
Repository: pandas-dev/pandas
Issue category: Bug Report

DOC: Dataframe.from_records should not say that passing in a DataFrame for data is allowed
### Pandas version checks

- [X] I have checked that the issue still exists on the latest versions of the docs on `main` [here](https://pandas.pydata.org/docs/dev/)


### Location of the documentation

https://pandas.pydata.org/docs/dev/reference/api/pandas.DataFrame.from_records.html#pandas.DataFrame.from_records

### Documentation problem

The first text in the docstring says (emphasis at the end is mine)

> Convert structured or record ndarray to DataFrame.
>
> Creates a DataFrame object from a structured ndarray, sequence of
> tuples or dicts, or **DataFrame**.

However, starting in 2.1.0, passing in a DataFrame has been deprecated. In 2.1.0 it would raise a FutureWarning; in main it will raise a TyperError.

The documentation between 2.1.0 and main appear to have been updated to remove text in the Parameters section of the docstring that still said a DataFrame could be passed in for data, but the text in the initial section of the docstring was not.

### Suggested fix for documentation

Change the initial docstring text to be:

> Convert structured or record ndarray to DataFrame.
>
> Creates a DataFrame object from a structured ndarray or sequence of
> tuples or dicts.


Functions to edit:
pandas/core/frame.py:DataFrame.from_records

Patch:
diff --git a/pandas/core/frame.py b/pandas/core/frame.py
index b35e2c8497fb7..34eb198b4b4da 100644
--- a/pandas/core/frame.py
+++ b/pandas/core/frame.py
@@ -2115,8 +2115,8 @@ def from_records(
         """
         Convert structured or record ndarray to DataFrame.
 
-        Creates a DataFrame object from a structured ndarray, sequence of
-        tuples or dicts, or DataFrame.
+        Creates a DataFrame object from a structured ndarray, or sequence of
+        tuples or dicts.
 
         Parameters
         ----------
Repository: pandas-dev/pandas
Issue category: Feature Request

DOC: Document merge_cells="columns" in to_excel
https://pandas.pydata.org/docs/dev/reference/api/pandas.DataFrame.to_excel.html

The `merge_cells` argument can also take `"columns"` due to #35384. This should be added to the docstring.


Functions to edit:
pandas/core/generic.py:NDFrame.to_excel

Patch:
diff --git a/pandas/core/generic.py b/pandas/core/generic.py
index 35014674565ff..3a83a3997f881 100644
--- a/pandas/core/generic.py
+++ b/pandas/core/generic.py
@@ -2211,8 +2211,9 @@ def to_excel(
             via the options ``io.excel.xlsx.writer`` or
             ``io.excel.xlsm.writer``.
 
-        merge_cells : bool, default True
-            Write MultiIndex and Hierarchical Rows as merged cells.
+        merge_cells : bool or 'columns', default False
+            If True, write MultiIndex index and columns as merged cells.
+            If 'columns', merge MultiIndex column cells only.
         {encoding_parameter}
         inf_rep : str, default 'inf'
             Representation for infinity (there is no native representation for
Repository: pandas-dev/pandas
Issue category: Feature Request

DOC: Improve documentation df.interpolate() for methods   ‘time’, ‘index’ and ‘values’
### Pandas version checks

- [X] I have checked that the issue still exists on the latest versions of the docs on `main` [here](https://pandas.pydata.org/docs/dev/)


### Location of the documentation

https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.interpolate.html

### Documentation problem

It is not possible to understand what exactly the method `interpolate` does from reading the documentation. See e.g. this SE post for more details

https://stackoverflow.com/questions/65511992/pandas-interpolation-type-when-method-index

### Suggested fix for documentation

Rewrite doctstring and documentation page for the method


Functions to edit:
pandas/core/generic.py:NDFrame.interpolate

Patch:
diff --git a/pandas/core/generic.py b/pandas/core/generic.py
index 7c2cc5d33a5db..56031f20faa16 100644
--- a/pandas/core/generic.py
+++ b/pandas/core/generic.py
@@ -7668,8 +7668,12 @@ def interpolate(
             * 'linear': Ignore the index and treat the values as equally
               spaced. This is the only method supported on MultiIndexes.
             * 'time': Works on daily and higher resolution data to interpolate
-              given length of interval.
-            * 'index', 'values': use the actual numerical values of the index.
+              given length of interval. This interpolates values based on
+              time interval between observations.
+            * 'index': The interpolation uses the numerical values
+              of the DataFrame's index to linearly calculate missing values.
+            * 'values': Interpolation based on the numerical values
+              in the DataFrame, treating them as equally spaced along the index.
             * 'nearest', 'zero', 'slinear', 'quadratic', 'cubic',
               'barycentric', 'polynomial': Passed to
               `scipy.interpolate.interp1d`, whereas 'spline' is passed to
Repository: pandas-dev/pandas
Issue category: Feature Request

DOC: Distinguish between Series.round and Series.dt.round
### Pandas version checks

- [X] I have checked that the issue still exists on the latest versions of the docs on `main` [here](https://pandas.pydata.org/docs/dev/)


### Location of the documentation

https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.round.html#pandas.Series.round

### Documentation problem

When using Series.round, it does not work on date data.

### Suggested fix for documentation

Adding Series.dt.round in the "See also" section would make it more convenient for users to find the relevant documentation.
https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.dt.round.html


Functions to edit:
pandas/core/series.py:Series.round

Patch:
diff --git a/pandas/core/series.py b/pandas/core/series.py
index fe2bb0b5aa5c3..d83d9715878f8 100644
--- a/pandas/core/series.py
+++ b/pandas/core/series.py
@@ -2482,6 +2482,7 @@ def round(self, decimals: int = 0, *args, **kwargs) -> Series:
         --------
         numpy.around : Round values of an np.array.
         DataFrame.round : Round values of a DataFrame.
+        Series.dt.round : Round values of data to the specified freq.
 
         Notes
         -----
Repository: huggingface/accelerate
Issue category: Bug Report

Calling infer_auto_device_map() with max_memory=None throws an error in version 1.2.0
### System Info

```Shell
accelerate==1.2.0
```

### Reproduction

Bug is from this commit:
https://github.com/huggingface/accelerate/commit/d7b1b368e9f484a18636a71600566b757d5cf87e

`max_memory` initialization was moved into `_init_infer_auto_device_map`, which does not return the `max_memory` value.

So if max_memory=None is passed to `infer_auto_device_map` (the default value), then it will still be None at line 1415:
https://github.com/huggingface/accelerate/blob/cb8b7c637a8588668c52bd306f9b2828f69d9585/src/accelerate/utils/modeling.py#L1415

Leading to error: TypeError: 'NoneType' object is not subscriptable

### Expected behavior

max_memory=None when passed to `infer_auto_device_map` does not throw an error.


Functions to edit:
src/accelerate/utils/modeling.py:_init_infer_auto_device_map
src/accelerate/utils/modeling.py:infer_auto_device_map

Patch:
diff --git a/src/accelerate/utils/modeling.py b/src/accelerate/utils/modeling.py
index 5f88e54e3c9..806f930acaa 100644
--- a/src/accelerate/utils/modeling.py
+++ b/src/accelerate/utils/modeling.py
@@ -1101,6 +1101,7 @@ def _init_infer_auto_device_map(
     special_dtypes: Optional[Dict[str, Union[str, torch.device]]] = None,
 ) -> Tuple[
     List[Union[int, str]],
+    Dict[Union[int, str], Union[int, str]],
     List[Union[int, str]],
     List[int],
     Dict[str, int],
@@ -1147,6 +1148,7 @@ def _init_infer_auto_device_map(
 
     return (
         devices,
+        max_memory,
         main_devices,
         gpus,
         module_sizes,
@@ -1356,6 +1358,7 @@ def infer_auto_device_map(
     # Initialize the variables
     (
         devices,
+        max_memory,
         main_devices,
         gpus,
         module_sizes,
Repository: huggingface/trl
Issue category: Bug Report

RLOO Trainer Stopping After 1 Epoch
### System Info

- Platform: Linux-3.10.0-693.11.6.el7.x86_64-x86_64-with-glibc2.17
- Python version: 3.9.5
- PyTorch version: 2.4.0
- CUDA device(s): not available
- Transformers version: 4.46.2
- Accelerate version: 1.1.1
- Accelerate config: not found
- Datasets version: 3.1.0
- HF Hub version: 0.26.2
- TRL version: 0.13.0.dev0
- bitsandbytes version: not installed
- DeepSpeed version: 0.15.4
- Diffusers version: not installed
- Liger-Kernel version: not installed
- LLM-Blender version: not installed
- OpenAI version: 1.54.4
- PEFT version: not installed

### Information

- [X] The official example scripts
- [ ] My own modified scripts

### Tasks

- [X] An officially supported task in the `examples` folder
- [ ] My own task or dataset (give details below)

### Reproduction

While reproducing RLOO using a multi-GPU setup with official [script](https://huggingface.co/docs/trl/en/rloo_trainer#benchmark-experiments), training consistently halts midway, regardless of whether it's set for 1,000 or 1 million episodes. An example wandb [run](https://wandb.ai/omerveyselcagatan/huggingface/runs/zdftqdx5?nw=nwuseromerveyselcagatan) that ended with 1954 steps, whereas it should  3908. 

### Expected behavior

Should have run for 3908, or possible step miscalculation.

### Checklist

- [X] I have checked that my issue isn't already filed (see [open issues](https://github.com/huggingface/trl/issues?q=is%3Aissue))
- [X] I have included my system information
- [X] Any code provided is minimal, complete, and reproducible ([more on MREs](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/creating-and-highlighting-code-blocks))
- [X] Any code provided is properly formatted in code blocks, (no screenshot, [more on code blocks](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/creating-and-highlighting-code-blocks))
- [X] Any traceback provided is complete


Functions to edit:
trl/trainer/rloo_trainer.py:RLOOTrainer.train

Patch:
diff --git a/trl/trainer/rloo_trainer.py b/trl/trainer/rloo_trainer.py
index 106426073f..f2e3eb9674 100644
--- a/trl/trainer/rloo_trainer.py
+++ b/trl/trainer/rloo_trainer.py
@@ -279,7 +279,7 @@ def repeat_generator():
         # trainer state initialization
         self.state.global_step = 0
         self.state.episode = 0
-        self.state.max_steps = args.num_total_batches * args.num_mini_batches
+        self.state.max_steps = (args.num_total_batches * args.num_mini_batches) // 2
         self.state.num_train_epochs = args.total_episodes / self.train_dataset_len
         # Compute absolute values for logging, eval, and save if given as ratio
         if args.logging_steps is not None:
Repository: huggingface/trl
Issue category: Bug Report

Wrong tensor index for roll and truncate in DPOTrainer fn concatenated_forward( ).
### System Info

it is a tensor index error

### Information

- [X] The official example scripts
- [ ] My own modified scripts

### Tasks

- [ ] An officially supported task in the `examples` folder
- [ ] My own task or dataset (give details below)

### Reproduction

```python
# Get the first column idx that is all zeros and remove every column after that
empty_cols = torch.sum(attention_mask, dim=0) == 0
first_empty_col = torch.nonzero(empty_cols)[0].item() if empty_cols.any() else attention_mask.size(1) + 1
input_ids = input_ids[:, : first_empty_col - 1]
attention_mask = attention_mask[:, : first_empty_col - 1]
loss_mask = loss_mask[:, : first_empty_col - 1]
```

### Expected behavior

The returns of _torch.nonzero_ is the index (starts from 0) of non-zero elements, so there is no need to add -1 to _first_empty_col_. 
The correct code should be:
```python
empty_cols = torch.sum(attention_mask, dim=0) == 0
first_empty_col = torch.nonzero(empty_cols)[0].item() if empty_cols.any() else attention_mask.size(1)
input_ids = input_ids[:, : first_empty_col]
attention_mask = attention_mask[:, : first_empty_col]
loss_mask = loss_mask[:, : first_empty_col]
```


Functions to edit:
trl/trainer/dpo_trainer.py:DPOTrainer.concatenated_forward

Patch:
diff --git a/trl/trainer/dpo_trainer.py b/trl/trainer/dpo_trainer.py
index b563cab2f5..0c9883387a 100644
--- a/trl/trainer/dpo_trainer.py
+++ b/trl/trainer/dpo_trainer.py
@@ -1086,10 +1086,10 @@ def concatenated_forward(self, model: nn.Module, batch: Dict[str, Union[List, to
 
             # Get the first column idx that is all zeros and remove every column after that
             empty_cols = torch.sum(attention_mask, dim=0) == 0
-            first_empty_col = torch.nonzero(empty_cols)[0].item() if empty_cols.any() else attention_mask.size(1) + 1
-            input_ids = input_ids[:, : first_empty_col - 1]
-            attention_mask = attention_mask[:, : first_empty_col - 1]
-            loss_mask = loss_mask[:, : first_empty_col - 1]
+            first_empty_col = torch.nonzero(empty_cols)[0].item() if empty_cols.any() else attention_mask.size(1)
+            input_ids = input_ids[:, : first_empty_col]
+            attention_mask = attention_mask[:, : first_empty_col]
+            loss_mask = loss_mask[:, : first_empty_col]
 
             # Truncate right
             if self.args.max_length is not None:
Repository: sympy/sympy
Issue category: Bug Report

DOC: outdated information about adaptive sampling in plot() function
I have recently learned (https://github.com/mgeier/python-audio/issues/4) that SymPy doesn't use adaptive sampling by default anymore.

Therefore, this documentation is outdated:

https://github.com/sympy/sympy/blob/a7719e719c0b43ec1dbb964b01b57c4f3783be8d/sympy/plotting/plot.py#L304-L305

https://github.com/sympy/sympy/blob/a7719e719c0b43ec1dbb964b01b57c4f3783be8d/sympy/plotting/plot.py#L380-L389


Functions to edit:
sympy/plotting/plot.py:plot

Patch:
diff --git a/sympy/plotting/plot.py b/sympy/plotting/plot.py
index 63da0440dabb..50029392a1ac 100644
--- a/sympy/plotting/plot.py
+++ b/sympy/plotting/plot.py
@@ -301,8 +301,8 @@ def plot(*args, show=True, **kwargs):
         :external:meth:`~matplotlib.axes.Axes.fill_between` method.
 
     adaptive : bool, optional
-        The default value is set to ``True``. Set adaptive to ``False``
-        and specify ``n`` if uniform sampling is required.
+        The default value for the ``adaptive`` parameter is now ``False``.
+        To enable adaptive sampling, set ``adaptive=True`` and specify ``n`` if uniform sampling is required.
 
         The plotting uses an adaptive algorithm which samples
         recursively to accurately plot. The adaptive algorithm uses a
@@ -377,14 +377,14 @@ def plot(*args, show=True, **kwargs):
        [0]: cartesian line: x**2 for x over (-6.0, 6.0)
        [1]: cartesian line: x for x over (-5.0, 5.0)
 
-    No adaptive sampling.
+    No adaptive sampling by default. If adaptive sampling is required, set ``adaptive=True``.
 
     .. plot::
        :context: close-figs
        :format: doctest
        :include-source: True
 
-       >>> plot(x**2, adaptive=False, n=400)
+       >>> plot(x**2, adaptive=True, n=400)
        Plot object containing:
        [0]: cartesian line: x**2 for x over (-10.0, 10.0)
Repository: SYSTRAN/faster-whisper
Issue category: Performance Issue

OOM when using VAD
Hi, does somebody else experience issues with memory consumption when transcribing audio files containing a lot of speech (~ 4 hours long)? I am running the latest version of faster-whisper in a Kubernetes pod on a g4dn AWS instance. The server has 4 cores, 1 GPU, and 16GB RAM, but the pod is limited to 2 cores. The base image is `pytorch/pytorch:2.5.1-cuda12.4-cudnn9-runtime` and as per [this pinned issue](https://github.com/SYSTRAN/faster-whisper/issues/1086) the installed versions should be compatible:
- python 3.11
- torch 2.5.1+cu124
- ctranslate2 4.5.0
- cuda 12.4
- cudnn 9.1.0.7

The process gets killed during the transcription phase when VAD is enabled. I tried the solution [described here](https://github.com/snakers4/silero-vad/issues/356), but it doesn't help. See the logs attached. Anyone has any idea what could be the cause of the OOM?

[libraries.txt](https://github.com/user-attachments/files/18039471/libraries.txt)
[logs on sigkill.txt](https://github.com/user-attachments/files/18039459/logs.on.sigkill.txt)


Functions to edit:
faster_whisper/vad.py:SileroVADModel.__init__
faster_whisper/vad.py:SileroVADModel.__call__

Patch:
diff --git a/faster_whisper/vad.py b/faster_whisper/vad.py
index 9605931c..1f7d2057 100644
--- a/faster_whisper/vad.py
+++ b/faster_whisper/vad.py
@@ -260,8 +260,9 @@ def __init__(self, encoder_path, decoder_path):
             ) from e
 
         opts = onnxruntime.SessionOptions()
-        opts.inter_op_num_threads = 0
-        opts.intra_op_num_threads = 0
+        opts.inter_op_num_threads = 1
+        opts.intra_op_num_threads = 1
+        opts.enable_cpu_mem_arena = False
         opts.log_severity_level = 4
 
         self.encoder_session = onnxruntime.InferenceSession(
@@ -301,7 +302,16 @@ def __call__(
 
         batched_audio = batched_audio.reshape(-1, num_samples + context_size_samples)
 
-        encoder_output = self.encoder_session.run(None, {"input": batched_audio})[0]
+        encoder_batch_size = 10000
+        num_segments = batched_audio.shape[0]
+        encoder_outputs = []
+        for i in range(0, num_segments, encoder_batch_size):
+            encoder_output = self.encoder_session.run(
+                None, {"input": batched_audio[i : i + encoder_batch_size]}
+            )[0]
+            encoder_outputs.append(encoder_output)
+
+        encoder_output = np.concatenate(encoder_outputs, axis=0)
         encoder_output = encoder_output.reshape(batch_size, -1, 128)
 
         decoder_outputs = []
Repository: phidatahq/phidata
Issue category: Bug Report

Duplicate key value violates unique constraint with recursive chunking
When use `RecursiveChunking` with large files, some errors happen:

```
ERROR    Error with batch starting at index 0: (psycopg.errors.UniqueViolation) duplicate key value violates unique constraint "recipes_agentic_recursive_chunking_pkey"
         DETAIL:  Key (id)=(relativity_1) already exists.
```



Functions to edit:
phi/document/chunking/recursive.py:RecursiveChunking.chunk

Patch:
diff --git a/phi/document/chunking/recursive.py b/phi/document/chunking/recursive.py
index 662a9218c..47c552294 100644
--- a/phi/document/chunking/recursive.py
+++ b/phi/document/chunking/recursive.py
@@ -38,6 +38,7 @@ def chunk(self, document: Document) -> List[Document]:
             chunk_id = None
             if document.id:
                 chunk_id = f"{document.id}_{chunk_number}"
+            chunk_number += 1
             meta_data["chunk_size"] = len(chunk)
             chunks.append(Document(id=chunk_id, name=document.name, meta_data=meta_data, content=chunk))
Repository: nltk/nltk
Issue category: Bug Report

Missing procedure call in line 417
Line 417 of the file "nltk/app/wordnet_app.py" should look like this:

    elif synset.pos() == wn.ADJ or synset.pos() == wn.ADJ_SAT:

but instead looks like this:

    elif synset.pos() == wn.ADJ or synset.pos == wn.ADJ_SAT:

which will generate this error (complete with spelling mistake) :

    "Unhandles synset POS type: s"



Functions to edit:
nltk/app/wordnet_app.py:get_relations_data

Patch:
diff --git a/nltk/app/wordnet_app.py b/nltk/app/wordnet_app.py
index 48fe1e30f6..437eb0f755 100644
--- a/nltk/app/wordnet_app.py
+++ b/nltk/app/wordnet_app.py
@@ -414,7 +414,7 @@ def get_relations_data(word, synset):
                 ),
             ),
         )
-    elif synset.pos() == wn.ADJ or synset.pos == wn.ADJ_SAT:
+    elif synset.pos() == wn.ADJ or synset.pos() == wn.ADJ_SAT:
         return (
             (ANTONYM, "Antonym", lemma_property(word, synset, lambda l: l.antonyms())),
             (SIMILAR, "Similar to", synset.similar_tos()),
@@ -435,7 +435,7 @@ def get_relations_data(word, synset):
         )
         # Derived from adjective - not supported by corpus
     else:
-        raise TypeError("Unhandles synset POS type: " + str(synset.pos()))
+        raise TypeError("Unhandled synset POS type: " + str(synset.pos()))
 
 
 html_header = """
Repository: kedro-org/kedro
Issue category: Bug Report

`kedro --version` isn't working 
## Description
Reported by @noklam, since adding lazy loading of Kedro subcommands, the `--version`/`-V` option isn't working. 

## Context
This bug is originating in Kedro 0.19.7 -> https://github.com/kedro-org/kedro/pull/3883


Functions to edit:
kedro/framework/cli/cli.py:KedroCLI.global_groups

Patch:
diff --git a/kedro/framework/cli/cli.py b/kedro/framework/cli/cli.py
index f5917e1b87..6ad4e24e97 100644
--- a/kedro/framework/cli/cli.py
+++ b/kedro/framework/cli/cli.py
@@ -217,7 +217,7 @@ def global_groups(self) -> Sequence[click.MultiCommand]:
         combines them with the built-in ones (eventually overriding the
         built-in ones if they are redefined by plugins).
         """
-        return [*load_entry_points("global"), cli, global_commands]
+        return [cli, *load_entry_points("global"), global_commands]
 
     @property
     def project_groups(self) -> Sequence[click.MultiCommand]:
Repository: dask/dask
Issue category: Performance Issue

`NestedContainer.to_container` method gets tracked individually per NestedContainer object
Looking into https://github.com/dask/distributed/issues/8958, I've noticed that for each `NestedContainer` object, its bound `to_container` method is tracked individually by the GC. This accounts for ~500k of 9MM objects in my workload. It would probably be better to stop tracking these individually.


Functions to edit:
dask/_task_spec.py:NestedContainer.__init__
dask/_task_spec.py:NestedContainer.to_container
dask/_task_spec.py:NestedContainer
Functions added: dask/_task_spec.py:NestedContainer

Patch:
diff --git a/dask/_task_spec.py b/dask/_task_spec.py
index 316f1805aa6..c108bbb5b6b 100644
--- a/dask/_task_spec.py
+++ b/dask/_task_spec.py
@@ -799,6 +799,7 @@ def __init__(
             None,
             self.to_container,
             *args,
+            klass=self.klass,
             _dependencies=_dependencies,
             **kwargs,
         )
@@ -832,9 +833,9 @@ def __dask_tokenize__(self):
 
         return super().__dask_tokenize__()
 
-    @classmethod
-    def to_container(cls, *args, **kwargs):
-        return cls.klass(args)
+    @staticmethod
+    def to_container(*args, klass):
+        return klass(args)
 
 
 class List(NestedContainer):
Repository: dask/dask
Issue category: Bug Report

Warning raised with default `from_zarr` settings

**Describe the issue**:
Reading a zarr array with `dask.array.from_zarr` raises a `UserWarning`, but I'm not doing anything wrong. 

**Minimal Complete Verifiable Example**:

```python
import dask.array
import zarr

zarr_arr = zarr.open(shape=(6, 6, 6), store="./zeros.zarr", chunks=(3, 3, 2), mode='w')
zarr_arr[:] = 0

dask_arr = dask.array.from_zarr("./zeros.zarr")
```

Raises:

```
/Users/dstansby/software/zarr/hackathon/.venv/lib/python3.12/site-packages/zarr/creation.py:614: UserWarning: ignoring keyword argument 'read_only'
  compressor, fill_value = _kwargs_compat(compressor, fill_value, kwargs)
```

**Anything else we need to know?**:

**Environment**:

- Dask version: 2024.11.2
- zarr version: 2.18.3
- Python version: 3.12
- Operating System: macOS
- Install method (conda, pip, source): pip



Functions to edit:
dask/array/core.py:from_zarr

Patch:
diff --git a/dask/array/core.py b/dask/array/core.py
index 10736af6f9d..0a7ebeb1b7c 100644
--- a/dask/array/core.py
+++ b/dask/array/core.py
@@ -3754,9 +3754,9 @@ def from_zarr(
                 store = zarr.storage.FSStore(url, **storage_options)
         else:
             store = url
-        z = zarr.open_array(store=store, read_only=True, path=component, **kwargs)
+        z = zarr.open_array(store=store, path=component, **kwargs)
     else:
-        z = zarr.open_array(store=url, read_only=True, path=component, **kwargs)
+        z = zarr.open_array(store=url, path=component, **kwargs)
     chunks = chunks if chunks is not None else z.chunks
     if name is None:
         name = "from-zarr-" + tokenize(z, component, storage_options, chunks, **kwargs)
Repository: dask/dask
Issue category: Bug Report

`map_blocks()` with `new_axis` output has incorrect shape
<!-- Please include a self-contained copy-pastable example that generates the issue if possible.

Please be concise with code posted. See guidelines below on how to provide a good bug report:

- Craft Minimal Bug Reports http://matthewrocklin.com/blog/work/2018/02/28/minimal-bug-reports
- Minimal Complete Verifiable Examples https://stackoverflow.com/help/mcve

Bug reports that follow these guidelines are easier to diagnose, and so are often handled much more quickly.
-->

**Describe the issue**:
When running `map_blocks()` with `new_axis` specified, the output shape of the dask array is not set correctly. In the below example I would expect it to be the same as the shape after computation.

**Minimal Complete Verifiable Example**:

```python
import dask.array as da
import numpy as np

def func(x):
    return np.stack([x, x + 0.5])

x = da.arange(6, chunks=2)
x_mapped = x.map_blocks(func, new_axis=[0])

print(x_mapped.shape)
# (1, 6)
print(x_mapped.compute().shape)
# (2, 6)
```

**Anything else we need to know?**:

**Environment**:

- Dask version: b7d9bf49f682de8d2ef51f4617e3da782400c290
- Python version: 3.12.3
- Operating System: macOS
- Install method (conda, pip, source): source



Functions to edit:
dask/array/core.py:map_blocks

Patch:
diff --git a/dask/array/core.py b/dask/array/core.py
index fdf65bd24a4..3065406a922 100644
--- a/dask/array/core.py
+++ b/dask/array/core.py
@@ -562,7 +562,9 @@ def map_blocks(
         Dimensions lost by the function.
     new_axis : number or iterable, optional
         New dimensions created by the function. Note that these are applied
-        after ``drop_axis`` (if present).
+        after ``drop_axis`` (if present). The size of each chunk along this
+        dimension will be set to 1. Please specify ``chunks`` if the individual
+        chunks have a different size.
     enforce_ndim : bool, default False
         Whether to enforce at runtime that the dimensionality of the array
         produced by ``func`` actually matches that of the array returned by
Repository: albumentations-team/albumentations
Issue category: Feature Request

[RandomSunFlare] Add transparency to RandomSunFlare
![image](https://github.com/user-attachments/assets/2c1a7dec-77db-4150-86df-d484da5e2e31)

Sunflare obscures the object


Functions to edit:
albumentations/augmentations/functional.py:add_sun_flare_overlay

Patch:
diff --git a/albumentations/augmentations/functional.py b/albumentations/augmentations/functional.py
index 52adf80df..2dc1dd07f 100644
--- a/albumentations/augmentations/functional.py
+++ b/albumentations/augmentations/functional.py
@@ -925,7 +925,12 @@ def add_sun_flare_overlay(
     overlay = img.copy()
     output = img.copy()
 
+    weighted_brightness = 0.0
+    total_radius_length = 0.0
+
     for alpha, (x, y), rad3, (r_color, g_color, b_color) in circles:
+        weighted_brightness += alpha * rad3
+        total_radius_length += rad3
         cv2.circle(overlay, (x, y), rad3, (r_color, g_color, b_color), -1)
         output = add_weighted(overlay, alpha, output, 1 - alpha)
 
@@ -933,7 +938,13 @@ def add_sun_flare_overlay(
 
     overlay = output.copy()
     num_times = src_radius // 10
-    alpha = np.linspace(0.0, 1, num=num_times)
+
+    # max_alpha is calculated using weighted_brightness and total_radii_length times 5
+    # meaning the higher the alpha with larger area, the brighter the bright spot will be
+    # for list of alphas in range [0.05, 0.2], the max_alpha should below 1
+    max_alpha = weighted_brightness / total_radius_length * 5
+    alpha = np.linspace(0.0, min(max_alpha, 1.0), num=num_times)
+
     rad = np.linspace(1, src_radius, num=num_times)
 
     for i in range(num_times):
Repository: bridgecrewio/checkov
Issue category: Feature Request

Add EKS 1.31 as a supported version
**Describe the issue**
EKS 1.31 has been released.  However `CKV_AWS_339` fails as this is not listed as a supported version.

**Examples**
```
resource "aws_eks_cluster" "eks_cluster" {
  ...
  version                   = "1.31"
```
**Version (please complete the following information):**
 - Checkov Version 3.2.256 (latest)

**Additional context**
https://github.com/bridgecrewio/checkov/blob/main/checkov/terraform/checks/resource/aws/EKSPlatformVersion.py seems to be where the fix is needed


Functions to edit:
checkov/terraform/checks/resource/aws/EKSPlatformVersion.py:EKSPlatformVersion.get_expected_values

Patch:
diff --git a/checkov/terraform/checks/resource/aws/EKSPlatformVersion.py b/checkov/terraform/checks/resource/aws/EKSPlatformVersion.py
index 563798a01d0..d2011578ec6 100644
--- a/checkov/terraform/checks/resource/aws/EKSPlatformVersion.py
+++ b/checkov/terraform/checks/resource/aws/EKSPlatformVersion.py
@@ -24,7 +24,8 @@ def get_inspected_key(self) -> str:
         return "version"
 
     def get_expected_values(self) -> list[Any]:
-        return ["1.23", "1.24", "1.25", "1.26", "1.27", "1.28", "1.29", "1.30"]
+        # https://docs.aws.amazon.com/eks/latest/userguide/kubernetes-versions.html
+        return ["1.24", "1.25", "1.26", "1.27", "1.28", "1.29", "1.30", "1.31"]
 
 
 check = EKSPlatformVersion()
Repository: robotframework/robotframework
Issue category: Bug Report

`logging` module log level is not restored after execution
Hi,

It seems like that the robot handler is changing the root logger log level via ``set_level`` function (``robot.output.pyloggingconf``) but the original root logger level is not restored back after the end of the ``robot.running.model.TestSuite.run`` method or ``robot.run`` module.

The original context manager:

```python
@contextmanager
def robot_handler_enabled(level):
    root = logging.getLogger()
    if any(isinstance(h, RobotHandler) for h in root.handlers):
        yield
        return
    handler = RobotHandler()
    old_raise = logging.raiseExceptions
    root.addHandler(handler)
    logging.raiseExceptions = False
    set_level(level)
    try:
        yield
    finally:
        root.removeHandler(handler)
        logging.raiseExceptions = old_raise
```

Would it be necessary to restore the log level after changing it, in case the test script or any other third-party tool has already modified it for any reason?

```python
@contextmanager
def robot_handler_enabled(level):
    root = logging.getLogger()
    if any(isinstance(h, RobotHandler) for h in root.handlers):
        yield
        return
    handler = RobotHandler()
    old_raise = logging.raiseExceptions
    * -> old_level = logging.getLevelName(root.level)
    root.addHandler(handler)
    logging.raiseExceptions = False
    set_level(level)
    try:
        yield
    finally:
        root.removeHandler(handler)
        logging.raiseExceptions = old_raise
        * -> set_level(old_level)
```


Functions to edit:
src/robot/output/pyloggingconf.py:robot_handler_enabled

Patch:
diff --git a/src/robot/output/pyloggingconf.py b/src/robot/output/pyloggingconf.py
index fdccb16329d..b2300a5ad21 100644
--- a/src/robot/output/pyloggingconf.py
+++ b/src/robot/output/pyloggingconf.py
@@ -36,6 +36,7 @@ def robot_handler_enabled(level):
         return
     handler = RobotHandler()
     old_raise = logging.raiseExceptions
+    old_level = root.level
     root.addHandler(handler)
     logging.raiseExceptions = False
     set_level(level)
@@ -43,6 +44,7 @@ def robot_handler_enabled(level):
         yield
     finally:
         root.removeHandler(handler)
+        root.setLevel(old_level)
         logging.raiseExceptions = old_raise
Repository: pymc-devs/pymc
Issue category: Bug Report

DOC: <MatrixNormal Example in Documentation not updated as per latest version ' prefix>
### Issue with current documentation:

The compute_corr parameter in pm.LKJCholeskyCov is set to True by default, which causes the error. 
Also discussed here: https://discourse.pymc.io/t/matrixnormal-example-in-documentation-throws-an-error/16171

### Idea or request for content:

Setting compute_corr=False resolves the problem. Will add a PR in a while.


Functions to edit:
pymc/distributions/multivariate.py:MatrixNormal
Functions added: pymc/distributions/multivariate.py:MatrixNormal

Patch:
diff --git a/pymc/distributions/multivariate.py b/pymc/distributions/multivariate.py
index bcc5b4fcef..e44008fe65 100644
--- a/pymc/distributions/multivariate.py
+++ b/pymc/distributions/multivariate.py
@@ -1791,14 +1791,21 @@ class MatrixNormal(Continuous):
     Examples
     --------
     Define a matrixvariate normal variable for given row and column covariance
-    matrices::
+    matrices.
 
-        colcov = np.array([[1.0, 0.5], [0.5, 2]])
-        rowcov = np.array([[1, 0, 0], [0, 4, 0], [0, 0, 16]])
-        m = rowcov.shape[0]
-        n = colcov.shape[0]
-        mu = np.zeros((m, n))
-        vals = pm.MatrixNormal("vals", mu=mu, colcov=colcov, rowcov=rowcov)
+    .. code:: python
+
+        import pymc as pm
+        import numpy as np
+        import pytensor.tensor as pt
+
+        with pm.Model() as model:
+            colcov = np.array([[1.0, 0.5], [0.5, 2]])
+            rowcov = np.array([[1, 0, 0], [0, 4, 0], [0, 0, 16]])
+            m = rowcov.shape[0]
+            n = colcov.shape[0]
+            mu = np.zeros((m, n))
+            vals = pm.MatrixNormal("vals", mu=mu, colcov=colcov, rowcov=rowcov)
 
     Above, the ith row in vals has a variance that is scaled by 4^i.
     Alternatively, row or column cholesky matrices could be substituted for
@@ -1827,16 +1834,13 @@ class MatrixNormal(Continuous):
         with pm.Model() as model:
             # Setup right cholesky matrix
             sd_dist = pm.HalfCauchy.dist(beta=2.5, shape=3)
-            colchol_packed = pm.LKJCholeskyCov('colcholpacked', n=3, eta=2,
-                                               sd_dist=sd_dist)
-            colchol = pm.expand_packed_triangular(3, colchol_packed)
-
+            colchol,_,_ = pm.LKJCholeskyCov('colchol', n=3, eta=2,sd_dist=sd_dist)
             # Setup left covariance matrix
             scale = pm.LogNormal('scale', mu=np.log(true_scale), sigma=0.5)
             rowcov = pt.diag([scale**(2*i) for i in range(m)])
 
             vals = pm.MatrixNormal('vals', mu=mu, colchol=colchol, rowcov=rowcov,
-                                   observed=data)
+                                observed=data)
     """
 
     rv_op = matrixnormal
Repository: ShishirPatil/gorilla
Issue category: Bug Report

[BFCL] bugs in function def _multi_threaded_inference(self, test_case, include_input_log: bool, include_state_log: bool):
**Describe the issue**
I encountered an error while running bfcl generate. The error occurred in the file gorilla/berkeley-function-call-leaderboard/bfcl/model_handler/oss_model/base_oss_handler.py in the function def _multi_threaded_inference(self, test_case, include_input_log: bool, include_state_log: bool):.

The line model_responses, metadata = self.inference_single_turn_prompting(test_case, include_input_log, include_state_log) caused a runtime error. I discovered that the function inference_single_turn_prompting only accepts the parameters test_case and include_input_log. However, the code additionally passes include_state_log, which leads to the runtime error. When I removed include_state_log, the code ran successfully.

**ID datapoint**
1. Datapoint / Model Handler permalink: 
2. Issue: 
2. Gorilla repo commit #: 

**What is the issue**
The function inference_single_turn_prompting does not accept include_state_log as a parameter, causing a runtime error when it is passed.
**Proposed Changes**

{
 'previous_datapoint':[], 
 'updated_datapoint':[]
}

**Additional context**
Add any other context about the problem here.



Functions to edit:
berkeley-function-call-leaderboard/bfcl/model_handler/oss_model/base_oss_handler.py:OSSHandler._multi_threaded_inference

Patch:
diff --git a/berkeley-function-call-leaderboard/bfcl/model_handler/oss_model/base_oss_handler.py b/berkeley-function-call-leaderboard/bfcl/model_handler/oss_model/base_oss_handler.py
index c58812641..c3fc3c8e5 100644
--- a/berkeley-function-call-leaderboard/bfcl/model_handler/oss_model/base_oss_handler.py
+++ b/berkeley-function-call-leaderboard/bfcl/model_handler/oss_model/base_oss_handler.py
@@ -224,7 +224,7 @@ def _multi_threaded_inference(self, test_case, include_input_log: bool, include_
             if "multi_turn" in test_case["id"]:
                 model_responses, metadata = self.inference_multi_turn_prompting(test_case, include_input_log, include_state_log)
             else:
-                model_responses, metadata = self.inference_single_turn_prompting(test_case, include_input_log, include_state_log)
+                model_responses, metadata = self.inference_single_turn_prompting(test_case, include_input_log)
         except Exception as e:
             print("-" * 100)
             print(