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

For DSGs, don't attempt to aggregate non-feature axes #730

Merged
merged 6 commits into from
Mar 1, 2024
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions cf/aggregate.py
Original file line number Diff line number Diff line change
Expand Up @@ -2977,11 +2977,19 @@ def aggregate(
# ------------------------------------------------------------
if axes is None:
# Aggregation will be over as many axes as possible
aggregating_axes = meta[0].axis_ids
m0 = meta[0]
aggregating_axes = m0.axis_ids[:]

# For DSG feature types, only consider aggregating the
# feature dimension(s).
if m0.featureType:
for axis in aggregating_axes[:]:
if not dsg_feature_type_axis(m0, axis):
aggregating_axes.remove(axis)

_create_hash_and_first_values(
meta, None, False, hfl_cache, rtol, atol
meta, aggregating_axes, False, hfl_cache, rtol, atol
)

else:
# Specific aggregation axes have been selected
aggregating_axes = []
Expand Down Expand Up @@ -3492,7 +3500,8 @@ def _create_hash_and_first_values(

meta: `list` of `_Meta`

axes: `None` or `list`
axes: `list`
The identities of the possible aggregating axes.

donotchecknonaggregatingaxes: `bool`

Expand All @@ -3505,10 +3514,15 @@ def _create_hash_and_first_values(
# identity.
canonical_direction = {}

aggregating_axes = list(axes)
davidhassell marked this conversation as resolved.
Show resolved Hide resolved

for m in meta:
field = m.field
constructs = field.constructs.todict()

# Store the aggregating axis identities
m.aggregating_axes = aggregating_axes

m_sort_keys = m.sort_keys
m_sort_indices = m.sort_indices

Expand Down Expand Up @@ -4131,7 +4145,7 @@ def _group_fields(meta, axis, info=False):
group is represented by a `list` of `_Meta` objects.

"""
axes = meta[0].axis_ids
axes = meta[0].aggregating_axes

if axes:
if axis in axes:
Expand Down
Loading