8000 Let apply_along_axis work with more function return types: Issue/2582 by oracal · Pull Request #5323 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

Conversation

@oracal
Copy link
@oracal oracal commented Nov 29, 2014

Fixed issue #2582. If the function passed into the apply_along_axis function returned anything other than a "scalar" or "array-like object" then it would throw an exception that len method did not exist.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Be best to have a blank line after the function definition, and also class definition in the next test.

@charris
Copy link
Member
charris commented Nov 30, 2014

The commit messages should be expanded a bit. First, the summaries should begin with BUG: , then follow with an explanation of what the problem was and what the fix is. You can use git rebase -i HEAD^^ to make the changes and a force push to origin to update this PR.

@charris charris changed the title Issue/2582 Let apply_along_axis work with more function return types: Issue/2582 Jan 11, 2015
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be simpler to just do

if isscalar or not hasattr(res, `__len__`):

Even so, for better behavior I'd probably save the results of applying func in a list, make a array out of that, and then reshape it. One could instead maybe do asarray(res) up front .and check the dimension of that. I think that would solve the problem here and also work for functions that, say, return a set constructed from the elements of the axis and that currently fail.

@homu
Copy link
Contributor
homu commented Oct 11, 2016

☔ The latest upstream changes (presumably 84b11f5) made this pull request unmergeable. Please resolve the merge conflicts.

@eric-wieser
Copy link
Member
eric-wieser commented Feb 13, 2017

@oracal: I think these tests all pass as of #8441 (by using asarray).

@oracal oracal closed this Feb 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants

0