nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: Quantum-Accelerators/quacc
Pull request #2027 (2024-04-21 06:04:50)

Add a sanity check before writing out results
## Summary of Changes

Add a sanity check to I/O.

### Checklist

- [ ] I have read the ["Guidelines" section](https://quantum-accelerators.github.io/quacc/dev/contributing.html#guidelines) of the contributing guide. Don't lie! 😉
- [ ] My PR is on a custom branch and is _not_ named `main`.
- [ ] I have added relevant, comprehensive [unit tests](https://quantum-accelerators.github.io/quacc/dev/contributing.html#unit-tests).

### Notes

- Your PR will likely not be merged without proper and thorough tests.
- If you are an external contributor, you will see a comment from [@buildbot-princeton](https://github.com/buildbot-princeton). This is solely for the maintainers.
- When your code is ready for review, ping one of the [active maintainers](https://quantum-accelerators.github.io/quacc/about/contributors.html#active-maintainers).



Patch:
diff --git a/src/quacc/utils/dicts.py b/src/quacc/utils/dicts.py
index a39bae2e..d0265ad9 100644
--- a/src/quacc/utils/dicts.py
+++ b/src/quacc/utils/dicts.py
@@ -232,6 +232,8 @@ def finalize_dict(
     cleaned_task_doc = clean_dict(task_doc)
 
     if directory:
+        if "tmp-quacc" in str(directory):
+            raise ValueError("The directory should not be a temporary directory.")
         with (
             gzip.open(Path(directory, "quacc_results.pkl.gz"), "wb")
             if gzip_file


Test patch:
diff --git a/tests/core/utils/test_dicts.py b/tests/core/utils/test_dicts.py
index 8223ba8f..4a623d20 100644
--- a/tests/core/utils/test_dicts.py
+++ b/tests/core/utils/test_dicts.py
@@ -5,7 +5,7 @@ import logging
 import pytest
 
 from quacc import Remove
-from quacc.utils.dicts import recursive_dict_merge, remove_dict_entries
+from quacc.utils.dicts import finalize_dict, recursive_dict_merge, remove_dict_entries
 
 LOGGER = logging.getLogger(__name__)
 LOGGER.propagate = True
@@ -82,3 +82,8 @@ def test_recursive_dict_merge_verbose(caplog):
 def test_remove_instantiation():
     with pytest.raises(NotImplementedError):
         Remove()
+
+
+def test_finalize_dict():
+    with pytest.raises(ValueError, match="The directory should not"):
+        finalize_dict({}, "tmp-quacc")
Repository: Quantum-Accelerators/quacc
Pull request #2133 (2024-05-12 21:25:30)

Add a small test


Patch:
diff --git a/src/quacc/calculators/vasp/params.py b/src/quacc/calculators/vasp/params.py
index f0f47a13..cda4559d 100644
--- a/src/quacc/calculators/vasp/params.py
+++ b/src/quacc/calculators/vasp/params.py
@@ -398,11 +398,11 @@ class MPtoASEConverter:
         -------
         None
         """
+        if atoms is None and prev_dir is None:
+            raise ValueError("Either atoms or prev_dir must be provided.")
         self.atoms = atoms
         self.prev_dir = prev_dir
         self.structure = AseAtomsAdaptor.get_structure(atoms)
-        if atoms is None and prev_dir is None:
-            raise ValueError("Either atoms or prev_dir must be provided.")
 
     def convert_dict_set(self, dict_set: DictSet) -> dict:
         """


Test patch:
diff --git a/tests/core/calculators/vasp/test_vasp.py b/tests/core/calculators/vasp/test_vasp.py
index 907aefbf..061aa7d3 100644
--- a/tests/core/calculators/vasp/test_vasp.py
+++ b/tests/core/calculators/vasp/test_vasp.py
@@ -816,6 +816,11 @@ def test_preset_override():
     assert calc.parameters.get("efermi") is None
 
 
+def test_bad_pmg_converter():
+    with pytest.raises(ValueError, match="Either atoms or prev_dir must be provided"):
+        MPtoASEConverter()
+
+
 def test_pmg_input_set():
     atoms = bulk("Cu")
     parameters = MPtoASEConverter(atoms=atoms).convert_dict_set(MPRelaxSet)
Repository: Quantum-Accelerators/quacc
Pull request #2803 (2025-05-25 02:16:46)

Bug Fix: Line density KPOINTS file should be in reciprocal units


Patch:
diff --git a/src/quacc/utils/kpts.py b/src/quacc/utils/kpts.py
index da7b16ec..8a614beb 100644
--- a/src/quacc/utils/kpts.py
+++ b/src/quacc/utils/kpts.py
@@ -66,7 +66,7 @@ def convert_pmg_kpts(
             has_magmoms=np.any(struct.site_properties.get("magmom", None)),
         )
         kpts, _ = kpath.get_kpoints(
-            line_density=pmg_kpts["line_density"], coords_are_cartesian=True
+            line_density=pmg_kpts["line_density"], coords_are_cartesian=False
         )
         kpts = np.stack(kpts)
         gamma = False


Test patch:
diff --git a/tests/core/calculators/vasp/test_vasp.py b/tests/core/calculators/vasp/test_vasp.py
index bbdc3713..bc5f8faf 100644
--- a/tests/core/calculators/vasp/test_vasp.py
+++ b/tests/core/calculators/vasp/test_vasp.py
@@ -870,13 +870,16 @@ def test_ismear_aggressive():
         calc = Vasp(atoms, pmg_kpts={"line_density": 100}, ismear=1)
         assert calc.int_params["ismear"] == 0
         assert calc.float_params["sigma"] == 0.01
+        assert calc.todict()["reciprocal"] is True
 
         calc = Vasp(atoms, pmg_kpts={"line_density": 100}, ismear=0, sigma=1e-3)
         assert calc.int_params["ismear"] == 0
         assert calc.float_params["sigma"] == 1e-3
+        assert calc.todict()["reciprocal"] is True
 
         calc = Vasp(atoms, pmg_kpts={"line_density": 100}, ismear=-5)
         assert calc.int_params["ismear"] == 0
+        assert calc.todict()["reciprocal"] is True
 
         calc = Vasp(atoms, kspacing=1.0, ismear=-5)
         assert calc.int_params["ismear"] == 0
@@ -1077,9 +1080,8 @@ def test_kpoint_schemes():
 
     atoms = bulk("Cu")
     calc = Vasp(atoms, pmg_kpts={"line_density": 100})
-    assert calc.kpts[-1] == pytest.approx(
-        np.array([1.30537091e00, 1.11022302e-16, 1.30537091e00])
-    )
+    assert calc.todict()["reciprocal"] is True
+    assert calc.kpts[-1] == pytest.approx(np.array([0.375, 0.75, 0.375]))
 
 
 def test_constraints():
Repository: pandas-dev/pandas
Pull request #60220 (2024-11-06 20:04:32)

Backport PR #60215 on branch 2.3.x (BUG (string dtype): fix escaping of newline/tab characters in the repr)
Backport PR #60215: BUG (string dtype): fix escaping of newline/tab characters in the repr


Patch:
diff --git a/pandas/core/arrays/string_.py b/pandas/core/arrays/string_.py
index 92c274453b..4801b70a27 100644
--- a/pandas/core/arrays/string_.py
+++ b/pandas/core/arrays/string_.py
@@ -1,5 +1,6 @@
 from __future__ import annotations
 
+from functools import partial
 import operator
 from typing import (
     TYPE_CHECKING,
@@ -64,6 +65,8 @@ from pandas.core.construction import extract_array
 from pandas.core.indexers import check_array_indexer
 from pandas.core.missing import isna
 
+from pandas.io.formats import printing
+
 if TYPE_CHECKING:
     import pyarrow
 
@@ -387,6 +390,14 @@ class BaseStringArray(ExtensionArray):
             raise ValueError
         return cls._from_sequence(scalars, dtype=dtype)
 
+    def _formatter(self, boxed: bool = False):
+        formatter = partial(
+            printing.pprint_thing,
+            escape_chars=("\t", "\r", "\n"),
+            quote_strings=not boxed,
+        )
+        return formatter
+
     def _str_map(
         self,
         f,


Test patch:
diff --git a/pandas/tests/frame/test_repr.py b/pandas/tests/frame/test_repr.py
index f7700af6be..6184e791ca 100644
--- a/pandas/tests/frame/test_repr.py
+++ b/pandas/tests/frame/test_repr.py
@@ -7,8 +7,6 @@ from io import StringIO
 import numpy as np
 import pytest
 
-from pandas._config import using_string_dtype
-
 from pandas import (
     NA,
     Categorical,
@@ -176,7 +174,6 @@ NaT   4"""
 
         repr(biggie)
 
-    @pytest.mark.xfail(using_string_dtype(), reason="/r in")
     def test_repr(self):
         # columns but no index
         no_index = DataFrame(columns=[0, 1, 3])
diff --git a/pandas/tests/series/test_formats.py b/pandas/tests/series/test_formats.py
index 77e77a9337..4f93e7424b 100644
--- a/pandas/tests/series/test_formats.py
+++ b/pandas/tests/series/test_formats.py
@@ -6,8 +6,6 @@ from datetime import (
 import numpy as np
 import pytest
 
-from pandas._config import using_string_dtype
-
 import pandas as pd
 from pandas import (
     Categorical,
@@ -144,11 +142,13 @@ class TestSeriesRepr:
         rep_str = repr(ser)
         assert "Name: 0" in rep_str
 
-    @pytest.mark.xfail(
-        using_string_dtype(), reason="TODO(infer_string): investigate failure"
-    )
-    def test_newline(self):
-        ser = Series(["a\n\r\tb"], name="a\n\r\td", index=["a\n\r\tf"])
+    def test_newline(self, any_string_dtype):
+        ser = Series(
+            ["a\n\r\tb"],
+            name="a\n\r\td",
+            index=Index(["a\n\r\tf"], dtype=any_string_dtype),
+            dtype=any_string_dtype,
+        )
         assert "\t" not in repr(ser)
         assert "\r" not in repr(ser)
         assert "a\n" not in repr(ser)
Repository: pandas-dev/pandas
Pull request #60222 (2024-11-06 20:54:31)

ENH (string dtype): accept string_view in addition to string/large_string for ArrowStringArray input
Looking into support for string dtype on the pyarrow side, and noticed we do not yet support string_view being converted to string dtype for the default pyarrow `to_pandas()` behaviour.


Patch:
diff --git a/pandas/core/arrays/string_arrow.py b/pandas/core/arrays/string_arrow.py
index cde39c7f4d..75e36feea2 100644
--- a/pandas/core/arrays/string_arrow.py
+++ b/pandas/core/arrays/string_arrow.py
@@ -17,6 +17,7 @@ from pandas._libs import (
 from pandas.compat import (
     pa_version_under10p1,
     pa_version_under13p0,
+    pa_version_under16p0,
 )
 from pandas.util._exceptions import find_stack_level
 
@@ -71,6 +72,10 @@ def _chk_pyarrow_available() -> None:
         raise ImportError(msg)
 
 
+def _is_string_view(typ):
+    return not pa_version_under16p0 and pa.types.is_string_view(typ)
+
+
 # TODO: Inherit directly from BaseStringArrayMethods. Currently we inherit from
 # ObjectStringArrayMixin because we want to have the object-dtype based methods as
 # fallback for the ones that pyarrow doesn't yet support
@@ -128,11 +133,13 @@ class ArrowStringArray(ObjectStringArrayMixin, ArrowExtensionArray, BaseStringAr
         _chk_pyarrow_available()
         if isinstance(values, (pa.Array, pa.ChunkedArray)) and (
             pa.types.is_string(values.type)
+            or _is_string_view(values.type)
             or (
                 pa.types.is_dictionary(values.type)
                 and (
                     pa.types.is_string(values.type.value_type)
                     or pa.types.is_large_string(values.type.value_type)
+                    or _is_string_view(values.type.value_type)
                 )
             )
         ):


Test patch:
diff --git a/pandas/tests/arrays/string_/test_string_arrow.py b/pandas/tests/arrays/string_/test_string_arrow.py
index d436317178..e6103da502 100644
--- a/pandas/tests/arrays/string_/test_string_arrow.py
+++ b/pandas/tests/arrays/string_/test_string_arrow.py
@@ -99,6 +99,20 @@ def test_constructor_valid_string_type_value_dictionary(string_type, chunked):
     assert pa.types.is_large_string(arr._pa_array.type)
 
 
+@pytest.mark.parametrize("chunked", [True, False])
+def test_constructor_valid_string_view(chunked):
+    # requires pyarrow>=18 for casting string_view to string
+    pa = pytest.importorskip("pyarrow", minversion="18")
+
+    arr = pa.array(["1", "2", "3"], pa.string_view())
+    if chunked:
+        arr = pa.chunked_array(arr)
+
+    arr = ArrowStringArray(arr)
+    # dictionary type get converted to dense large string array
+    assert pa.types.is_large_string(arr._pa_array.type)
+
+
 def test_constructor_from_list():
     # GH#27673
     pytest.importorskip("pyarrow")
Repository: pandas-dev/pandas
Pull request #60223 (2024-11-06 22:06:52)

Backport PR #60222 on branch 2.3.x (ENH (string dtype): accept string_view in addition to string/large_string for ArrowStringArray input)
Backport PR #60222: ENH (string dtype): accept string_view in addition to string/large_string for ArrowStringArray input


Patch:
diff --git a/pandas/core/arrays/string_arrow.py b/pandas/core/arrays/string_arrow.py
index e7dd4f9dc5..b6e98d8fdc 100644
--- a/pandas/core/arrays/string_arrow.py
+++ b/pandas/core/arrays/string_arrow.py
@@ -18,6 +18,7 @@ from pandas._libs import (
 from pandas.compat import (
     pa_version_under10p1,
     pa_version_under13p0,
+    pa_version_under16p0,
 )
 from pandas.util._exceptions import find_stack_level
 
@@ -65,6 +66,10 @@ def _chk_pyarrow_available() -> None:
         raise ImportError(msg)
 
 
+def _is_string_view(typ):
+    return not pa_version_under16p0 and pa.types.is_string_view(typ)
+
+
 # TODO: Inherit directly from BaseStringArrayMethods. Currently we inherit from
 # ObjectStringArrayMixin because we want to have the object-dtype based methods as
 # fallback for the ones that pyarrow doesn't yet support
@@ -122,11 +127,13 @@ class ArrowStringArray(ObjectStringArrayMixin, ArrowExtensionArray, BaseStringAr
         _chk_pyarrow_available()
         if isinstance(values, (pa.Array, pa.ChunkedArray)) and (
             pa.types.is_string(values.type)
+            or _is_string_view(values.type)
             or (
                 pa.types.is_dictionary(values.type)
                 and (
                     pa.types.is_string(values.type.value_type)
                     or pa.types.is_large_string(values.type.value_type)
+                    or _is_string_view(values.type.value_type)
                 )
             )
         ):


Test patch:
diff --git a/pandas/tests/arrays/string_/test_string_arrow.py b/pandas/tests/arrays/string_/test_string_arrow.py
index 2f3840e92b..aa87f5fc0f 100644
--- a/pandas/tests/arrays/string_/test_string_arrow.py
+++ b/pandas/tests/arrays/string_/test_string_arrow.py
@@ -99,6 +99,20 @@ def test_constructor_valid_string_type_value_dictionary(string_type, chunked):
     assert pa.types.is_large_string(arr._pa_array.type)
 
 
+@pytest.mark.parametrize("chunked", [True, False])
+def test_constructor_valid_string_view(chunked):
+    # requires pyarrow>=18 for casting string_view to string
+    pa = pytest.importorskip("pyarrow", minversion="18")
+
+    arr = pa.array(["1", "2", "3"], pa.string_view())
+    if chunked:
+        arr = pa.chunked_array(arr)
+
+    arr = ArrowStringArray(arr)
+    # dictionary type get converted to dense large string array
+    assert pa.types.is_large_string(arr._pa_array.type)
+
+
 def test_constructor_from_list():
     # GH#27673
     pytest.importorskip("pyarrow")
Repository: pandas-dev/pandas
Pull request #60264 (2024-11-09 16:04:43)

ENH: set __module__ on `date_range` and `bdate_range`
- [ ] Part of https://github.com/pandas-dev/pandas/issues/55178
- [ ] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature
- [ ] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit).
- [ ] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to new arguments/methods/functions.
- [ ] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature.

This decorates `date_range` and `bdate_range` with `@set_module('pandas')` (similar to https://github.com/pandas-dev/pandas/pull/55171)



Patch:
diff --git a/pandas/core/indexes/datetimes.py b/pandas/core/indexes/datetimes.py
index b3d9c3bc78..9adbaadbdc 100644
--- a/pandas/core/indexes/datetimes.py
+++ b/pandas/core/indexes/datetimes.py
@@ -816,6 +816,7 @@ class DatetimeIndex(DatetimeTimedeltaMixin):
         return mask.nonzero()[0]
 
 
+@set_module("pandas")
 def date_range(
     start=None,
     end=None,
@@ -1020,6 +1021,7 @@ def date_range(
     return DatetimeIndex._simple_new(dtarr, name=name)
 
 
+@set_module("pandas")
 def bdate_range(
     start=None,
     end=None,


Test patch:
diff --git a/pandas/tests/api/test_api.py b/pandas/tests/api/test_api.py
index 00b0236c23..54e0453ed5 100644
--- a/pandas/tests/api/test_api.py
+++ b/pandas/tests/api/test_api.py
@@ -418,3 +418,5 @@ def test_set_module():
     assert pd.Timestamp.__module__ == "pandas"
     assert pd.Timedelta.__module__ == "pandas"
     assert pd.Series.__module__ == "pandas"
+    assert pd.date_range.__module__ == "pandas"
+    assert pd.bdate_range.__module__ == "pandas"
Repository: pandas-dev/pandas
Pull request #60265 (2024-11-09 16:36:27)

ENH: set __module__ on  `read_*` functions in readers.py
- [ ] Part of https://github.com/pandas-dev/pandas/issues/55178
- [ ] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature
- [ ] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit).
- [ ] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to new arguments/methods/functions.
- [ ] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature.

This decorates `read_csv`, `read_table` and `read_fwf` functions in readers.py with `@set_module('pandas')` (similar to https://github.com/pandas-dev/pandas/pull/55171)




Patch:
diff --git a/pandas/io/parsers/readers.py b/pandas/io/parsers/readers.py
index ffc2690a5e..54877017f7 100644
--- a/pandas/io/parsers/readers.py
+++ b/pandas/io/parsers/readers.py
@@ -32,7 +32,10 @@ from pandas.errors import (
     AbstractMethodError,
     ParserWarning,
 )
-from pandas.util._decorators import Appender
+from pandas.util._decorators import (
+    Appender,
+    set_module,
+)
 from pandas.util._exceptions import find_stack_level
 from pandas.util._validators import check_dtype_backend
 
@@ -771,6 +774,7 @@ def read_csv(
         % "filepath_or_buffer",
     )
 )
+@set_module("pandas")
 def read_csv(
     filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str],
     *,
@@ -906,6 +910,7 @@ def read_table(
         % "filepath_or_buffer",
     )
 )
+@set_module("pandas")
 def read_table(
     filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str],
     *,
@@ -1023,6 +1028,7 @@ def read_fwf(
 ) -> DataFrame: ...
 
 
+@set_module("pandas")
 def read_fwf(
     filepath_or_buffer: FilePath | ReadCsvBuffer[bytes] | ReadCsvBuffer[str],
     *,


Test patch:
diff --git a/pandas/tests/api/test_api.py b/pandas/tests/api/test_api.py
index acb4809791..7f738108c2 100644
--- a/pandas/tests/api/test_api.py
+++ b/pandas/tests/api/test_api.py
@@ -417,6 +417,9 @@ def test_set_module():
     assert pd.Period.__module__ == "pandas"
     assert pd.Timestamp.__module__ == "pandas"
     assert pd.Timedelta.__module__ == "pandas"
+    assert pd.read_csv.__module__ == "pandas"
+    assert pd.read_table.__module__ == "pandas"
+    assert pd.read_fwf.__module__ == "pandas"
     assert pd.Series.__module__ == "pandas"
     assert pd.date_range.__module__ == "pandas"
     assert pd.bdate_range.__module__ == "pandas"
Repository: pandas-dev/pandas
Pull request #60266 (2024-11-09 16:44:34)

ENH: set __module__ on merge functions in merge.py
- [ ] Part of https://github.com/pandas-dev/pandas/issues/55178
- [ ] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature
- [ ] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit).
- [ ] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to new arguments/methods/functions.
- [ ] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature.

This decorates the following merge functions in merge.py with `@set_module('pandas')` (similar to https://github.com/pandas-dev/pandas/pull/55171)
- merge
- merge_asof
- merge_ordered




Patch:
diff --git a/pandas/core/reshape/merge.py b/pandas/core/reshape/merge.py
index 0ca8661ad3..6f9bb8cb24 100644
--- a/pandas/core/reshape/merge.py
+++ b/pandas/core/reshape/merge.py
@@ -39,7 +39,10 @@ from pandas._typing import (
     npt,
 )
 from pandas.errors import MergeError
-from pandas.util._decorators import cache_readonly
+from pandas.util._decorators import (
+    cache_readonly,
+    set_module,
+)
 from pandas.util._exceptions import find_stack_level
 
 from pandas.core.dtypes.base import ExtensionDtype
@@ -138,6 +141,7 @@ if np.uintc is not np.uint32:
 _known = (np.ndarray, ExtensionArray, Index, ABCSeries)
 
 
+@set_module("pandas")
 def merge(
     left: DataFrame | Series,
     right: DataFrame | Series,
@@ -502,6 +506,7 @@ def _groupby_and_merge(
     return result, lby
 
 
+@set_module("pandas")
 def merge_ordered(
     left: DataFrame | Series,
     right: DataFrame | Series,
@@ -645,6 +650,7 @@ def merge_ordered(
     return result
 
 
+@set_module("pandas")
 def merge_asof(
     left: DataFrame | Series,
     right: DataFrame | Series,


Test patch:
diff --git a/pandas/tests/api/test_api.py b/pandas/tests/api/test_api.py
index 7f738108c2..8209ff86c6 100644
--- a/pandas/tests/api/test_api.py
+++ b/pandas/tests/api/test_api.py
@@ -417,6 +417,9 @@ def test_set_module():
     assert pd.Period.__module__ == "pandas"
     assert pd.Timestamp.__module__ == "pandas"
     assert pd.Timedelta.__module__ == "pandas"
+    assert pd.merge.__module__ == "pandas"
+    assert pd.merge_ordered.__module__ == "pandas"
+    assert pd.merge_asof.__module__ == "pandas"
     assert pd.read_csv.__module__ == "pandas"
     assert pd.read_table.__module__ == "pandas"
     assert pd.read_fwf.__module__ == "pandas"
Repository: pandas-dev/pandas
Pull request #60267 (2024-11-09 16:51:26)

ENH: set __module__ on `timedelta_range`
- [ ] Part of https://github.com/pandas-dev/pandas/issues/55178
- [ ] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature
- [ ] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit).
- [ ] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to new arguments/methods/functions.
- [ ] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature.

This decorates `timedelta_range` with `@set_module('pandas')` (similar to https://github.com/pandas-dev/pandas/pull/55171)




Patch:
diff --git a/pandas/core/indexes/timedeltas.py b/pandas/core/indexes/timedeltas.py
index 6bbe86816d..fa3de46621 100644
--- a/pandas/core/indexes/timedeltas.py
+++ b/pandas/core/indexes/timedeltas.py
@@ -237,6 +237,7 @@ class TimedeltaIndex(DatetimeTimedeltaMixin):
         return "timedelta64"
 
 
+@set_module("pandas")
 def timedelta_range(
     start=None,
     end=None,


Test patch:
diff --git a/pandas/tests/api/test_api.py b/pandas/tests/api/test_api.py
index 2a96ef35c9..acb4809791 100644
--- a/pandas/tests/api/test_api.py
+++ b/pandas/tests/api/test_api.py
@@ -420,6 +420,7 @@ def test_set_module():
     assert pd.Series.__module__ == "pandas"
     assert pd.date_range.__module__ == "pandas"
     assert pd.bdate_range.__module__ == "pandas"
+    assert pd.timedelta_range.__module__ == "pandas"
     assert pd.NamedAgg.__module__ == "pandas"
     assert api.typing.SeriesGroupBy.__module__ == "pandas.api.typing"
     assert api.typing.DataFrameGroupBy.__module__ == "pandas.api.typing"