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

Conversation

@trexfeathers
Copy link
Contributor

@trexfeathers trexfeathers commented Dec 14, 2020

This PR shifts tests/synthetic_data_generator to a full package structure, where the generation code is held within __init__.py and various CDL header templates are held within the mesh_headers/ sub-directory.

The generation and associated tests are more agnostic than before, allowing the generation of a greater variety of dataset types.

The current available dataset types are as follows, and the code also accounts for planned future additions (e.g. data located on edges):

Data location Dimensionality UM Levels Configurable Sizes Notes
faces 2D half mesh, time-dim the existing functionality
faces 3D (layered) half mesh, time-dim, number of levels
faces 3D (layered) full mesh, time-dim, number of levels

@trexfeathers trexfeathers added the enhancement New feature or request label Dec 14, 2020
Copy link
Member

@pp-mo pp-mo left a comment

Choose a reason for hiding this comment

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

Suggested some rework -- hope it's not too troublesome

Copy link
Member

@pp-mo pp-mo left a comment

Choose a reason for hiding this comment

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

Some tiny points to consider, but I think it hangs together now 💐

I see that subtle differences between similar things have made some things a bit repetitive + verbose -- especially the tests -- but so be it.
After all, @bjlittle never shrinks from writing stuff like that -- especially in tests !

# Data addition dependent on this assumption:
assert len(unlimited_dim_names) < 2

# Fill all data variables (both mesh and phenomenon vars) with zeros.
Copy link
Member

Choose a reason for hiding this comment

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

Tiny nit-picky point : not always zeros !

Copy link
Contributor Author

Choose a reason for hiding this comment

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

"""Shared data populating behaviour.
Adds placeholder data to the variables in a NetCDF file, accounting for
dimension size, unlimited dimensions and 'dimension coordinates'.
Copy link
Member

Choose a reason for hiding this comment

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

Maybe say "a possible unlimited dimension" ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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


file_path = create_file__xios_half_levels_faces(
def create_synthetic_file(self, **create_kwargs):
# Placeholder that will be overridden by sub-classes.
Copy link
Member

Choose a reason for hiding this comment

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

As it's a placeholder -- i.e. an abstract method -- I don't think providing a "default" operation is a good idea.
You could either

  1. go back to using abc-s to enforce overriding
  2. provide no routine body, just "pass" (which should cause an error in use, as the caller expects a filepath)
  3. raise NotImplementedError(), which is more-or-less what abc would do

Case (1) requires metaclass=abc.ABCMeta in the class def, and then @abstractmethod on this method.
(See iris.coords._DimensionalMetadata for examples)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cool, I'm familiar with what you're talking about but I wasn't sure of best practice, especially when it comes to constructing a test class. I will use 1 and 2!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

e9260ef

There did seem to be some unexpected interaction with py.test so I opted for the simpler NotImplementedError.

@trexfeathers
Copy link
Contributor Author

I see that subtle differences between similar things have made some things a bit repetitive + verbose

Yes, that was mildly frustrating, but no big problem

@pp-mo pp-mo merged commit e618a48 into SciTools-incubator:master Dec 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants