Skip to content

Conversation

@davidhassell
Copy link
Collaborator

Fixes #677

Plus a bit of linting on some previous, unconnected work.

@davidhassell davidhassell added this to the 3.15.2 milestone Jun 29, 2023
Copy link
Member

@sadielbartholomew sadielbartholomew left a comment

Choose a reason for hiding this comment

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

Works to re-implement the feature at hand, but ideally we can add to this PR to:

  • add a little testing of the indices on the Field side in test_Field__getitem__ as well; and
  • also (in testing) cover cases of objects with masking as indices since masked arrays can be pesky;
  • add documentation to highlight the possibility of using cf objects as indices, e.g. adding to the 'Assignment by index' section of the tutorial.

I've raised one minor comment and also have one question:

  • should cf objects with a to_dask_array method now be valid inputs to the indices methods of Field and Domain (etc.) because they don't seem to work with those at the moment (but maybe they shouldn't and I am missing something!).

Changelog.rst Outdated
(https://github.com/NCAS-CMS/cf-python/issues/661)
* New keyword parameter to `cf.aggregate`: ``cells``
(https://github.com/NCAS-CMS/cf-python/issues/452)
* Allow `__getitem__` indices that have a `to_dask_array` method
Copy link
Member

Choose a reason for hiding this comment

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

This message makes sense to us for dev purposes but doesn't strike me as being very user friendly, as opposed to something like, as a snippet from the opening sentence you made in that Issue:

... allow cf.Data and other objects (such as cf.DimensionCoordinate) to be used as indices ...

so how about putting something more like that instead? (Obviously imagine we are in an alternative universe where users read the Changelog 😃)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

2aa45ec

As a firm adherent to the many-universes hypothesis, I can rest happy knowing that the obfuscated developers version lives on somewhere :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm looking at the improving the tests and docs as you have suggested ...

@davidhassell
Copy link
Collaborator Author

Hi @sadielbartholomew,

add a little testing of the indices on the Field side in test_Field__getitem__ as well; and also (in testing) cover cases of objects with masking as indices since masked arrays can be pesky;

5a28c94

add documentation to highlight the possibility of using cf objects as indices, e.g. adding to the 'Assignment by index' section of the tutorial.

6fb4e47

Copy link
Member

@sadielbartholomew sadielbartholomew left a comment

Choose a reason for hiding this comment

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

Previous feedback addressed well. Thanks David. I've done a final sanity check and all tests pass locally and everything's good (with one optional minor addition, see in-line). Please merge!

Co-authored-by: Sadie L. Bartholomew <sadie.bartholomew@ncas.ac.uk>
@davidhassell davidhassell merged commit 128e5f4 into NCAS-CMS:main Jul 21, 2023
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.

Allow __getitem__ indices that have a to_dask_array method

2 participants