Skip to content
This repository was archived by the owner on May 4, 2019. It is now read-only.

Be more conservative about recycling values #49

Open
johnmyleswhite opened this issue Jan 5, 2014 · 2 comments
Open

Be more conservative about recycling values #49

johnmyleswhite opened this issue Jan 5, 2014 · 2 comments

Comments

@johnmyleswhite
Copy link
Member

Right now, we are far too liberal when recycling values. We should only allow the following behaviors:

  • Allow operations between arrays when their sizes are perfectly matched.
  • Recycle scalars so that they behave like an array of the same size as the non-scalar operand in an operation like addition or multiplication.

We should definitely not follow the R lead of recycling vectors of short length until they match the length of the longer vector. Only arrays whose sizes exactly match should be allowed to interact.

As an example of what we should not allow going forward, consider the following

julia> using DataArrays

julia> x = @data([1, 2, 3, 4, 5])
5-element DataArray{Int64,1}:
 1
 2
 3
 4
 5

julia> y = @data([6, 7])
2-element DataArray{Int64,1}:
 6
 7

julia> x[:] = y
2-element DataArray{Int64,1}:
 6
 7

julia> x
5-element DataArray{Int64,1}:
 6
 7
 3
 4
 5

This operation does not work on Julia's normal arrays. In general, we should always try to behave exactly like Julia's normal arrays, except with NA's added in.

@nalimilan
Copy link
Member

+1

@simonster
Copy link
Member

Since #104, that example throws a DimensionMismatch, and setindex! should behave identically to a normal array. Is there more work to be done here?

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

No branches or pull requests

3 participants