-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
Complex Dtype Support for Hashmap Algos #36482
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
Changes from all commits
1c6b786
42a46d7
8331d06
3ba4169
8302589
5068771
8d65aa7
8b7ac7d
45c8237
cb74fe3
b29404e
f983f4f
c2e4e82
7c42495
41b1faf
da53f38
32262e7
f4932d9
328e242
8d5d517
38e0dc7
2008239
574be58
e0c3e44
1b487b8
b393a08
554090f
ab38ad9
a28c495
7a9f960
9e558ce
1d11a90
737ea96
ae7674b
d1e00b7
df28514
6b4c10e
9afed5f
96d5a58
e9a4ca2
e882b4e
6bf72a0
e53417d
fdf45b1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -207,3 +207,22 @@ def test_value_counts_bool_with_nan(self, ser, dropna, exp): | |||
# GH32146 | ||||
out = ser.value_counts(dropna=dropna) | ||||
tm.assert_series_equal(out, exp) | ||||
|
||||
@pytest.mark.parametrize( | ||||
"input_array,expected", | ||||
[ | ||||
( | ||||
[1 + 1j, 1 + 1j, 1, 3j, 3j, 3j], | ||||
Series([3, 2, 1], index=pd.Index([3j, 1 + 1j, 1], dtype=np.complex128)), | ||||
), | ||||
( | ||||
[1 + 1j, 1 + 1j, 1, 3j, 3j, 3j], | ||||
Series([3, 2, 1], index=pd.Index([3j, 1 + 1j, 1], dtype=np.complex64)), | ||||
), | ||||
], | ||||
) | ||||
def test_value_counts_complex_numbers(self, input_array, expected): | ||||
# GH 17927 | ||||
# Complex Index dtype is cast to object | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this comment still valid? IIUC
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Dtype of the index will be objects, see below. Agree this probably needs fixing - I can create a follow up. As this is the same issue as your comment below refers too. #36482 (comment)
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. pls create a followon issue |
||||
result = Series(input_array).value_counts() | ||||
tm.assert_series_equal(result, expected) |
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -1513,6 +1513,21 @@ def test_unique_tuples(self, arr, uniques): | |||
result = pd.unique(arr) | ||||
tm.assert_numpy_array_equal(result, expected) | ||||
|
||||
@pytest.mark.parametrize( | ||||
"array,expected", | ||||
[ | ||||
( | ||||
[1 + 1j, 0, 1, 1j, 1 + 2j, 1 + 2j], | ||||
# Should return a complex dtype in the future | ||||
np.array([(1 + 1j), 0j, (1 + 0j), 1j, (1 + 2j)], dtype=object), | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm,
What do you think @jbrockmendel? Probably should not be part of this PR though. It looks like dtype=object for factorize and Index are just consequences of unique returning objects.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jbrockmendel - whenever you have time, think your eyes on this would be much appreciated. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yah i think ideally this should return a complex dtype (same for factorize above). OK for that to be a separate PR, can leave a comment on the test to that effect There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great have added comments to that effect - will create a follow up issue |
||||
) | ||||
], | ||||
) | ||||
def test_unique_complex_numbers(self, array, expected): | ||||
# GH 17927 | ||||
result = pd.unique(array) | ||||
tm.assert_numpy_array_equal(result, expected) | ||||
|
||||
|
||||
class TestHashTable: | ||||
def test_string_hashtable_set_item_signature(self): | ||||
|
Uh oh!
There was an error while loading. Please reload this page.