-
Notifications
You must be signed in to change notification settings - Fork 300
Clearer error message when using concatenate_cube on multi-variable cubes list #4345
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
Conversation
for more information, see https://pre-commit.ci
|
Note that I just signed the SciTools CLA. |
|
Hi @tinyendian, thanks for your contribution!
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. |
|
Sorry, I just realised I pointed to the wrong set of tests in my last comment 🤦♀️. The "names differ" error is raised within |
|
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? |
Correct! iris/docs/src/whatsnew/latest.rst Lines 145 to 149 in a07e20d
See here for a populated example from iris/docs/src/whatsnew/3.1.rst Lines 300 to 305 in b15386e
|
rcomer
left a comment
There was a problem hiding this 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.
|
Thanks, @rcomer, working on it... |
|
Awesome - thanks @tinyendian! |
|
Thanks for your help getting this over the line, @rcomer and @trexfeathers! |
🚀 Pull Request
Description
This pull request addresses issue #4342: cube method
concatenate_cube()can produce confusing error messages, reporting thatvar1 != var1when a user (erroneously) attempts to concatenate a multi-variable cube list consisting of, e.g., multiple time steps of var1 and var2 withcubes = [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 replacesnameswith listunique_nameswhen generating the error message - the latter list is used as a criterion forconcatenate_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