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

Support in-place numerical operations for SparseLabelOps #917

Open
mrossinek opened this issue Oct 26, 2022 · 1 comment
Open

Support in-place numerical operations for SparseLabelOps #917

mrossinek opened this issue Oct 26, 2022 · 1 comment

Comments

@mrossinek
Copy link
Member

What is the expected enhancement?

#860 suggest supporting in-place operations on SparseLabelOp instances. That issue focuses on the addition of an inplace keyword argument to the public API where this can be useful.

This issue suggests to take this one step further and implement similar methods to allow in-place numerical operations such as addition, scalar multiplication, etc.This can be done by implementing the dunder methods like __iadd__ which get called when doing a += b (currently this gets expanded to a = a + b).

@kevinsung
Copy link
Contributor

kevinsung commented Oct 26, 2022

Some observations:

  • The type of SparseLabelOp will change from Mapping to MutableMapping (or even dict)
  • Setting copy=False in SparseLabelOp.__init__ won't be supported. Because the argument data can be a Mapping which may be immutable, we will need to copy the data no matter what. So we should just remove the copy argument.
  • Alternatively, we can keep the copy argument but change the type of data from Mapping to MutableMapping (or dict)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants