-
Notifications
You must be signed in to change notification settings - Fork 43
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
Adding .pipe
to SpatialData
#695
Comments
hi @srivarra , this sounds a very interesting feature! what could be a use case for this at the moment? |
@giovp Currently, this would be useful for some of the pipelines I've created with |
Sounds very interesting @srivarra , I personally don't have a lot of capacity for new features atm, but if you feel like submitting a PR, would be very happy to support! |
@srivarra Would you be willing to help implement this? If so we could schedule a meeting and work on it together if you would like. |
@melonora Yeah I'd be willing to implement this, was on vacation for a while, but I'll add a PR soonish. |
Thanks @srivarra, the feature looks very interesting! Happy to review the PR 😊 |
Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
It'd be elegant to be able to chain functions on a
SpatialData
object. Currently given some functionsf
,g
,h
We would have to do the following:
Describe the solution you'd like
Pandas
andXarray
havepipe
methods forDataFrames
,DataArrays
andDatasets
, looking over their examples thepipe
here would be able to be used like so:Describe alternatives you've considered
If a user has their own custom SpatialData Accessors for
f
,g
,h
(whereh
's first argument is aSpatialData
/self
object in this case), then it should work just the same, but incorporating the accessor call within a lambda function makes it rather wordy.Just chaining the accessor is much easier to read in this instance.
For accessors, piping would be more useful in contexts where there are higher order functions composed of calls to the accessor's methods:
Additional context
Implementation:
The following has been taken from https://github.com/pydata/xarray/blob/d33e4ad9407591cc7287973b0f8da47cae396004/xarray/core/common.py#L717-L847
These pipes can return anything so users would have to keep that in mind if they plan on chaining multiple calls to
pipe
.References:
Pandas DataFrame.pipe()
Xarray DataArray.pipe()
returns
provides some interesting implementations as well with their functionsflow
andpipe
specifically.The text was updated successfully, but these errors were encountered: