You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 functions f,g,h
Pandas and Xarray have pipe methods for DataFrames, DataArrays and Datasets, looking over their examples the pipe here would be able to be used like so:
If a user has their own custom SpatialData Accessors for f,g,h (where h's first argument is a SpatialData / 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.
For much more advanced pipeline functionality, the package returns provides some interesting implementations as well with their functions flow and pipe specifically.
The text was updated successfully, but these errors were encountered:
@giovp Currently, this would be useful for some of the pipelines I've created with SpatialData objects in my analysis project. Multiple functions are called sequentially on the same object. It's not a super important feature or use case, it's more of a convenience utility.
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!
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: