Skip to content

CLN: unify a ValueError message for removed units T, L, U, N and remove these entries from UnitChoices #59119

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

Merged

Conversation

natmokval
Copy link
Contributor

  • unify a ValueError message for removed units T, L, U, N to "Invalid frequency: T"
  • removed unused entries T, L, n, u from UnitChoices
  • removed a deeprecation note from the documentation of the class Timedelta

@natmokval natmokval marked this pull request as ready for review June 27, 2024 12:12
@natmokval natmokval requested a review from MarcoGorelli as a code owner June 27, 2024 12:12
@@ -56,10 +56,3 @@ def test_units_H_S_deprecated_from_attrname_to_abbrevs(freq):

with tm.assert_produces_warning(FutureWarning, match=msg):
Resolution.get_reso_from_freqstr(freq)


@pytest.mark.parametrize("freq", ["T", "t", "L", "U", "N", "n"])
Copy link
Member

Choose a reason for hiding this comment

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

Are these units tested elsewhere (that they are disallowed)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, for these units we have tests:
test_period_index_T_L_U_N_raises in pandas/tests/indexes/period/test_constructors.py
test_frequency_H_T_S_L_U_N_raises in pandas/tests/indexes/datetimes/test_date_range.py
with the error message "Invalid frequency: {}”

and with another error message "invalid unit abbreviation: {unit}"
test_timedelta_unit_T_L_U_N_raises in pandas/tests/indexes/timedeltas/test_timedelta_range.py and
test_unit_T_L_N_U_raises pandas/tests/scalar/timedelta/test_constructors.py

I am not sure, should we unify this error message to "Invalid frequency: {}”?

I removed the test_reso_abbrev_T_L_U_N_raises from pandas/tests/tslibs/test_resolution.py because we get KeyError: 'T' for this test.

Copy link
Member

Choose a reason for hiding this comment

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

I am not sure, should we unify this error message to "Invalid frequency: {}”?

That would be nice, but if it makes the code more complex I would say it's not worth it

@mroeschke mroeschke added this to the 3.0 milestone Jun 27, 2024
@mroeschke mroeschke merged commit a89f208 into pandas-dev:main Jun 27, 2024
49 checks passed
@mroeschke
Copy link
Member

Thanks @natmokval

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants