-
Notifications
You must be signed in to change notification settings - Fork 56
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
some modify to utils convert function #335
base: master
Are you sure you want to change the base?
Conversation
Hello @MeloDi-23! Thanks for opening this PR. We checked the lines you've touched for PEP 8 issues, and found:
|
Thanks again for the PR @MeloDi-23. We had only talked about modifying the documentation but you have added entirely new functionality - might require a bit of a think about how to proceed. @lgarrison Thoughts? |
I think our API here is not great to begin with—accepting either an array or a dict that we try to unpack into an array seems pretty magical, and it's undocumented. I think it's a big part of the confusion about why the weights aren't used, because when passing a dict the function does indeed have enough information to apply the weighted counts (except for the sum of weights). So I wonder if we should narrow the API to only accept results dicts, and maybe add a (I would suggest that we only accept arrays instead of dicts, but then users have to type |
Thanks for your idea. I think one key point I want to say is to make it compatible with pair counting APIs ( |
Yes, sorry, I meant to edit my comment to say "record array" instead of "dict". I'm not too concerned about other people using the API with their own counts, but if they are, I think the function can trivially accept a record array or dict of arrays. I also agree that an object-oriented API could be nice, but in the interest of fixing the current issue in a timely manner, maybe we should stick to improving the utils functions. |
I am clearly the bottleneck here. @lgarrison Should we work out what a good compromise would be? This could be an useful addition as long as we don't break user expectations/existing code. |
I think I'm in favor of changing the function to only accept record arrays and/or dicts, and add a If that's too disruptive, we could instead introduce a new function with this behavior, and restrict the old function to its documented behavior, which is to accept only arrays and not record arrays/dicts. "Documented" is a fuzzy term here, though, because we have examples that are at odds with the docstring. I think no matter what we do, the change will (and should!) be breaking in at least a small way, because the current situation of silently producing unweighted CFs is not a good user experience. |
Corrfunc forked:
I rewrite the utils.py, so that the
convert_rp_pi_counts_to_wp
andconvert_3d_counts_to_cf
works more properly. The formal call is still valid, and I added that if you provide weight in the pair-counting, it will account for the weighting.This code will work.
Note that, for simplicity, I didn't add new parameters to the function.
Instead you can
weight_normal = weight / weight.mean()
, and pass the parameter in the old way.ND1
, sum of weight of dataset2 toND2
, etc. This is reasonable, because if you assume no weighting(that is weight of every point is 1), then the sum of weights equals to number of points.Both way will work.