-
Notifications
You must be signed in to change notification settings - Fork 35
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
Jq/pushappend #9
Conversation
@@ -193,3 +193,13 @@ function getindex(A::CatOrdArray, i::Int) | |||
end | |||
|
|||
levels!(A::CatOrdArray, newlevels::Vector) = _levels!(A, newlevels) | |||
|
|||
Base.push!{T, R}(A::CategoricalArray{T, 1, R}, item::T) = (push!(A.refs, get!(A.pool, item)); return A) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better use the CatOrdArray
alias as elsewhere, rather than duplicating definitions.
I'm afraid these definitions won't work in two cases:
For EDIT: please also add tests for these corner cases (in both 11_array.jl and 12_nullablearray.jl). |
Would we really want |
Another method I realized I need is |
Sorry, I meant |
Alrighty, cleaned up and tests passing. Might not be the most performant solutions in the world, but they seem to be functional. |
I do find it interesting that there are two coverage systems on CI, but no travis or appveyor? :) |
x = V{String, R}(a) | ||
push!(x, "a") | ||
@test length(x) == 4 | ||
@test String(x[end]) == "a" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for String
here, ==
is implemented to allow direct comparisons with NominalValue
.
Thanks. These look reasonably fast. We could be slightly faster by 1) copying the integer codes for
AFAIK Travis is enabled. We could add AppVeyor, but nothing should be Windows-specific in this package, so not a high priority. |
Coverage increased (+0.6%) to 83.986% when pulling 7e33fe3b7d0ec99114ae76ed4180c83b7c55e0b4 on quinnj:jq/pushappend into 98c147d on nalimilan:master. |
1 similar comment
Coverage increased (+0.6%) to 83.986% when pulling 7e33fe3b7d0ec99114ae76ed4180c83b7c55e0b4 on quinnj:jq/pushappend into 98c147d on nalimilan:master. |
Ok updated. I mention travis because it doesn't seem to be showing up here to show its status. |
|
||
|
||
empty!(x) | ||
@test length(x) == 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please test that levels are preserved.
There's a test failure on Travis. Apart from this and the two details I noted, should be OK. |
Weird, I can't reproduce the error when I run the test file by itself, only when I run the entire test suite. Can you think of any reason I'd see that? Unfortunately, the backtraces seemed to be messed up when the test suite is run in full and it doesn't tell me the individual test that is failing. I'll keep trying ot figure out what's going on here. |
|
||
y = V{String, R}(a) | ||
append!(x, y) | ||
@test length(x) == 10 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also test the contents of x
after appending? Same below.
Got it. The error was only happening with Could you also repeat the new test code for each series of tests in each file? The test are currently repeated (with some variations were needed) for vectors (without then with nulls) and matrices (without then with nulls). I could probably simplify this, but for now I'd prefer that you follow that structure. |
Well, we won't need the tests for matrices since we're only dealing with vector operations here (push!, append!) |
Right, so please just repeat the tests twice (one for without nullables, then one with nullables). |
Current coverage is 83.62% (diff: 100%)@@ master #9 diff @@
==========================================
Files 7 7
Lines 271 281 +10
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
+ Hits 225 235 +10
Misses 46 46
Partials 0 0
|
Ok, think we're good to go here. |
@test length(x) == 6 | ||
@test x[1] == x[end] | ||
@test levels(x) == ["e", "a", "b", "c", "zz"] | ||
# ["c", "a", "a", "a", "zz", "c"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leftover?
|
||
append!(x, x) | ||
@test length(x) == 12 | ||
@test x[1] == "c" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't this be replaced with x == ["c", "a", ...]
?
Alright, let's see what CI says about this. |
2 similar comments
Thanks! Sorry it took so many rounds of review! Tell me if you need me to tag a new release. |
Needed by DataStreams.jl. This uncovered a bug in _levels!() when the input contained missing values.
No worries. Yeah, let's tag a new release. I can do that if you'd like. |
I'd just like to include commit d4a4e70, but tests unexplicably fail on Travis while they pass locally. Could you checkout |
Ah, nevermind, I just realized this depends on JuliaStats/NullableArrays.jl#141, which isn't merged upstream. Let me find a temporary fix. |
OK, should be good as soon as all tests are done. Feel free to tag the new commit as version 0.0.3 (I'm going to be offline for a few hours). |
Do you want to do a "release" on github and I can just use that? |
No description provided.