In-place operations #80
Comments
cc @mrocklin @nils-werner Your thoughts would be welcome here. |
The docs say about inplace modification of immutable vs mutable types:
and
To me, that sounds like solution 1. would be acceptable behaviour. Another solution that comes to mind would be to keep |
>>> import numpy as np
>>> x = np.zeros((1, 5))
>>> y = np.ones((5, 5))
>>> x += y
Traceback (most recent call last):
File "<input>", line 1, in <module>
ValueError: non-broadcastable output operand with shape (1,5) doesn't match the broadcast shape (5,5) |
Option 1 seems fine with me with a couple of small comments:
|
I was wondering about operators such as
operator.iadd
, etc. There are a few ways we can go about this:self
a copy of the returned object.data
in-place.If we want to maintain compatibility with Numpy code (I hope to make
COO
a mostly drop-in replacement forndarray
with a few exceptions at some point), I would go with 1, with a warning in the docs that in-place isn't really "in-place".If we want to do our own thing... Then we have options 2 and 3.
The text was updated successfully, but these errors were encountered: