Skip to content

Commit 7e5fea4

Browse files
committed
Reformat all Python files using Black
1 parent 41a8553 commit 7e5fea4

22 files changed

Lines changed: 2462 additions & 1383 deletions

aodntools/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '0.0.0'
1+
__version__ = "0.0.0"

aodntools/ncwriter/__init__.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
from .imos_template import ImosTemplate, TIMESTAMP_FORMAT
44

55
__all__ = [
6-
'ImosTemplate',
7-
'DatasetTemplate',
8-
'ValidationError',
9-
'metadata_attributes',
10-
'special_attributes',
11-
'TIMESTAMP_FORMAT'
6+
"ImosTemplate",
7+
"DatasetTemplate",
8+
"ValidationError",
9+
"metadata_attributes",
10+
"special_attributes",
11+
"TIMESTAMP_FORMAT",
1212
]

aodntools/ncwriter/imos_template.py

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55

66
from .template import DatasetTemplate
77

8-
IMOS_GLOBAL_JSON = resource_filename(__name__, 'imos_global.json')
8+
IMOS_GLOBAL_JSON = resource_filename(__name__, "imos_global.json")
99
IMOS_GLOBAL_ATTRIBUTES = DatasetTemplate.from_json(IMOS_GLOBAL_JSON).global_attributes
1010

11-
TIMESTAMP_FORMAT = '%Y-%m-%dT%H:%M:%SZ'
11+
TIMESTAMP_FORMAT = "%Y-%m-%dT%H:%M:%SZ"
1212

1313

1414
class ImosTemplate(DatasetTemplate):
@@ -19,7 +19,9 @@ def __init__(self, global_attributes=None, *args, **kwargs):
1919
combined_attributes = IMOS_GLOBAL_ATTRIBUTES.copy()
2020
if global_attributes is not None:
2121
combined_attributes.update(global_attributes)
22-
super(ImosTemplate, self).__init__(global_attributes=combined_attributes, *args, **kwargs)
22+
super(ImosTemplate, self).__init__(
23+
global_attributes=combined_attributes, *args, **kwargs
24+
)
2325
self._date_created = None
2426

2527
@property
@@ -30,9 +32,13 @@ def date_created(self):
3032
return self._date_created
3133

3234
def add_date_created_attribute(self):
33-
self.global_attributes['date_created'] = self.date_created.strftime(TIMESTAMP_FORMAT)
35+
self.global_attributes["date_created"] = self.date_created.strftime(
36+
TIMESTAMP_FORMAT
37+
)
3438

35-
def add_extent_attributes(self, time_var='TIME', vert_var='DEPTH', lat_var='LATITUDE', lon_var='LONGITUDE'):
39+
def add_extent_attributes(
40+
self, time_var="TIME", vert_var="DEPTH", lat_var="LATITUDE", lon_var="LONGITUDE"
41+
):
3642
"""
3743
Calculate spatial and temporal extents from coordinate variables in the template and add/update
3844
the relevant global attributes. Set an input variable name to None to skip that coordinate.
@@ -46,28 +52,33 @@ def add_extent_attributes(self, time_var='TIME', vert_var='DEPTH', lat_var='LATI
4652
if time_var:
4753
data_range = self.get_data_range(time_var)
4854
time = self.variables[time_var]
49-
units = time.get('units')
55+
units = time.get("units")
5056
if not units:
51-
raise ValueError("Time variable '{time_var}' has no units".format(time_var=time_var))
52-
calendar = time.get('calendar', 'gregorian')
57+
raise ValueError(
58+
"Time variable '{time_var}' has no units".format(time_var=time_var)
59+
)
60+
calendar = time.get("calendar", "gregorian")
5361
time_range = num2date(data_range, units, calendar)
54-
self.global_attributes['time_coverage_start'] = time_range[0].strftime(TIMESTAMP_FORMAT)
55-
self.global_attributes['time_coverage_end'] = time_range[1].strftime(TIMESTAMP_FORMAT)
62+
self.global_attributes["time_coverage_start"] = time_range[0].strftime(
63+
TIMESTAMP_FORMAT
64+
)
65+
self.global_attributes["time_coverage_end"] = time_range[1].strftime(
66+
TIMESTAMP_FORMAT
67+
)
5668

5769
if vert_var:
5870
vmin, vmax = self.get_data_range(vert_var)
59-
self.global_attributes['geospatial_vertical_min'] = vmin
60-
self.global_attributes['geospatial_vertical_max'] = vmax
71+
self.global_attributes["geospatial_vertical_min"] = vmin
72+
self.global_attributes["geospatial_vertical_max"] = vmax
6173

6274
if lat_var:
6375
vmin, vmax = self.get_data_range(lat_var)
64-
self.global_attributes['geospatial_lat_min'] = vmin
65-
self.global_attributes['geospatial_lat_max'] = vmax
76+
self.global_attributes["geospatial_lat_min"] = vmin
77+
self.global_attributes["geospatial_lat_max"] = vmax
6678

6779
if lon_var:
6880
vmin, vmax = self.get_data_range(lon_var)
69-
self.global_attributes['geospatial_lon_min'] = vmin
70-
self.global_attributes['geospatial_lon_max'] = vmax
81+
self.global_attributes["geospatial_lon_min"] = vmin
82+
self.global_attributes["geospatial_lon_max"] = vmax
7183

7284
# TODO: def set_imos_filename(self):
73-

aodntools/ncwriter/schema.py

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@
1212
# Create a new validator class (based on Draft4Validator) to allow templates to use
1313
# * Python types or numpy dtypes to specify variable data types; and
1414
# * numpy arrays to specify variable data.
15-
TemplateValidator = validators.create(meta_schema=Draft4Validator.META_SCHEMA,
16-
validators=Draft4Validator.VALIDATORS)
15+
TemplateValidator = validators.create(
16+
meta_schema=Draft4Validator.META_SCHEMA, validators=Draft4Validator.VALIDATORS
17+
)
1718
format_checker = FormatChecker()
1819

1920

20-
@format_checker.checks('datatype')
21+
@format_checker.checks("datatype")
2122
def is_python_datatype(value):
2223
"""Return whether the given value is a valid data type specification for a NetCDF variable"""
2324
if isinstance(value, np.dtype):
@@ -28,31 +29,37 @@ def is_python_datatype(value):
2829
return False
2930

3031

31-
TYPES = {'array': (list, np.ndarray)}
32+
TYPES = {"array": (list, np.ndarray)}
3233

33-
TEMPLATE_SCHEMA_JSON = resource_filename(__name__, 'template_schema.json')
34+
TEMPLATE_SCHEMA_JSON = resource_filename(__name__, "template_schema.json")
3435
with open(TEMPLATE_SCHEMA_JSON) as f:
3536
TEMPLATE_SCHEMA = json.load(f)
3637
TemplateValidator.check_schema(TEMPLATE_SCHEMA)
3738

38-
template_validator = TemplateValidator(TEMPLATE_SCHEMA, types=TYPES, format_checker=format_checker)
39+
template_validator = TemplateValidator(
40+
TEMPLATE_SCHEMA, types=TYPES, format_checker=format_checker
41+
)
3942

4043

4144
def validate_template(t):
4245
template_validator.validate(t)
4346

4447

4548
def validate_dimensions(d):
46-
validate_template({'_dimensions': d})
49+
validate_template({"_dimensions": d})
4750

4851

4952
def validate_variables(v):
50-
validate_template({'_variables': v})
53+
validate_template({"_variables": v})
5154

5255

5356
def validate_global_attributes(a):
54-
if hasattr(a, 'keys'):
55-
special = [k for k in a.keys() if k.startswith('_')]
57+
if hasattr(a, "keys"):
58+
special = [k for k in a.keys() if k.startswith("_")]
5659
if special:
57-
raise ValidationError('Special attributes {} not allowed in global attributes dict'.format(special))
60+
raise ValidationError(
61+
"Special attributes {} not allowed in global attributes dict".format(
62+
special
63+
)
64+
)
5865
template_validator.validate(a)

0 commit comments

Comments
 (0)