numpy/mergesort-kind
| Rule | mergesort-kind |
|---|---|
| Pack | NumPy |
| Severity | info |
| Fix | unsafe, with xpd check --fix --unsafe-fixes |
| Library versions | every version |
kind="mergesort" is kept only for old code and runs the same stable sort as kind="stable". Write kind="stable".
order = np.argsort(scores, kind="mergesort")order = np.argsort(scores, kind="stable")What the rule reports
Section titled “What the rule reports”The rule reports kind="mergesort" in np.sort, np.argsort and the sort and argsort methods. The docs keep "mergesort" only for backwards compatibility, and both names select the same stable sort.
How to fix it
Section titled “How to fix it”xpd check --fix --unsafe-fixes applies the fixes of this rule. Check the result, because an unsafe fix can change what the code does.
The safe fix writes kind="stable" in np.sort and np.argsort. The unsafe fix writes the same in a sort or argsort method, because the pattern cannot tell an array from another object.
Message
Section titled “Message”xpd prints this message with the issue. A name that starts with $ stands for code from your file.
kind="mergesort" is kept only for backwards compatibility, and it runs the same stable sort as kind="stable". Write kind="stable".Browse the other rules of the NumPy pack.