Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Accepts integer/float string with units and raises when unit is ambiguous (2) #23025
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
Accepts integer/float string with units and raises when unit is ambiguous (2) #23025
Changes from 12 commits
ab5f7ba
7a38ecd
a65a35a
57dea1d
b8cf952
8154859
a90a992
1184b6e
5e28b49
fafe838
3ca0dae
8105f9c
e90a18b
e0a55a8
827aebf
9bff504
b6c7d45
9ff6ade
be93e4b
85f0103
673ad19
eb7d3f8
bb40f77
2e331c1
bada4a7
8c0425a
493a14b
e525ec4
448b68a
bd173a9
d16c4c5
1cfc729
e559f06
b914950
64a4440
4d26474
db41054
2f53004
fb40c94
f5e59ee
e7266da
b6a02df
694abe9
4d86ae1
40b09f4
a9c4675
95302de
661fd70
80a1161
dbe8fae
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
@jreback said:
I think differently I would like to present the reasons why I think this is the proper place:
parse_timedelta_string
gets a string and already checks internally for units. Currently it raises ValueError if it gets a decimal number and no units - but allows a integer number without units.If we don't leave the responsibility of checking units for string in
parse_timedelta_string
, it means that:Timedelta
, and functions_coerce_scalar_to_timedelta
and_convert_listlike
(last two are theto_timedelta
path)parse_timedelta_string
is now redundant and should be removed.The way it is right now we just give it the externally provided units and it can now do the checks itself - and that's all, and all cases are covered. Very little coding needed.
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 rename this to just
unit
, and then in the parsing if you find a unit call ithave_unit
(similar to others)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.
The other
have_
variables are all boolean, and it could be a bit weird to call the parsed unit ashave_unit
. Can we call it something likeparsed_unit
?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
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.
I think I mentioned it before, but I think we need to deprecate this first. We can here raise a deprecation warning when unit is None, and still fallback to unit='ns' for now
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!