-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
REF: share code for scalar validation in datetimelike array methods #34076
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
REF: share code for scalar validation in datetimelike array methods #34076
Conversation
…like-validators-scalar
…like-validators-scalar
I agree that we would want to improve the user-friendliness of these error messages. From that perspective, I prefer the error messages that were there before. |
f"'value' should be a '{self._scalar_type.__name__}', 'NaT', " | ||
f"or array of those. Got '{type(value).__name__}' instead." | ||
) | ||
raise TypeError(msg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This message for example is a nicer, user-friendly one that would be good to keep.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok @gfyoung ?
…like-validators-scalar
@@ -760,6 +759,26 @@ def _validate_shift_value(self, fill_value): | |||
|
|||
return self._unbox(fill_value) | |||
|
|||
def _validate_scalar(self, value, msg: str, cast_str: bool = False): | |||
if cast_str and isinstance(value, str): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add a doc-string here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
…like-validators-scalar
The user-facing effect here is in the exception messages we show to users, where we may want to be more verbose than this. Thoughts @gfyoung?