-
Notifications
You must be signed in to change notification settings - Fork 603
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
Remove inplace argument in scanpy 2.0 #2583
Comments
@flying-sheep suggested to write a hatch-plugin that can automatically create the respective @overload type hints |
Notes from discussion with @Intron7, @flying-sheep, @gtca, and @grst at hackathon:
|
Unformatted notes by me: Behaviors that exist for
|
What if we had copy-on-write behavior for AnnData? Then we could never modify AnnData inplace but always return a view of an AnnData with references to the objects that were unchanged and only the new data added. Pandas seems to be going that route: https://github.com/pandas-dev/pandas/blob/57390ada100466dac777e5b66d5a4f2a72700c38/web/pandas/pdeps/0008-inplace-methods-in-pandas.md (HT @bernheder) |
Our views are a limited version of COW ( If I understand the idea correctly, I’d be for it if we could guarantee that all nested data structures delegate modification to us. I don’t know if that’s possible with things like dask arrays and (at the time of writing) pandas data frames. |
@flying-sheep This guarantee seems hard to ask for though? @grst It would be great but it's unclear how to do that properly for a container-like data structure such as AnnData. E.g. even for data frames for value changes that document already states the following:
|
Agree it's challenging, but maybe not impossible
A couple of examples how I think this would look like:
|
What kind of feature would you like to request?
Other?
Please describe your wishes
Another point that I'd like to throw into the scanpy 2.0 discussion:
Right now, many functions have the
inplace
argument, that determines if a function should write back toadata
or return the result instead.With this behavior it is hard to make correct type hints. While it is possible with
@overload
, it is cumbersome because it requires to type out the entire function signature twice. When I asked if it is possible to write these overloads in a more concise way on stackoverflow several users argued that changing the return type based on an argument is an anti-pattern, and I think they convinced me.Alternative approach
Have two API levels, e.g.
and
Where the former is a wrapper for the latter. This allows to separate the implementation of the actual method using only numpy/scipy data types from the scverse-specific behavior.
The text was updated successfully, but these errors were encountered: