Skip to content

Stop using rep()#968

Merged
nalimilan merged 1 commit intomasterfrom
nl/rep
May 26, 2016
Merged

Stop using rep()#968
nalimilan merged 1 commit intomasterfrom
nl/rep

Conversation

@nalimilan
Copy link
Copy Markdown
Member

This function lives in DataArrays and is mostly redundant with
Base.repeat(). Use the latter where possible, or custom code
when not, so that we can deprecate rep().

Cf. JuliaStats/DataArrays.jl#186.

r1, r2 = size(df1, 1), size(df2, 1)
cols = [[rep(c, 1, r2) for c in columns(df1)];
[rep(c, r1, 1) for c in columns(df2)]]
cols = [[c[repeat(collect(1:length(c)), inner=[r2])] for c in columns(df1)];
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The new code isn't as clean as the old one here since repeat only works for Array until JuliaLang/julia#14082 is merged. Not sure we could backport it to 0.4 or have a version in Compat.jl. It's not terrible anyway.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The new repeat was backported in Compat, which allowed cleaning the code.

@nalimilan nalimilan force-pushed the nl/rep branch 2 times, most recently from 2815a07 to 38c122d Compare May 25, 2016 21:23
This function lives in DataArrays and is mostly redundant with
Base.repeat(). Use the latter where possible, or custom code
when not, so that we can deprecate rep(). Use Compat.repeat()
since Base.repeat() only works with Array on 0.4.
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.

1 participant