Skip to content

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 ;)

@rafaqz rafaqz marked this pull request as ready for review March 8, 2025 20:33
@codecov
Copy link

codecov bot commented Mar 8, 2025

Codecov Report

Attention: Patch coverage is 76.08696% with 11 lines in your changes missing coverage. Please review.

Project coverage is 80.61%. Comparing base (80954d7) to head (de2440f).
Report is 5 commits behind head on breaking.

Files with missing lines Patch % Lines
src/stack/indexing.jl 22.22% 7 Missing ⚠️
src/utils.jl 0.00% 3 Missing ⚠️
src/stack/stack.jl 94.44% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##           breaking     #903   +/-   ##
=========================================
  Coverage     80.60%   80.61%           
=========================================
  Files            54       54           
  Lines          5130     5168   +38     
=========================================
+ Hits           4135     4166   +31     
- Misses          995     1002    +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@rafaqz rafaqz changed the base branch from main to breaking March 8, 2025 23:33
@rafaqz rafaqz merged commit 49746ef into breaking Mar 8, 2025
7 of 10 checks passed
@rafaqz rafaqz deleted the combine branch March 8, 2025 23:33
@felixcremer
Copy link
Collaborator

Did this close #745?

@felixcremer felixcremer mentioned this pull request Sep 23, 2025
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.

4 participants