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

reuploading changes for bounds of derived variables #6350

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

HGWright
Copy link
Contributor

🚀 Pull Request

Description

I seem to have royally screwed up the old PR for this. So here are all of the relevant current changes for that.

Will copy over all of the discussions from the PR soon.


Consult Iris pull request check list


Add any of the below labels to trigger actions on this PR:

  • benchmark_this Request that this pull request be benchmarked to check if it introduces performance shifts

Copy link

codecov bot commented Feb 28, 2025

Codecov Report

Attention: Patch coverage is 29.33333% with 53 lines in your changes missing coverage. Please review.

Project coverage is 89.60%. Comparing base (da199ee) to head (82be35f).

Files with missing lines Patch % Lines
lib/iris/fileformats/cf.py 28.37% 49 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6350      +/-   ##
==========================================
- Coverage   89.79%   89.60%   -0.20%     
==========================================
  Files          90       90              
  Lines       23554    23608      +54     
  Branches     4391     4411      +20     
==========================================
+ Hits        21150    21153       +3     
- Misses       1662     1710      +48     
- Partials      742      745       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@pp-mo pp-mo linked an issue Mar 3, 2025 that may be closed by this pull request
@pp-mo
Copy link
Member

pp-mo commented Mar 3, 2025

Note (for my benefit!)
This basically replaces #6190

This comment is a useful summary of the agreed behaviour we should be delivering
-- plus the statement, just previous
"We can also avoid making this save to the best version of CF until a later date"
-- which means, as I read it, no change to saving at all (for now)

Copy link
Contributor

@stephenworsley stephenworsley left a comment

Choose a reason for hiding this comment

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

Just a couple notes on places to improve the code. As mentioned offline, the major thing this needs now tests. It's worth pushing something up demonstrating expected behaviour even if they're currently failing.

cf_root_var = self.cf_group[cf_root]
if not hasattr(cf_root_var, "standard_name"):
continue
name = cf_root_var.standard_name or cf_root_var.long_name
Copy link
Contributor

Choose a reason for hiding this comment

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

if you reach this point you will have a standard name, so or cf_root_var.long_name is unnecessary.

cf_root_coord = self.cf_group.coordinates.get(cf_root)
if cf_root_coord is None:
cf_root_coord = self.cf_group.auxiliary_coordinates.get(cf_root)
with contextlib.suppress(AttributeError):
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like this is probably not necessary. Would you not want to do something like bounds_name = getattr(cf_root_coord, "bounds", default=None)?

bounds_name = cf_root_coord.bounds

if bounds_name is not None:
try:
Copy link
Contributor

Choose a reason for hiding this comment

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

Ultimately, I think you'll probably want to replace this try-except call. I expect you ought to be able to replace this with something like:

bounds_vars = [...]
if len(bounds_vars) == 1:
  bounds_var = bounds_vars[0]
  ...
else:
  ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Status: 👀 In Review
Development

Successfully merging this pull request may close these issues.

Bounds of derived variable are not read correctly
3 participants