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

Breaking: add combine method for groupby output, fixing similar for AbstractDimStack #903

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

rafaqz
Copy link
Owner

@rafaqz rafaqz commented Jan 14, 2025

This PR introduces a combine method to make things like this easier:

combine(f, groupby(dim_array_or_stack, Ti=month); dims=Ti)

It helps with recomposing grouped output into a single DimArray/DimStack allowing for partial reductions of the grouped content.

Surprisingly hardly any code needed to do this, once I actually fixed similar to make more sense on DimStack, and a few bugs in setindex! on stacks. I guess in the past it wasn't totally clear how these things should work. But making combine just work like this for arrays or stacks probably means the design is correct now.

similar now matches NamedTuple eltypes as layer types, and keeps the same dimension structure as the original stack (layers missing dimensions are still missing dimensions after similar).

If `dims` is given, combine only the dimensions in `dims`. The reducing function
`f` must accept a `dims` keyword.
"""
function combine(f::Function, gb::DimGroupByArray{G}; dims=:) where G
Copy link
Collaborator

Choose a reason for hiding this comment

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

DataAPI.combine? Since DD owns one of the types...

Copy link
Owner Author

@rafaqz rafaqz Jan 14, 2025

Choose a reason for hiding this comment

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

It doesn't exist yet JuliaData/DataAPI.jl#65 ;)

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