-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG/DOC: Add documentation in types/common.py #15941
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
Conversation
3ac9d08
to
986d8b6
Compare
dtype = _get_dtype(arr_or_dtype) | ||
return dtype.kind in ('O', 'S', 'U') and not is_period_dtype(dtype) | ||
""" | ||
Check whether the provided array or dtype is of the string dtype. |
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.
see comments here: #15585
maybe add a reference / comments
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.
Ah, sounds good. Done.
986d8b6
to
5fcc3cf
Compare
Codecov Report
@@ Coverage Diff @@
## master #15941 +/- ##
==========================================
+ Coverage 90.98% 90.99% +<.01%
==========================================
Files 145 145
Lines 49556 49565 +9
==========================================
+ Hits 45090 45101 +11
+ Misses 4466 4464 -2
Continue to review full report at Codecov.
|
pandas/types/common.py
Outdated
|
||
Returns | ||
------- | ||
is_orderable_exc : Whether or not the exception raised is an |
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 better to use say:
Returns
--------
boolean : .......
(for all of these)
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.
Yep, done.
pandas/tests/types/test_common.py
Outdated
# | ||
# No exception should be raised. | ||
|
||
assert not com.is_string_dtype(None) |
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 all of these (use parametrize / construct them)
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.
Yep, done.
5fcc3cf
to
9777867
Compare
pandas/tests/types/test_common.py
Outdated
|
||
|
||
get_dtype_funcs = [ | ||
(com.is_dtype_equal, 2), |
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.
what I meant was to add all of the validation functions.
(In [3]: [ f for f in dir(com) if f.startswith('is_') and f.endswith('dtype')]
Out[3]:
['is_any_int_dtype',
'is_bool_dtype',
'is_categorical_dtype',
'is_complex_dtype',
'is_datetime64_any_dtype',
'is_datetime64_dtype',
'is_datetime64_ns_dtype',
'is_datetime64tz_dtype',
'is_datetime_or_timedelta_dtype',
'is_float_dtype',
'is_floating_dtype',
'is_int64_dtype',
'is_int_or_datetime_dtype',
'is_integer_dtype',
'is_numeric_dtype',
'is_object_dtype',
'is_period_dtype',
'is_signed_integer_dtype',
'is_string_dtype',
'is_string_like_dtype',
'is_timedelta64_dtype',
'is_timedelta64_ns_dtype',
'is_unsigned_integer_dtype']
then is_dtype_equal
should be a separate function to test (as its different)
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.
could make this a nice fixture :>
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.
Well the whole point was to check all of the functions that _get_dtype
. The ones in the list
currently are the only ones that do.
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.
could make this a nice fixture :>
Perhaps, if it's 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.
hmm, well we should check them all anyhow :>
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.
Fair enough. Will do then.
Partially addresses pandas-devgh-15895.
The following functions were not catching the TypeError raised by _get_dtype: 1) is_string_dtype 2) is_string_like_dtype 3) is_timedelta64_ns_dtype Thus, when "None" was passed in, an Exception was raised instead of returning False, as other functions did.
9777867
to
327687c
Compare
thanks @gfyoung |
Adds documentation for all internal functions in
types/common.py
In addition, caught a bug in which some functions calling
_get_dtype
were not catching theTypeError
. Documented those functions along the way too.Partially addresses #15895.