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

Implement pre-commit checks fixes #20

Merged
merged 1 commit into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 31 additions & 19 deletions cc_plugin_ugrid/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os
import logging

from compliance_checker.base import BaseNCCheck, Result

try:
Expand All @@ -10,13 +10,15 @@
logger = logging.getLogger(__name__)
logger.addHandler(logging.NullHandler())


class UgridException(Exception):
pass


class UgridChecker(BaseNCCheck):
_cc_spec = 'UGRID'
_cc_url = 'https://github.com/ioos/cc-plugin-ugrid'
_cc_author = 'Brian McKenna <[email protected]>'
_cc_spec = "UGRID"
_cc_url = "https://github.com/ioos/cc-plugin-ugrid"
_cc_author = "Brian McKenna <[email protected]>"
_cc_checker_version = __version__

@classmethod
Expand All @@ -43,26 +45,36 @@ def setup(self, ds):
ds : netCDF4 dataset object
"""


self.ds = ds
self.meshes = {
m:{} for m in self.ds.get_variables_by_attributes(
cf_role='mesh_topology'
)
m: {} for m in self.ds.get_variables_by_attributes(cf_role="mesh_topology")
}

for mesh in self.meshes.keys():
for att in ['boundary_node_coordinates', 'edge_coordinates',
'edge_dimension', 'edge_face_connectivity', 'edge_node_connectivity',
'face_coordinates', 'face_dimension', 'face_edge_coordinates',
'face_face_connectivity', 'face_node_connectivity', 'nedges', 'nfaces',
'node_coordinates', 'topology_dimension', 'volume_dimension',
'volume_edge_coordinates', 'volume_face_connectivity', 'volume_node_connectivity',
'volume_coordinates', 'volume_shape_type', 'volume_volume_connectivity'
]:

for att in [
"boundary_node_coordinates",
"edge_coordinates",
"edge_dimension",
"edge_face_connectivity",
"edge_node_connectivity",
"face_coordinates",
"face_dimension",
"face_edge_coordinates",
"face_face_connectivity",
"face_node_connectivity",
"nedges",
"nfaces",
"node_coordinates",
"topology_dimension",
"volume_dimension",
"volume_edge_coordinates",
"volume_face_connectivity",
"volume_node_connectivity",
"volume_coordinates",
"volume_shape_type",
"volume_volume_connectivity",
]:
try:
self.meshes[mesh][att] = mesh.getncattr(att)
except AttributeError: # NetCDF: Attribute not found
except AttributeError: # NetCDF: Attribute not found
self.meshes[mesh][att] = None

Loading