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

Switch to get/set methods #213

Merged
merged 4 commits into from Mar 21, 2013
Merged

Switch to get/set methods #213

merged 4 commits into from Mar 21, 2013

Conversation

johnmyleswhite
Copy link
Contributor

This pull request tries to make the full transition over to getindex and setindex!. It would be great if someone could try it out and confirm that it works.

@blakejohnson
Copy link

@johnmyleswhite you seem to missing several ref/assigns. Search for ref{ and assign{ and you'll pick up a bunch of hits.

@johnmyleswhite
Copy link
Contributor Author

Thanks! I'll finish this today.

Conflicts:
	src/dataarray.jl

Many other fixes: update for cor(), svd(), etc.
@johnmyleswhite
Copy link
Contributor Author

I think this is ready to go. I've also made a lot of other fixes that we needed.

@kmsquire, note that the two calls to using Stats are required: one pulls the names into DataFrames for easy access within the module, whereas the other call pushes those names into Main.

@johnmyleswhite
Copy link
Contributor Author

I'll merge this tomorrow morning barring any objections.

# TODO: Make inds::AbstractVector
## # There are two definitions in order to remove ambiguity warnings
getindex{T<:Number,N}(d::DataArray{T,N}, inds::Union(BitVector, Vector{Bool})) = DataArray(d.data[inds], d.na[inds])
getindex{T<:Number,N}(d::DataArray{T,N}, inds::Union(Vector, Ranges, BitVector)) = DataArray(d.data[inds], d.na[inds])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is another possible ref into an array with #undefs. Maybe we need a function that just checks for that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still need to ponder this more. Why is indexing an undef so bad? It's possible in Base Julia, although it throws an error:

julia> a = Array(ASCIIString, 5)
5-element ASCIIString Array:
 #undef
 #undef
 #undef
 #undef
 #undef

julia> a[1]
ERROR: access to undefined reference
 in getindex at array.jl:246

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is issue #198. If you end up with undefs in d.data, but d.na is all true's, indexing into that should return NA. That's the DataArray you get from using a = DataArray(Array(ASCIIString, 5)). We need one of two rules:

  1. If at all possible, don't allow undefs in d.data.
  2. Before indexing into d.data, check d.na to see if there are NAs.

As part of a commit to start to address #198, I used option 2, but option 1 may be the better approach.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I very strongly think that Option 2 is the way to go. Option 1 is like building a dam against the ocean when dealing with strings.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we build up a good test suite for this? I have some examples in mind, but it would be good to pinpoint all the places where NA's are not being returned because of undef's.

@tshort
Copy link
Contributor

tshort commented Mar 21, 2013

Thanks for doing this, John. No objections here.

@kmsquire
Copy link
Contributor

@kmsquire, note that the two calls to using Stats are required: one pulls the names into DataFrames for easy access within the module, whereas the other call pushes those names into Main.

Okay, thanks. Maybe it would be good to add a comment to that effect?

@johnmyleswhite
Copy link
Contributor Author

Done.

johnmyleswhite added a commit that referenced this pull request Mar 21, 2013
Switch to get/set methods
@johnmyleswhite johnmyleswhite merged commit 774bef0 into master Mar 21, 2013
@johnmyleswhite
Copy link
Contributor Author

Merged.

@garborg garborg deleted the getset branch November 25, 2014 23:10
nalimilan pushed a commit that referenced this pull request May 26, 2022
Switch to get/set methods
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants