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

Check size of arrays being assigned #911

Closed
ViralBShah opened this issue Jun 3, 2012 · 7 comments
Closed

Check size of arrays being assigned #911

ViralBShah opened this issue Jun 3, 2012 · 7 comments
Labels
bug Indicates an unexpected problem or unintended behavior

Comments

@ViralBShah
Copy link
Member

This seems like some sort of bug
indexing five elements on the left, six on the right

julia> A
5x5 Int64 Array:
 1   6  11  16  21
 2   7  12  17  22
 3   8  13  18  23
 4   9  14  19  24
 5  10  15  20  25

julia> A[1:5]=2:7
2:7

julia> A
5x5 Int64 Array:
 2   6  11  16  21
 3   7  12  17  22
 4   8  13  18  23
 5   9  14  19  24
 6  10  15  20  25
@ViralBShah
Copy link
Member Author

cc: @alanedelman

@JeffBezanson
Copy link
Member

Could be considered a bug, or could just be defined to take the necessary number of elements from an iterable. The right side could even be an infinite vector.

@ViralBShah
Copy link
Member Author

What happens in multi-dimensional arrays if there is a size mismatch?

-viral

On 04-Jun-2012, at 7:14 AM, Jeff Bezanson wrote:

Could be considered a bug, or could just be defined to take the necessary number of elements from an iterable. The right side could even be an infinite vector.


Reply to this email directly or view it on GitHub:
#911 (comment)

@StefanKarpinski
Copy link
Member

I really think this should be an error.

@StefanKarpinski
Copy link
Member

If taking a few elements from a bigger structure is intended, it's worth slicing on the right too.

@JeffBezanson
Copy link
Member

In the middle of fixing this. I encountered the following use case in the tests:

true_fftd3_m3d[:,:,1] = 17:2:45

If the RHS is 1d, should we just check the element count?

JeffBezanson added a commit that referenced this issue Jun 20, 2012
The rule I propose is: the number of elements on the left and right must
match. Then, either the left/right shapes match in the normal way (i.e.
ignoring trailing singleton dims), or one side can be 1d. This allows
filling an n-D region from a vector.
@timholy
Copy link
Member

timholy commented Jun 30, 2012

I like this solution. Could this be closed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

4 participants