-
-
Notifications
You must be signed in to change notification settings - Fork 155
MAINT: #1503 deduplicate tests/__init__.py
#1508
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
base: main
Are you sure you want to change the base?
Conversation
| np_1darray_bool: TypeAlias = np.ndarray[tuple[int], np.bool_] | ||
| np_1darray_str: TypeAlias = np.ndarray[tuple[int], np.str_] | ||
| np_1darray_bytes: TypeAlias = np.ndarray[tuple[int], np.bytes_] | ||
| np_1darray_complex: TypeAlias = np.ndarray[tuple[int], np.complexfloating] | ||
| np_1darray_object: TypeAlias = np.ndarray[tuple[int], np.object_] |
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.
These have been incorrect. Should have been np.ndarray[tuple[int], np.dtype[np.bool_]], etc.
| def test_types_to_numpy() -> None: | ||
| s = pd.Series(["a", "b", "c"], dtype=str) | ||
| check(assert_type(s.to_numpy(), np_1darray_str), np_1darray_str) | ||
| check(assert_type(s.to_numpy(), np_1darray_object), np_1darray_object) | ||
| check( # <U1, not str_ | ||
| assert_type(s.to_numpy(dtype="str", copy=True), np_1darray), np_1darray | ||
| ) | ||
| check(assert_type(s.to_numpy(na_value=0), np_1darray_object), np_1darray_object) | ||
| check( | ||
| assert_type(s.to_numpy(dtype="str", copy=True), np_1darray_str), np_1darray_str | ||
| assert_type(s.to_numpy(na_value=np.int32(4)), np_1darray_object), | ||
| np_1darray_object, | ||
| ) | ||
| check(assert_type(s.to_numpy(na_value=0), np_1darray_str), np_1darray_str) | ||
| check(assert_type(s.to_numpy(na_value=np.int32(4)), np_1darray_str), np_1darray_str) | ||
| check( | ||
| assert_type(s.to_numpy(na_value=np.float16(4)), np_1darray_str), np_1darray_str | ||
| assert_type(s.to_numpy(na_value=np.float16(4)), np_1darray_object), | ||
| np_1darray_object, | ||
| ) | ||
| check( | ||
| assert_type(s.to_numpy(na_value=np.complex128(4, 7)), np_1darray_str), | ||
| np_1darray_str, | ||
| assert_type(s.to_numpy(na_value=np.complex128(4, 7)), np_1darray_object), | ||
| np_1darray_object, | ||
| ) |
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.
Behavioural changes
| """Test Series.to_numpy for different types.""" | ||
| s_str = pd.Series(["a", "b", "c"], dtype=str) | ||
| check(assert_type(s_str.to_numpy(), np_1darray_str), np_1darray_str) | ||
| check(assert_type(s_str.to_numpy(), np_1darray_object), np_1darray_object) |
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.
Behavioural change
| # |S20, not bytes_ | ||
| check(assert_type(o_s.to_numpy(dtype=np.bytes_), np_1darray), np_1darray) | ||
| # |S6, not bytes_ | ||
| check(assert_type(i_s.to_numpy(dtype=np.bytes_), np_1darray), np_1darray) | ||
| # <U6, not str_ | ||
| check(assert_type(i_s.to_numpy(dtype=np.str_), np_1darray), np_1darray) |
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.
Behavioural changes
| # |S6, not bytes_ | ||
| check(assert_type(i_i.to_numpy(dtype="bytes", copy=True), np_1darray), np_1darray) |
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.
Behavioural change
_typing.pyiandtests/__init__.py#1503