Discussion:
[Numpy-discussion] ENH: Add the function 'expand_view'
John Kirkham
2015-11-24 19:57:00 UTC
Permalink
Takes an array and tacks on arbitrary dimensions on either side, which is returned as a view always. Here are the relevant features:

* Creates a view of the array that has the dimensions before and after tacked on to it.
* Takes the before and after arguments independent of each other and the current shape.
* Allows for read and write access to the underlying array.


To see an example of what this would look like, see this PR ( https://github.com/numpy/numpy/pull/6713 ).
Nathaniel Smith
2015-11-25 00:13:07 UTC
Permalink
Post by John Kirkham
Takes an array and tacks on arbitrary dimensions on either side, which is
* Creates a view of the array that has the dimensions before and after tacked on to it.
* Takes the before and after arguments independent of each other and the current shape.
* Allows for read and write access to the underlying array.
Can you expand this with some discussion of why you want this function, and
why you chose these specific features? (E.g. as mentioned in the PR
comments already, the reason broadcast_to returns a read-only array is that
it was decided that this was less confusing for users, not because of any
technical issue.)

-n
j***@gmail.com
2015-11-25 02:13:47 UTC
Permalink
Post by John Kirkham
Post by John Kirkham
Takes an array and tacks on arbitrary dimensions on either side, which
* Creates a view of the array that has the dimensions before and after
tacked on to it.
Post by John Kirkham
* Takes the before and after arguments independent of each other and the
current shape.
Post by John Kirkham
* Allows for read and write access to the underlying array.
Can you expand this with some discussion of why you want this function,
and why you chose these specific features? (E.g. as mentioned in the PR
comments already, the reason broadcast_to returns a read-only array is that
it was decided that this was less confusing for users, not because of any
technical issue.)
Why is this a stride_trick?

I thought this looks similar to expand_dims and could maybe be implemented
with some extra options there.



Josef
Post by John Kirkham
-n
_______________________________________________
NumPy-Discussion mailing list
https://mail.scipy.org/mailman/listinfo/numpy-discussion
Benjamin Root
2015-11-26 15:30:57 UTC
Permalink
How is this different from using np.newaxis and broadcasting? Or am I
misunderstanding this?

Ben Root
Post by j***@gmail.com
Post by John Kirkham
Post by John Kirkham
Takes an array and tacks on arbitrary dimensions on either side, which
* Creates a view of the array that has the dimensions before and after
tacked on to it.
Post by John Kirkham
* Takes the before and after arguments independent of each other and
the current shape.
Post by John Kirkham
* Allows for read and write access to the underlying array.
Can you expand this with some discussion of why you want this function,
and why you chose these specific features? (E.g. as mentioned in the PR
comments already, the reason broadcast_to returns a read-only array is that
it was decided that this was less confusing for users, not because of any
technical issue.)
Why is this a stride_trick?
I thought this looks similar to expand_dims and could maybe be implemented
with some extra options there.
Josef
Post by John Kirkham
-n
_______________________________________________
NumPy-Discussion mailing list
https://mail.scipy.org/mailman/listinfo/numpy-discussion
_______________________________________________
NumPy-Discussion mailing list
https://mail.scipy.org/mailman/listinfo/numpy-discussion
Loading...