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

Add recode() function #67

Merged
merged 1 commit into from
Jun 10, 2017
Merged

Add recode() function #67

merged 1 commit into from
Jun 10, 2017

Conversation

nalimilan
Copy link
Member

Modeled after dplyr's and Stata's eponymous functions.

The generic AbstractArray method could live in a more basic package, but I'm not sure which one.

@nalimilan nalimilan force-pushed the nl/recode branch 3 times, most recently from ea87d27 to 48528f9 Compare May 16, 2017 20:42
# and using a wider type than necessary would be annoying
T = default === nothing ? V : promote_type(typeof(default), V)
# TODO: result should not be a nullable array when one of the pairs' LHS is null
if T <: Nullable || eltype(a) <: Nullable
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure this will matter if it will be changed for Union{T, Null}, but to check for nullability here could you use the method

typeintersect(T, Nullable) !== Union{}

you mentioned here?

Same for the next function.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, that's a bit problematic. In theory we should use typeintersect, but in practice it doesn't sound very useful to return a NullableArray when T == Any.

The TODO refers to the fact that with Union{T, Null}, we will be able to know whether one of the pairs' LHS is null at compile time just from its type, which isn't possible with Nullable. This will allow returning a non-nullable array when we know in advance all missing values will be replaced with a non-null value.

@cjprybol
Copy link
Contributor

This looks great!

@nalimilan nalimilan force-pushed the nl/recode branch 2 times, most recently from 60c44d2 to 3f331e1 Compare June 10, 2017 14:32
@JuliaData JuliaData deleted a comment from codecov bot Jun 10, 2017
@JuliaData JuliaData deleted a comment from coveralls Jun 10, 2017
Modeled after dplyr's and Stata's eponymous functions.
@JuliaData JuliaData deleted a comment from codecov bot Jun 10, 2017
@codecov
Copy link

codecov bot commented Jun 10, 2017

Codecov Report

Merging #67 into master will decrease coverage by 0.18%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #67      +/-   ##
==========================================
- Coverage   92.24%   92.06%   -0.19%     
==========================================
  Files           9       10       +1     
  Lines         529      693     +164     
==========================================
+ Hits          488      638     +150     
- Misses         41       55      +14
Impacted Files Coverage Δ
src/CategoricalArrays.jl 100% <ø> (ø) ⬆️
src/recode.jl 100% <100%> (ø)
src/nullablearray.jl 70.96% <0%> (-6.12%) ⬇️
src/value.jl 67.44% <0%> (-3.99%) ⬇️
src/array.jl 92.24% <0%> (-1.9%) ⬇️
src/extras.jl 98.57% <0%> (+0.02%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f184019...728add9. Read the comment docs.

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.

2 participants