-
Notifications
You must be signed in to change notification settings - Fork 3.3k
ENH: medcouple n log n (see #9570) #9571
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
- added fast algorithm - added legacy multiplexing option - revised tests - suggested draft release note
also STY: more style fixes
also STY: multi line warning again
bashtage
left a comment
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.
Overall looking pretty good.
statsmodels/stats/stattools.py
Outdated
| ----- | ||
| This is a helper function for the O(N log N) medcouple algorithm. | ||
| """ | ||
| AW = sorted(zip(A, W), key=lambda x: x[0]) |
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.
Should these be ndarray at this point, in which case we could avoid the python zip and sorted, which would normally be much slower for even modest sized data?
statsmodels/stats/stattools.py
Outdated
| mid = (beg + end) // 2 | ||
| trial = AW[mid][0] | ||
|
|
||
| wleft = sum(w for a, w in AW if a < trial) |
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 might also be slow since using Python objects.
statsmodels/stats/stattools.py
Outdated
| wleft = sum(w for a, w in AW if a < trial) | ||
| wright = sum(w for a, w in AW if a >= trial) | ||
|
|
||
| if 2 * wleft > wtot: |
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.
Do we need some nan protection somwhere? Usually need to ensure that all values are non-nan which using boolean comp.
ENH: other numpy library usage. STY: docstring improvements.
|
Thank you for your code critique. I made the following main changes:
Please let me know what else may be needed. |
I am following up on issue #9570 (link to issue) by creating this pull request, which implements Medcouple in O(N log N) time.
Legacy functionality with O(N**2) time is preserved with the use of a flag
use_fast. This flag defaults to the new behavior.Please let me know if you have any questions, or if you need anything else.
Overview:
added fast algorithm
added legacy multiplexing option
revised tests (passed locally)
suggested draft release note
closes ENH: Medcouple in O(N Log N) time #9570
tests added / passed.
code/documentation is well formatted.
properly formatted commit message. See
NumPy's guide.