Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing issue #8770: Improved frequency parameter logic to set it to 'D' only if periods, start, or end are None. #8774

Merged
merged 7 commits into from
Feb 24, 2024
5 changes: 4 additions & 1 deletion xarray/coding/cftime_offsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -1152,7 +1152,7 @@ def date_range(
start=None,
end=None,
periods=None,
freq="D",
freq=None,
tz=None,
normalize=False,
name=None,
Expand Down Expand Up @@ -1218,6 +1218,9 @@ def date_range(
"""
from xarray.coding.times import _is_standard_calendar

if freq is None and any(arg is None for arg in [periods, start, end]):
freq = "D"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry on second thought could you move this logic into cftime_range (defined a little farther up in this file)? That way we can harmonize the default arguments across pandas.date_range, xarray.cftime_range, and xarray.date_range.


if tz is not None:
use_cftime = False

Expand Down
Loading