Skip to content

cf.aggregate fails when creating new axes with the dimension keyword #283

@davidhassell

Description

@davidhassell

At v3.11.0 (and all other versions since 3.0.0) , cf.aggregate fails when creating new axes for each input field from one or more given properties, using the dimension keyword argument:

>>> import cf
>>> print (cf.__version__)
3.11.0
>>> f = cf.example_field(0)
>>> g = f.copy()
>>> f.set_property('sim', 'r1i1p1f1')
>>> g.set_property('sim', 'r2i1p1f1')
>>> a = cf.aggregate([f, g], dimension='sim')
Traceback (most recent call last):
  File "agg.py", line 20, in <module>
    a = cf.aggregate([f, g], dimension='sim')[0]
  File "/home/david/NCAS-CMS/cfdm/cfdm/decorators.py", line 171, in verbose_override_wrapper
    return method_with_verbose_kwarg(*args, **kwargs)
  File "/home/david/cf-python/cf/aggregate.py", line 1721, in aggregate
    meta = _Meta(
  File "/home/david/cf-python/cf/aggregate.py", line 355, in __init__
    aux_coords = {
  File "/home/david/cf-python/cf/aggregate.py", line 358, in <dictcomp>
    if axis in construct_axes[aux]
KeyError: 'auxiliarycoordinate0'

This is simply a bug in code that was not covered by the units tests. PR fix to follow.

Thank you to @bnlawrence for originally spotting this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    aggregationRerlating to metadata-based field and domain aggregationbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions