@@ -1705,6 +1705,110 @@ def test_date_range_unit():
1705
1705
)
1706
1706
1707
1707
1708
+ def test_date_range_overloads () -> None :
1709
+ """Test different overloads of pd.date_range (GH1327)."""
1710
+ t1 = pd .Timestamp ("2023-04-05" )
1711
+ t2 = pd .Timestamp ("2023-05-05" )
1712
+ # start end (freq None)
1713
+ check (assert_type (pd .date_range (t1 , t2 ), pd .DatetimeIndex ), pd .DatetimeIndex )
1714
+ # start end positional (freq None)
1715
+ check (
1716
+ assert_type (pd .date_range (start = t1 , end = t2 ), pd .DatetimeIndex ), pd .DatetimeIndex
1717
+ )
1718
+ # start periods (freq None)
1719
+ check (
1720
+ assert_type (pd .date_range (start = t1 , periods = 10 ), pd .DatetimeIndex ),
1721
+ pd .DatetimeIndex ,
1722
+ )
1723
+ # end periods (freq None)
1724
+ check (
1725
+ assert_type (pd .date_range (end = t2 , periods = 10 ), pd .DatetimeIndex ),
1726
+ pd .DatetimeIndex ,
1727
+ )
1728
+ # start periods (freq None)
1729
+ check (assert_type (pd .date_range (t1 , t2 , 10 ), pd .DatetimeIndex ), pd .DatetimeIndex )
1730
+ # start end periods
1731
+ check (
1732
+ assert_type (pd .date_range (start = t1 , end = t2 , periods = 10 ), pd .DatetimeIndex ),
1733
+ pd .DatetimeIndex ,
1734
+ )
1735
+ # start end freq
1736
+ check (
1737
+ assert_type (pd .date_range (start = t1 , end = t2 , freq = "ME" ), pd .DatetimeIndex ),
1738
+ pd .DatetimeIndex ,
1739
+ )
1740
+ # start periods freq
1741
+ check (
1742
+ assert_type (pd .date_range (start = t1 , periods = 10 , freq = "ME" ), pd .DatetimeIndex ),
1743
+ pd .DatetimeIndex ,
1744
+ )
1745
+
1746
+ if TYPE_CHECKING_INVALID_USAGE :
1747
+ pd .date_range (t1 ) # type: ignore[call-overload] # pyright: ignore[reportCallIssue]
1748
+ pd .date_range (start = t1 ) # type: ignore[call-overload] # pyright: ignore[reportCallIssue]
1749
+ pd .date_range (end = t1 ) # type: ignore[call-overload] # pyright: ignore[reportCallIssue]
1750
+ pd .date_range (periods = 10 ) # type: ignore[call-overload] # pyright: ignore[reportCallIssue]
1751
+ pd .date_range (freq = "BD" ) # type: ignore[call-overload] # pyright: ignore[reportCallIssue]
1752
+ pd .date_range (start = t1 , end = t2 , periods = 10 , freq = "BD" ) # type: ignore[call-overload] # pyright: ignore[reportCallIssue]
1753
+
1754
+
1755
+ def test_timedelta_range_overloads () -> None :
1756
+ """Test different overloads of pd.timedelta_range (GH1327)."""
1757
+ t1 = "1 day"
1758
+ t2 = "20 day"
1759
+ # start end (freq None)
1760
+ check (assert_type (pd .timedelta_range (t1 , t2 ), pd .TimedeltaIndex ), pd .TimedeltaIndex )
1761
+ # start end positional (freq None)
1762
+ check (
1763
+ assert_type (pd .timedelta_range (start = t1 , end = t2 ), pd .TimedeltaIndex ),
1764
+ pd .TimedeltaIndex ,
1765
+ )
1766
+ # start periods (freq None)
1767
+ check (
1768
+ assert_type (pd .timedelta_range (start = t1 , periods = 10 ), pd .TimedeltaIndex ),
1769
+ pd .TimedeltaIndex ,
1770
+ )
1771
+ # end periods (freq None)
1772
+ check (
1773
+ assert_type (pd .timedelta_range (end = t2 , periods = 10 ), pd .TimedeltaIndex ),
1774
+ pd .TimedeltaIndex ,
1775
+ )
1776
+ # start periods (freq None)
1777
+ check (
1778
+ assert_type (pd .timedelta_range (t1 , t2 , 10 ), pd .TimedeltaIndex ),
1779
+ pd .TimedeltaIndex ,
1780
+ )
1781
+ # start end periods
1782
+ check (
1783
+ assert_type (
1784
+ pd .timedelta_range (start = t1 , end = t2 , periods = 10 ), pd .TimedeltaIndex
1785
+ ),
1786
+ pd .TimedeltaIndex ,
1787
+ )
1788
+ # start end freq
1789
+ check (
1790
+ assert_type (
1791
+ pd .timedelta_range (start = t1 , end = t2 , freq = "48h" ), pd .TimedeltaIndex
1792
+ ),
1793
+ pd .TimedeltaIndex ,
1794
+ )
1795
+ # start periods freq
1796
+ check (
1797
+ assert_type (
1798
+ pd .timedelta_range (start = t1 , periods = 10 , freq = "48h" ), pd .TimedeltaIndex
1799
+ ),
1800
+ pd .TimedeltaIndex ,
1801
+ )
1802
+
1803
+ if TYPE_CHECKING_INVALID_USAGE :
1804
+ pd .timedelta_range (t1 ) # type: ignore[call-overload] # pyright: ignore[reportCallIssue]
1805
+ pd .timedelta_range (start = t1 ) # type: ignore[call-overload] # pyright: ignore[reportCallIssue]
1806
+ pd .timedelta_range (end = t1 ) # type: ignore[call-overload] # pyright: ignore[reportCallIssue]
1807
+ pd .timedelta_range (periods = 10 ) # type: ignore[call-overload] # pyright: ignore[reportCallIssue]
1808
+ pd .timedelta_range (freq = "BD" ) # type: ignore[call-overload] # pyright: ignore[reportCallIssue]
1809
+ pd .timedelta_range (start = t1 , end = t2 , periods = 10 , freq = "BD" ) # type: ignore[call-overload] # pyright: ignore[reportCallIssue]
1810
+
1811
+
1708
1812
def test_DatetimeIndex_sub_timedelta () -> None :
1709
1813
# GH838
1710
1814
check (
0 commit comments