-
Notifications
You must be signed in to change notification settings - Fork 370
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 broadcasting of selectors to the minilanguage #2918
Conversation
Additionally I have caught two bugs in the existing implementation:
(both are fixed) |
@@ -27,8 +27,11 @@ function _combine_prepare(gd::GroupedDataFrame, | |||
keepkeys::Bool, ungroup::Bool, copycols::Bool, | |||
keeprows::Bool, renamecols::Bool) | |||
for cei in cs | |||
@assert cei isa Union{Pair, Base.Callable, ColumnIndex, MultiColumnIndex, | |||
AbstractVecOrMat{<:Pair}} | |||
if !(cei isa AbstractMatrix && isempty(cei)) |
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.
I guess this is again because of broadcasting returning Matrix{Any}
? It's somewhat ugly to have to handle this special case here. Would there be any way to fix this elsewhere?
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.
Yes - this is the Matrix{Any}
case special handling. This is essentially the only place we can handle this in a short way. The point is that we want to do AbstractVecOrMat{<:Pair}
check below (not to allow arbitrary matrices to leak further unless they are empty as then it does not matter what eltype they have - and thus the additional check).
Co-authored-by: Milan Bouchet-Valat <[email protected]>
CI failure here is unrelated. |
src/abstractdataframe/selection.jl
Outdated
@@ -67,6 +67,10 @@ const TRANSFORMATION_COMMON_RULES = | |||
`cols => function`. In particular the following expression `function => target_cols` | |||
is not a valid transformation specification. | |||
|
|||
Note! If `cols` or `target_cols` is one of `All`, `Cols`, `Between`, or | |||
`Not` and is used in a broadcasting context are properly expanded to |
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.
There's a syntax problem here. Just copy the text from above?
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.
I have forgotten to sync the docstrings. Fixed.
Thank you! |
@nalimilan + @pdeffebach: I am sharing the preview of the functionality making e.g.
Not(:x1) .=> sum
work in the minilanguage.The core mechanism should be working for intended cases.
What is todo:
select
,subset
etc. functions that should call it