Feature request: Add out-of-place (i.e. pure) versions of all existing in-place operations, such as the following: - https://numpy.org/doc/stable/reference/generated/numpy.fill_diagonal.html - https://numpy.org/doc/stable/reference/generated/numpy.put.html - https://numpy.org/doc/stable/reference/generated/numpy.place.html - https://numpy.org/doc/stable/reference/generated/numpy.put_along_axis.html - https://numpy.org/doc/stable/reference/generated/numpy.putmask.html
This can be done by adding a boolean argument to each function called "inplace", which is True by default, but when set to False, makes the function return a modified copy of the array. This is the approach taken by JAX for its counterparts of these functions: - https://jax.readthedocs.io/en/latest/_autosummary/jax.numpy.fill_diagonal.html - https://jax.readthedocs.io/en/latest/_autosummary/jax.numpy.put.html - https://jax.readthedocs.io/en/latest/_autosummary/jax.numpy.place.html This would have the following advantages: - Making it easier to perform these operations in a functional way (potentially less error-prone). - Harmonizing the interfaces of NumPy and JAX. _______________________________________________ NumPy-Discussion mailing list -- numpy-discussion@python.org To unsubscribe send an email to numpy-discussion-le...@python.org https://mail.python.org/mailman3/lists/numpy-discussion.python.org/ Member address: arch...@mail-archive.com