-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
ENH: average
to allow better use w/ custom objects
#12067
Conversation
A simple syntax change to enable better use of `average` with custom Python objects. This works because if `weights is None`, then `avg.dtype` can be `"O"` when working with custom Python objects. The fix does nothing but change how shape is called, so that it will work with objects that don't necessarily have shapes, like base Python floats, etc.
average
to allow better use w/ custom objectsaverage
to allow better use w/ custom objects
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.
If this is useful, my first thought is that it would be helpful to have a unit test that demonstrates something that works with this change that didn't work before. That would also provide a sort of "code example" for the behavior you're trying to enable.
The macos Azure failure is probably not related -- we may also have to skip / decorate the test in |
@tylerjereddy thank you for your quick response, and apologies for the delay. This is actually not as simple as I had initially thought when submitting the change, because, for example, I believe that this is important (selfishly, of course) because it will facilitate the use of Thanks again; I very much appreciate you responding. |
Needs release note. |
Going to close the PR, I expect its still relevant. But right now this is an incomplete one-line change with tests missing and was idle for many years. If anyone wants to pick it up, |
A simple syntax change to enable better use of
average
with custom Python objects.This works because if
weights is None
, thenavg.dtype
can be"O"
when working with custom Python objects.The fix does nothing but change how
np.shape
is called, so that it will work with objects that don't necessarily have shapes, like base Python floats, custom Python objects, etc.