Skip to content

BUG: when flooring, ambiguous parameter unnecessarily used (and raising Error) #50024

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
merged 15 commits into from
Dec 12, 2022

Conversation

jcaoun
Copy link
Contributor

@jcaoun jcaoun commented Dec 2, 2022

Comment on lines 358 to 360
@td.skip_if_windows
def test_tz_convert_utc_with_system_utc(self):

Copy link
Member

Choose a reason for hiding this comment

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

why delete this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, i forgot to ask about this, I deleted it temporarily to run tests because using the @td.skip_if_windows decorator gives me an error I couldn't figure out

Copy link
Member

Choose a reason for hiding this comment

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

can you put this back and add a whatsnew note? rest looks fine

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done 👍

Copy link
Member

@MarcoGorelli MarcoGorelli left a comment

Choose a reason for hiding this comment

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

getting there, thanks 💪

this'll also need a whatsnew note

raise ValueError("Cannot infer offset with only one time.")
if not isinstance(ambiguous, bool) and ambiguous not in {"NaT", "raise"}:
raise ValueError(
"ambiguous parameter must be one of: "
Copy link
Member

Choose a reason for hiding this comment

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

let's quote the parameter name, else it'll be ambiguous (😄 )

                        "'ambiguous' parameter must be one of: "

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done :)

@MarcoGorelli MarcoGorelli changed the title merged with pandas/dev main branch and re-added previous changes BUG: when flooring, ambiguous parameter unnecessarily used (and raising Error) Dec 3, 2022
Comment on lines 371 to 373
# ------------------------------------------------------------------
# Timestamp.__init__ with tz str or tzinfo

Copy link
Member

Choose a reason for hiding this comment

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

can you check over the file again please? let's not make irrelevant changes

@@ -25,20 +25,21 @@ Fixed regressions
Bug fixes
~~~~~~~~~
- Bug in :meth:`.Styler.to_excel` leading to error when unrecognized ``border-style`` (e.g. ``"hair"``) provided to Excel writers (:issue:`48649`)
-
- Bug in :meth:`.Timestamp.floor` fixed tz_localize so 'ambiguous' parameter can only be True, False, 'NaT' or 'raise' and all other invalid arguments to ambiguous have same error, including 'infer' (:issue:`49565`)
Copy link
Member

Choose a reason for hiding this comment

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

this should go in v2.0.0.rst

as for the test, how about

Better error message when passing invalid values to ``ambiguous`` parameter in :meth:`Timestamp.tz_localize` (:issue:`49565`)


.. ---------------------------------------------------------------------------
.. _whatsnew_153.other:

Other
~~~~~
-
- Modified test cases in test_timezones.py to reflect new error message from bug fix for bug: (:issue:`49565`)
Copy link
Member

Choose a reason for hiding this comment

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

this is unnecessary, let's remove it

-

.. ---------------------------------------------------------------------------
.. _whatsnew_153.contributors:

Contributors
~~~~~~~~~~~~
- Julia Chaker Aoun
Copy link
Member

Choose a reason for hiding this comment

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

no need, this is populated automatically

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi! If you could approve or merge my PR by tomorrow I would really appreciate it! I'm working on this for a project and I get extra credit if the PR is approved :)

Copy link
Member

Choose a reason for hiding this comment

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

you'll need to address the review comments first

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe I resolved the remaining comments in my last commit

Copy link
Member

Choose a reason for hiding this comment

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

still need to address #50024 and #50024

@MarcoGorelli MarcoGorelli added the Error Reporting Incorrect or improved errors from pandas label Dec 11, 2022
@MarcoGorelli MarcoGorelli added this to the 2.0 milestone Dec 11, 2022
Copy link
Member

@MarcoGorelli MarcoGorelli left a comment

Choose a reason for hiding this comment

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

Looks good to me, I think this error message is clearer than the original (which kind of makes it look like pandas was trying to use the ambiguous parameter, but failed)

Over to @mroeschke in case there's further comments / objections

@jcaoun
Copy link
Contributor Author

jcaoun commented Dec 11, 2022

Thanks for approving the PR!!! This is the first time I contribute to an open-source project and it was really fun. I really appreciate your help :)

@mroeschke mroeschke merged commit e3143f6 into pandas-dev:main Dec 12, 2022
@mroeschke
Copy link
Member

Thanks @jcaoun

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Error Reporting Incorrect or improved errors from pandas
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: when flooring, ambiguous parameter unnecessarily used (and raising Error)
3 participants