Skip to content

Conversation

@tinyendian
Copy link
Contributor

🚀 Pull Request

Description

This pull request addresses issue #4342: cube method concatenate_cube() can produce confusing error messages, reporting that var1 != var1 when a user (erroneously) attempts to concatenate a multi-variable cube list consisting of, e.g., multiple time steps of var1 and var2 with cubes = [var1, var1, var2, ...].

The reason for this behaviour is that the error message in the method quotes the first two elements of list names, which can be identical in the above scenario. This pull request replaces names with list unique_names when generating the error message - the latter list is used as a criterion for concatenate_cube() to reject concatenation, and it is guaranteed to produce non-identical variable names. This should give the user better feedback on why concatenation failed.

It should not be necessary to handle the cases of length-zero or length-1 list, since len(unique_names) should always be >=2, given that the method will fail earlier on an empty cube list, and it will accept length 1 for concatenation.


Consult Iris pull request check list

@SciTools-assistant SciTools-assistant added the Blocked: CLA needed See https://scitools.org.uk. Submit the form at: https://scitools.org.uk/cla/v4/form label Sep 30, 2021
@tinyendian
Copy link
Contributor Author

Note that I just signed the SciTools CLA.

@rcomer rcomer self-assigned this Sep 30, 2021
@SciTools-assistant SciTools-assistant removed the Blocked: CLA needed See https://scitools.org.uk. Submit the form at: https://scitools.org.uk/cla/v4/form label Sep 30, 2021
@rcomer
Copy link
Member

rcomer commented Sep 30, 2021

Hi @tinyendian, thanks for your contribution!

We have some unit tests that check concatenate throws the right error in various circumstances. Would you be happy to add a test to cover the case you've highlighted? [Edit: see next comment about where such a test should go].

Also, so that we can advertise your contribution in the next release, could you add an entry under "Bugs Fixed" in the whatsnew/latest.rst file? There is guidance about writing a "whatsnew" entry here.

Do let us know if any of this isn't clear, or if you need help with anything.

@rcomer
Copy link
Member

rcomer commented Sep 30, 2021

Sorry, I just realised I pointed to the wrong set of tests in my last comment 🤦‍♀️. The "names differ" error is raised within CubeList.concatenate_cube() itself, so a test to cover this case would need to be added to this class.

@tinyendian
Copy link
Contributor Author

Hi @rcomer, I added a unit test that replicates the multi-variable scenario mentioned in the issue and checks the error message, as well as a "whatsnew" entry in the list of bug fixes. I hope that both match the required styles.

The doctests and link check are failing with error message "Unknown target name: "@tinyendian", does my GitHub name need to be added somewhere?

@trexfeathers
Copy link
Contributor

"Unknown target name: "@tinyendian", does my GitHub name need to be added somewhere?

Correct!

.. comment
Whatsnew author names (@github name) in alphabetical order. Note that,
core dev names are automatically included by the common_links.inc:

See here for a populated example from v3.1:

.. comment
Whatsnew author names (@github name) in alphabetical order. Note that,
core dev names are automatically included by the common_links.inc:
.. _@akuhnregnier: https://github.com/akuhnregnier
.. _@Badboy-16: https://github.com/Badboy-16

Copy link
Member

@rcomer rcomer left a comment

Choose a reason for hiding this comment

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

Thanks @tinyendian, the new test looks perfect to me. It fails without the fix and passes with it. Just need to add the GitHub link for your handle, as @trexfeathers shows above, and then I think this will be ready to merge.

@tinyendian
Copy link
Contributor Author

Thanks, @rcomer, working on it...

@rcomer
Copy link
Member

rcomer commented Oct 1, 2021

Awesome - thanks @tinyendian!

@rcomer rcomer merged commit 92b2739 into SciTools:main Oct 1, 2021
@tinyendian
Copy link
Contributor Author

Thanks for your help getting this over the line, @rcomer and @trexfeathers!

@rcomer rcomer mentioned this pull request Oct 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Confusing error message when applying "concatenate_cube" to multi-variable cube list

4 participants