Skip to content

Commit

Permalink
ENH: Fix Python 3.13 test failures & enable CI
Browse files Browse the repository at this point in the history
x-ref pandas-dev#58734

Co-authored-by: Thomas Li <[email protected]>
  • Loading branch information
lysnikolaou and lithomas1 committed Jun 21, 2024
1 parent dd87dd3 commit c207a3c
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 7 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ jobs:
# To freeze this file, uncomment out the ``if: false`` condition, and migrate the jobs
# to the corresponding posix/windows-macos/sdist etc. workflows.
# Feel free to modify this comment as necessary.
if: false # Uncomment this to freeze the workflow, comment it to unfreeze
# if: false # Uncomment this to freeze the workflow, comment it to unfreeze
defaults:
run:
shell: bash -eou pipefail {0}
Expand Down Expand Up @@ -332,7 +332,7 @@ jobs:
- name: Set up Python Dev Version
uses: actions/setup-python@v5
with:
python-version: '3.12-dev'
python-version: '3.13-dev'

- name: Build Environment
run: |
Expand Down
7 changes: 6 additions & 1 deletion pandas/_libs/tslibs/offsets.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -4948,7 +4948,12 @@ cpdef to_offset(freq, bint is_period=False):
if result is None:
raise ValueError(INVALID_FREQ_ERR_MSG.format(freq))

if is_period and not hasattr(result, "_period_dtype_code"):
try:
has_period_dtype_code = hasattr(result, "_period_dtype_code")
except ValueError:
has_period_dtype_code = False

if is_period and not has_period_dtype_code:
if isinstance(freq, str):
raise ValueError(f"{result.name} is not supported as period frequency")
else:
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/groupby/test_groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -2445,7 +2445,7 @@ def test_rolling_wrong_param_min_period():
test_df.columns = ["name", "val"]

result_error_msg = (
r"^[a-zA-Z._]*\(\) got an unexpected keyword argument 'min_period'$"
r"^[a-zA-Z._]*\(\) got an unexpected keyword argument 'min_period'"
)
with pytest.raises(TypeError, match=result_error_msg):
test_df.groupby("name")["val"].rolling(window=2, min_period=1).sum()
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/io/parser/test_dialect.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def custom_dialect():
"escapechar": "~",
"delimiter": ":",
"skipinitialspace": False,
"quotechar": "~",
"quotechar": "`",
"quoting": 3,
}
return dialect_name, dialect_kwargs
Expand Down
5 changes: 4 additions & 1 deletion pandas/tests/io/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,10 @@ def test_warning_missing_utf_bom(self, encoding, compression_):
df.to_csv(path, compression=compression_, encoding=encoding)

# reading should fail (otherwise we wouldn't need the warning)
msg = r"UTF-\d+ stream does not start with BOM"
msg = (
r"UTF-\d+ stream does not start with BOM|"
r"'utf-\d+' codec can't decode byte"
)
with pytest.raises(UnicodeError, match=msg):
pd.read_csv(path, compression=compression_, encoding=encoding)

Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/io/xml/test_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -1038,7 +1038,7 @@ def test_utf16_encoding(xml_baby_names, parser):
UnicodeError,
match=(
"UTF-16 stream does not start with BOM|"
"'utf-16-le' codec can't decode byte"
"'utf-16(-le)?' codec can't decode byte"
),
):
read_xml(xml_baby_names, encoding="UTF-16", parser=parser)
Expand Down
1 change: 1 addition & 0 deletions pandas/tests/scalar/timedelta/test_arithmetic.py
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,7 @@ def test_td_floordiv_invalid_scalar(self):
[
r"Invalid dtype datetime64\[D\] for __floordiv__",
"'dtype' is an invalid keyword argument for this function",
"this function got an unexpected keyword argument 'dtype'",
r"ufunc '?floor_divide'? cannot use operands with types",
]
)
Expand Down

0 comments on commit c207a3c

Please sign in to comment.