Skip to content
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

Implement axis as tuple of int #13815

Open
OGordon100 opened this issue Apr 6, 2021 · 5 comments
Open

Implement axis as tuple of int #13815

OGordon100 opened this issue Apr 6, 2021 · 5 comments
Labels
enhancement A new feature or improvement

Comments

@OGordon100
Copy link
Contributor

Is your feature request related to a problem? Please describe.

Many numpy functions (e.g. mean) allow for axis= (or axes=) to be not just a single value, but a tuple of multiple axes.

Describe the solution you'd like

Allow functions such as detrend to accept multiple axis.

So instead of

data = np.random.rand(shape=(10,10))

data = scipy.signal.detrend(data, axis=0)
data = scipy.signal..detrend(data, axis=1)

we have

data = np.random.rand(shape=(10,10))

data = scipy.signal.detrend(data, axis=(0, 1))

Describe alternatives you've considered

Additional context (e.g. screenshots)

@Vijayhiga
Copy link

I am working on it.

@V0lantis V0lantis added the enhancement A new feature or improvement label Apr 7, 2021
@tupui
Copy link
Member

tupui commented Apr 7, 2021

I am working on it.

Thanks @Vijayhiga, but what do you mean? Are you looking specifically at scipy.signal.detrend or also other functions as suggested?

@rgommers
Copy link
Member

I'm not sure this is desirable, it seems like a lot of busywork adding this for little real-world value for a function like detrend.

@OGordon100
Copy link
Contributor Author

@rgommers completely disagree. Besides the fact that this could be carried over to other functions, there are lots of valuable use cases. If it's of no value, stuff it why was the functionality ever introduced anywhere else? It's also a really annoying inconsistency when half of functions can be called on multiple axes and half can't. Why not try and refine it?

In probe microscopy (encompassing a huge number of different techniques employed by pretty much every nanoscience group worldwide), for example, we have to correct our images for tilt as part of the most basic level of analysis. Groups are moving away from proprietary manufacturer software to python, and so I can tell you for a fact we have a number of codes calling several scipy functions twice, one for each axis. It would be useful to my sector of research, I can assure you 😉

@rgommers
Copy link
Member

It's also a really annoying inconsistency when half of functions can be called on multiple axes and half can't.

It's way less than half I'd say.

for example, we have to correct our images for tilt

So what do you expect scipy.signal.detrend(data, axis=(0, 1)) to do? Just be a shorthand for:

data = scipy.signal.detrend(data, axis=0)
data = scipy.signal..detrend(data, axis=1)

or fit a 2-D plane and subtract that? I think if we implement it, we can only do the former because it needs to generalize to length-N input to the axis keyword. But better practice for your example would be to actually fit a plane.

signal functionality is basically 1-D, and making axis accept a tuple to do internally a repeated loop of 1-D operations isn't great. For proper n-D operations it's a different story.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A new feature or improvement
Projects
None yet
Development

No branches or pull requests

5 participants