-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
CLN: Remove unused code in Factorizer classes #49547
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 3 commits
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 |
---|---|---|
|
@@ -230,21 +230,11 @@ def test_factorize_nan(self): | |
key = np.array([1, 2, 1, np.nan], dtype="O") | ||
rizer = ht.ObjectFactorizer(len(key)) | ||
for na_sentinel in (-1, 20): | ||
ids = rizer.factorize(key, sort=True, na_sentinel=na_sentinel) | ||
expected = np.array([0, 1, 0, na_sentinel], dtype="int32") | ||
ids = rizer.factorize(key, na_sentinel=na_sentinel) | ||
expected = np.array([0, 1, 0, na_sentinel], dtype="int64") | ||
assert len(set(key)) == len(set(expected)) | ||
tm.assert_numpy_array_equal(pd.isna(key), expected == na_sentinel) | ||
|
||
# nan still maps to na_sentinel when sort=False | ||
key = np.array([0, np.nan, 1], dtype="O") | ||
na_sentinel = -1 | ||
|
||
# TODO(wesm): unused? | ||
ids = rizer.factorize(key, sort=False, na_sentinel=na_sentinel) # noqa | ||
|
||
expected = np.array([2, -1, 0], dtype="int32") | ||
assert len(set(key)) == len(set(expected)) | ||
tm.assert_numpy_array_equal(pd.isna(key), expected == na_sentinel) | ||
tm.assert_numpy_array_equal(ids, expected, check_dtype=False) | ||
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. why check_dtype=False here? 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. Because 32 bit systems return 32 bit and the dtype does not matter here at all. Can add an if else to specify the int32/int64 if you prefer though 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. so use np.intp? 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. Oh, good idea. thx |
||
|
||
@pytest.mark.parametrize( | ||
"data, expected_codes, expected_uniques", | ||
|
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.
Just to make sure I'm understanding - the dtype specified for expected in main currently is wrong, but the old test never actually checked it. Is that right?
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.
Correct. Honestly, I am not sure what the old test was supposed to test at all.
We get int32 on 32-bit systems, so I disabled the dtype check, it's not relevant here anyway