Skip to content
This repository was archived by the owner on Jul 8, 2021. It is now read-only.

Ucubes summaries#27

Merged
lbdreyer merged 12 commits intoSciTools-incubator:masterfrom
pp-mo:ucubes_summaries
Oct 30, 2020
Merged

Ucubes summaries#27
lbdreyer merged 12 commits intoSciTools-incubator:masterfrom
pp-mo:ucubes_summaries

Conversation

@pp-mo
Copy link
Copy Markdown
Member

@pp-mo pp-mo commented Oct 29, 2020

Re-spin of #26, as I had some problems with stickler testing

Make unstructured cubes load as UCubes (i.e. a specialised subclass).
And then to make them print augmented cube summaries.

Along with SciTools/iris#3914, this effectively completes the import of SciTools/iris#3688 ,which was the POC code for this in the irtis "ng-vat" branch.

Unfinished business:

  • requires Cube print respin SciTools/iris#3914 .
    • May need further change if that changes.
    • Will not pass tests until that is merged
  • needs some kind of testing for UCube._repr_html_
  • ideally, should test that loading can (correctly) produce a mixture of UCube-s and Cube-s.
    ( second thoughts : not very important. not going to bother )

Comment thread iris_ugrid/ugrid_cf_reader.py Outdated
@pp-mo pp-mo requested a review from trexfeathers October 29, 2020 11:33
@trexfeathers trexfeathers self-assigned this Oct 29, 2020
Copy link
Copy Markdown
Contributor

@trexfeathers trexfeathers left a comment

Choose a reason for hiding this comment

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

Thanks @pp-mo! A few things to address, which I will get sorted out with @lbdreyer tomorrow.

Comment thread iris_ugrid/ucube.py Outdated

"""
name = super()._summary_dim_name(dim)
if self.ugrid and dim == self.ugrid.cube_dim:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
if self.ugrid and dim == self.ugrid.cube_dim:
if self.ugrid is not None and dim == self.ugrid.cube_dim:

The original syntax is nice and efficient, but very easy to misinterpret. Is my suggestion equivalent? And I assume that dim == self.ugrid.cube_dim definitely doesn't trip over if self.ugrid doesn't exist?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Comment thread iris_ugrid/ucube.py Outdated
][0]

# Indent the mesh details 4 spaces more than that.
indent = " " * (indent + 4)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
indent = " " * (indent + 4)
indent += (" " * 4)

I don't think the original is written the correct way round. Wouldn't it multiply an existing indent rather than just adding to it?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I was wrong: I hadn't understood that indent is actually numerical at this stage. It only becomes text on L86.
My new suggestion is to give the precursor a different name rather than indent, to avoid confusion.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Comment on lines +201 to +202
Constructs a :class:`CubeUgrid` referencing the appropriate file mesh,
and makes a new `UCube` of which this is the '.ugrid' property.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Need to say somewhere that this actually returns a UCube.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Comment thread iris_ugrid/ugrid_cf_reader.py
Comment thread iris_ugrid/ugrid_cf_reader.py Outdated
Comment on lines +241 to +242
# Return a new UCube, based on the provided Cube, and replacing it
# in the caller (and as returned to user).
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't follow. To me, it doesn't look like anything is replaced anymore - this function no longer modifies cube, instead it returns new_result_cube.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Have attempted to rephrase in a more explicit way. Believe @pp-mo was referring to the downstream change he introduced to iris.fileformats.netcdf.load_cubes()

dc3665e

@trexfeathers trexfeathers requested a review from lbdreyer October 30, 2020 12:08
@trexfeathers
Copy link
Copy Markdown
Contributor

Hi @lbdreyer, please could you see if you think I've addressed my own comments, and that this PR looks OK to you? Thanks!

Comment thread iris_ugrid/ugrid_cf_reader.py Outdated
The cube to be post-processed

Returns:
:class:`iris_ugrid.ucube.UCube`
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

... or None.
It may be worth mentioning that?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Comment on lines +13 to +16
from iris import Constraint
from iris.tests import IrisTest, get_data_path

from iris.cube import CubeList
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't understand this order of these imports.
Why isn't it:

Suggested change
from iris import Constraint
from iris.tests import IrisTest, get_data_path
from iris.cube import CubeList
from iris import Constraint
from iris.cube import CubeList
from iris.tests import IrisTest, get_data_path

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm just going to remove the from iris.tests import altogether, since we're already importing iris.tests on L9.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@lbdreyer lbdreyer requested a review from trexfeathers October 30, 2020 16:02
@lbdreyer
Copy link
Copy Markdown
Member

This looks good to me now. Once travis is finished I will merge in

@trexfeathers I think merge is blocked until you approve it currently says "Merging can be performed automatically once the requested changes are addressed."

@lbdreyer lbdreyer merged commit 4e4d644 into SciTools-incubator:master Oct 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants