Skip to content

Commit 25a2062

Browse files
committed
linting
1 parent 4019ff6 commit 25a2062

File tree

7 files changed

+41
-29
lines changed

7 files changed

+41
-29
lines changed

obsarray/flag_accessor.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -194,12 +194,12 @@ def __setitem__(self, flag_meaning: str, flag_value: Union[bool, np.ndarray]):
194194
)
195195

196196
if flag_meaning not in flag_meanings:
197-
self._obj[
198-
self._flag_var_name
199-
].attrs = DatasetUtil.add_flag_meaning_to_attrs(
200-
self._obj[self._flag_var_name].attrs,
201-
flag_meaning,
202-
self._obj[self._flag_var_name].dtype,
197+
self._obj[self._flag_var_name].attrs = (
198+
DatasetUtil.add_flag_meaning_to_attrs(
199+
self._obj[self._flag_var_name].attrs,
200+
flag_meaning,
201+
self._obj[self._flag_var_name].dtype,
202+
)
203203
)
204204

205205
self[flag_meaning][:] = flag_value

obsarray/templater/dataset_util.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,8 @@ def create_flags_variable(
259259
attributes=attributes,
260260
)
261261

262-
#initialise flags to zero (instead of fillvalue)
263-
variable.values=0*variable.values
262+
# initialise flags to zero (instead of fillvalue)
263+
variable.values = 0 * variable.values
264264

265265
# add flag attributes
266266
variable.attrs.update(DatasetUtil.pack_flag_attrs(meanings))
@@ -290,7 +290,7 @@ def pack_flag_attrs(
290290
)
291291

292292
if flag_masks is None:
293-
flag_masks = [2 ** i for i in range(0, n_masks)]
293+
flag_masks = [2**i for i in range(0, n_masks)]
294294

295295
flag_attrs["flag_masks"] = str(flag_masks)[1:-1]
296296

@@ -333,7 +333,7 @@ def add_flag_meaning_to_attrs(
333333

334334
# check if variable for available flags
335335
max_n_flags = numpy.iinfo(dtype).bits
336-
all_flag_masks = [2 ** i for i in range(0, max_n_flags)]
336+
all_flag_masks = [2**i for i in range(0, max_n_flags)]
337337
available_flag_masks = list(set(all_flag_masks) - set(flag_masks))
338338

339339
if not available_flag_masks:
@@ -435,7 +435,9 @@ def add_encoding(
435435
if fill_value is not None:
436436
encoding_dict.update({"_FillValue": fill_value})
437437
else:
438-
encoding_dict.update({"_FillValue": DatasetUtil.get_default_fill_value(dtype)})
438+
encoding_dict.update(
439+
{"_FillValue": DatasetUtil.get_default_fill_value(dtype)}
440+
)
439441

440442
variable.encoding = encoding_dict
441443

obsarray/test/test_err_corr_forms.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,18 @@ def test_get_sliced_dim_sizes_uncvar(self):
8585
basicerrcorr = self.BasicErrCorrForm(
8686
self.ds, "u_ran_temperature", ["x"], [], []
8787
)
88-
dim_sizes=basicerrcorr.get_sliced_dim_sizes_uncvar((slice(None),0,slice(0,2,1)))
88+
dim_sizes = basicerrcorr.get_sliced_dim_sizes_uncvar(
89+
(slice(None), 0, slice(0, 2, 1))
90+
)
8991
assert dim_sizes == {"x": 2, "time": 2}
9092

9193
def test_get_sliced_dim_sizes_errcorr(self):
9294
basicerrcorr = self.BasicErrCorrForm(
9395
self.ds, "u_ran_temperature", ["x"], [], []
9496
)
95-
dim_sizes = basicerrcorr.get_sliced_dim_sizes_errcorr((slice(None), 0, slice(0, 2, 1)))
97+
dim_sizes = basicerrcorr.get_sliced_dim_sizes_errcorr(
98+
(slice(None), 0, slice(0, 2, 1))
99+
)
96100
assert dim_sizes == {"x": 2}
97101

98102
def test_get_sliced_dims_errcorr(self):
@@ -112,7 +116,7 @@ def test_get_sliced_shape_errcorr(self):
112116
self.ds, "u_ran_temperature", ["x", "time"], [], []
113117
)
114118
shape = basicerrcorr.get_sliced_shape_errcorr((slice(None), 0, slice(0, 2, 1)))
115-
assert shape == (2,2)
119+
assert shape == (2, 2)
116120

117121
def test_slice_flattened_matrix(self):
118122
basicerrcorr = self.BasicErrCorrForm(
@@ -121,7 +125,7 @@ def test_slice_flattened_matrix(self):
121125

122126
full_matrix = np.arange(144).reshape((12, 12))
123127
slice_matrix = basicerrcorr.slice_flattened_matrix(
124-
full_matrix, (2,2,3), (slice(None), slice(None), 0)
128+
full_matrix, (2, 2, 3), (slice(None), slice(None), 0)
125129
)
126130

127131
exp_slice_matrix = np.array(
@@ -146,6 +150,7 @@ def test_slice_full_cov_slice(self):
146150

147151
np.testing.assert_equal(slice_matrix, exp_slice_matrix)
148152

153+
149154
class TestRandomUnc(unittest.TestCase):
150155
def setUp(self) -> None:
151156
self.ds = create_ds()
@@ -197,8 +202,9 @@ def test_build_dot_matrix(self):
197202
x = self.build_matrix_1stdim()
198203
y = self.build_matrix_2nddim()
199204
time = self.build_matrix_3ddim()
200-
print(x.dot(y),x,y)
205+
print(x.dot(y), x, y)
201206
np.testing.assert_equal((x.dot(y)).dot(time), np.ones((12, 12)))
202207

208+
203209
if __name__ == "main":
204210
unittest.main()

obsarray/test/test_flag_accessor.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,9 @@ def test___iter__(self):
9292
self.assertIsInstance(flag, obsarray.flag_accessor.FlagVariable)
9393
var_names.append(flag._flag_var_name)
9494

95-
self.assertCountEqual(var_names, ["temperature_flags", "general_flags", "time_flags"])
95+
self.assertCountEqual(
96+
var_names, ["temperature_flags", "general_flags", "time_flags"]
97+
)
9698

9799
def test_keys(self):
98100
self.assertCountEqual(

obsarray/test/test_unc_accessor.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -479,15 +479,17 @@ def test_systematic_unc(self, mock):
479479
self.ds.unc["temperature"][:, :, 0].systematic_unc()
480480
mock.assert_called_once_with(["u_sys_temperature"])
481481

482-
def test_total_err_corr_matrix(self, ):
482+
def test_total_err_corr_matrix(
483+
self,
484+
):
483485
tercm = self.ds.unc["temperature"].total_err_corr_matrix()
484-
assert tercm.shape==(12,12)
485-
tercm = self.ds.unc["temperature"][:,:,0].total_err_corr_matrix()
486-
assert tercm.shape==(4,4)
487-
tercm = self.ds.unc["temperature"][:,0,0:2].total_err_corr_matrix()
488-
assert tercm.shape==(4,4)
489-
tercm = self.ds.unc["temperature"][0,0,:].total_err_corr_matrix()
490-
assert tercm.shape==(3,3)
486+
assert tercm.shape == (12, 12)
487+
tercm = self.ds.unc["temperature"][:, :, 0].total_err_corr_matrix()
488+
assert tercm.shape == (4, 4)
489+
tercm = self.ds.unc["temperature"][:, 0, 0:2].total_err_corr_matrix()
490+
assert tercm.shape == (4, 4)
491+
tercm = self.ds.unc["temperature"][0, 0, :].total_err_corr_matrix()
492+
assert tercm.shape == (3, 3)
491493

492494
def test_structured_err_corr_matrix(self):
493495
pass

obsarray/unc_accessor.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -336,8 +336,8 @@ def err_corr_matrix(self) -> xr.DataArray:
336336
# populate with error-correlation matrices built be each error-correlation
337337
# parameterisation object
338338
for dim_err_corr in self.err_corr:
339-
sliced_dims=dim_err_corr[1].get_sliced_dims_errcorr(self._sli)
340-
if len(dim_err_corr[1].get_sliced_dims_errcorr(self._sli))>0:
339+
sliced_dims = dim_err_corr[1].get_sliced_dims_errcorr(self._sli)
340+
if len(dim_err_corr[1].get_sliced_dims_errcorr(self._sli)) > 0:
341341
err_corr_matrix.values = err_corr_matrix.values.dot(
342342
dim_err_corr[1].build_dot_matrix(self._sli)
343343
)
@@ -518,7 +518,7 @@ def _quadsum_unc(self, unc_var_names):
518518
quadsum_unc += self[unc_var_name].abs_value ** 2.0
519519

520520
if quadsum_unc is not None:
521-
quadsum_unc = quadsum_unc ** 0.5
521+
quadsum_unc = quadsum_unc**0.5
522522

523523
return quadsum_unc
524524

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
def read(filename):
1111
filename = os.path.join(os.path.dirname(__file__), filename)
12-
text_type = type(u"")
12+
text_type = type("")
1313
with io.open(filename, mode="r", encoding="utf-8") as fd:
1414
return re.sub(text_type(r":[a-z]+:`~?(.*?)`"), text_type(r"``\1``"), fd.read())
1515

0 commit comments

Comments
 (0)