Skip to content

Commit a6b1f15

Browse files
authored
Merge pull request #64 from data-exp-lab/pre-commit-ci-update-config
[pre-commit.ci] pre-commit autoupdate
2 parents 3349921 + 666b3f8 commit a6b1f15

File tree

11 files changed

+4
-37
lines changed

11 files changed

+4
-37
lines changed

.pre-commit-config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ ci:
66
autoupdate_schedule: weekly
77

88
repos:
9-
- repo: https://github.com/ambv/black
10-
rev: 22.8.0
9+
- repo: https://github.com/psf/black
10+
rev: 23.9.1
1111
hooks:
1212
- id: black
1313
language_version: python3
14-
- repo: https://github.com/timothycrosley/isort
14+
- repo: https://github.com/PyCQA/isort
1515
rev: '5.12.0'
1616
hooks:
1717
- id: isort
1818
- repo: https://github.com/PyCQA/flake8
19-
rev: '6.0.0'
19+
rev: '6.1.0'
2020
hooks:
2121
- id: flake8

yt_xarray/accessor/_readers.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
def _get_xarray_reader(
99
handle, sel_info: _xr_to_yt.Selection, interp_required: Optional[bool] = True
1010
):
11-
1211
# the callable generator for an open xarray handle.
1312
# handle: an open xarray handle
1413
# sel_info: a Selection object for the handle

yt_xarray/accessor/_xr_to_yt.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ def __init__(
3232
sel_dict: Optional[dict] = None,
3333
sel_dict_type: Optional[str] = "isel",
3434
):
35-
3635
self.fields = self._validate_fields(xr_ds, fields)
3736
self.units: dict = self._find_units(xr_ds)
3837
self.full_shape = xr_ds.data_vars[self.fields[0]].shape
@@ -60,7 +59,6 @@ def __init__(
6059
self.yt_coord_names = _convert_to_yt_internal_coords(self.selected_coords)
6160

6261
def _find_units(self, xr_ds) -> dict:
63-
6462
units = {}
6563
for field in self.fields:
6664
unit = getattr(xr_ds[field], "units", "")
@@ -70,7 +68,6 @@ def _find_units(self, xr_ds) -> dict:
7068
return units
7169

7270
def _find_starting_index(self, coordname, coord_da, coord_select) -> int:
73-
7471
si = 0
7572
selector = coord_select[coordname]
7673
if self.sel_dict_type == "isel":
@@ -116,7 +113,6 @@ def _find_starting_index(self, coordname, coord_da, coord_select) -> int:
116113
return si
117114

118115
def _process_selection(self, xr_ds):
119-
120116
# the full list of coordinates (in order)
121117
full_coords = list(xr_ds.data_vars[self.fields[0]].dims)
122118
time = 0.0
@@ -162,7 +158,6 @@ def _process_selection(self, xr_ds):
162158
is_time_dim = _check_for_time(c, coord_vals)
163159

164160
if coord_vals.size > 1:
165-
166161
# not positive-monotonic? reverse it for cell width calculations
167162
# changes to indexing are accounted for when extracting data.
168163
if reverse_axis[-1]:
@@ -220,7 +215,6 @@ def _process_selection(self, xr_ds):
220215
}
221216

222217
def _validate_fields(self, xr_ds, fields: List[str]) -> List[str]:
223-
224218
if fields is None:
225219
raise ValueError("Please provide a list of fields")
226220

@@ -232,7 +226,6 @@ def _validate_fields(self, xr_ds, fields: List[str]) -> List[str]:
232226
msg = "Provided fields must have the same "
233227

234228
for f in fields[1:]:
235-
236229
if xr_ds.data_vars[f].shape != shape:
237230
rmsg = msg + f"shape : {f} does not match {fields[0]}"
238231
raise RuntimeError(rmsg)
@@ -400,7 +393,6 @@ def _add_3rd_axis_name(yt_geometry: str, axis_order: list) -> list:
400393

401394

402395
def _size_of_array_like(v):
403-
404396
if isinstance(v, (np.ndarray, xr.DataArray)):
405397
return v.size
406398

yt_xarray/accessor/accessor.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,6 @@ def get_bbox(
220220
def _load_single_grid(
221221
ds_xr, sel_info, geom, use_callable, fields, length_unit, **kwargs
222222
):
223-
224223
geometry = geom[0]
225224

226225
interp_required, data_shp, bbox = sel_info.interp_validation(geometry)
@@ -285,7 +284,6 @@ def _load_single_grid(
285284
def _load_chunked_grid(
286285
ds_xr, sel_info, geom, use_callable, fields, length_unit, chunksizes, **kwargs
287286
):
288-
289287
if isinstance(chunksizes, int):
290288
chunksizes = np.array((chunksizes,) * sel_info.ndims)
291289
elif len(chunksizes) != sel_info.ndims:
@@ -339,7 +337,6 @@ def _load_chunked_grid(
339337
subgrid_start = []
340338
subgrid_end = []
341339
for idim in range(sel_info.ndims):
342-
343340
si_0 = si[idim] + chunksizes[idim] * np.arange(n_whl_chnk[idim])
344341
ei_0 = si_0 + chunksizes[idim]
345342

yt_xarray/sample_data.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ def load_random_xr_data(
3434

3535
data = {}
3636
for field, field_dims in fields.items():
37-
3837
coords = {}
3938
sz = []
4039
for dim_name in field_dims:

yt_xarray/tests/test_accesor.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ def ds_xr():
3131

3232

3333
def test_accessor():
34-
3534
tfield = "a_new_field"
3635
n_x = 3
3736
n_y = 4
@@ -82,7 +81,6 @@ def test_bbox():
8281

8382
@pytest.mark.parametrize("use_callable", (True, False))
8483
def test_load_grid(ds_xr, use_callable):
85-
8684
flds = ["a_new_field_0", "a_new_field_1"]
8785
ds_yt = ds_xr.yt.load_grid(flds, use_callable=use_callable)
8886
assert ds_yt.coordinates.name == "internal_geographic"

yt_xarray/tests/test_chunking.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111

1212
def test_partial_chunks_uni_cartesian():
13-
1413
# uniform grid, cartesian
1514
fields = {
1615
"field0": ("x", "y", "z"),
@@ -29,7 +28,6 @@ def test_partial_chunks_uni_cartesian():
2928

3029

3130
def test_cartesian():
32-
3331
# builds yt grids with and without chunking (and callables), compares the
3432
# frb ImageArrays for equivalent SlicePlots
3533
ds = construct_minimal_ds(x_name="x", y_name="y", z_name="z", n_fields=2)
@@ -49,7 +47,6 @@ def test_cartesian():
4947

5048

5149
def test_geographic_interp():
52-
5350
# this case will require interpolation
5451
ds = construct_minimal_ds(n_fields=2)
5552
ds_yt_nochunk = ds.yt.load_grid()
@@ -66,7 +63,6 @@ def test_geographic_interp():
6663

6764

6865
def test_geographic_no_interp():
69-
7066
# this case will not require interpolation
7167
ds = construct_minimal_ds(
7268
n_fields=2, min_x=30.0, max_x=35.0, min_y=40.0, max_y=42.0
@@ -106,7 +102,6 @@ def test_chunks_stretched_not_implemented():
106102

107103

108104
def test_dask_array():
109-
110105
# checks that we can handle a field that is a dask array
111106
shp = (10, 12, 5)
112107
f1 = da.random.random(shp, chunks=5)

yt_xarray/tests/test_sample_data.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66

77
def test_load_random_xr_data():
8-
98
fields = {
109
"field0": ("x", "y"),
1110
"field1": ("x", "y", "z"),
@@ -23,7 +22,6 @@ def test_load_random_xr_data():
2322

2423

2524
def test_load_random_xr_data_bad():
26-
2725
fields = {"field0": ("x", "y")}
2826
dims = {"x": (0, 1, 4)}
2927

yt_xarray/tests/test_utilities.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ def test_float32_ds():
4040

4141

4242
def test_file_validation(tmp_path):
43-
4443
tdir = tmp_path / "test_data"
4544
tdir.mkdir()
4645
b = tdir / "test_file.txt"

yt_xarray/tests/test_xr_to_yt.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@ def ds_xr():
3535

3636
@pytest.mark.parametrize("coord", ("latitude", "longitude", "altitude"))
3737
def test_selection_aliases(coord):
38-
3938
for othername in xr2yt._coord_aliases[coord]:
40-
4139
kwargs = {c_m_ds_kwargs[coord]: othername}
4240
ds = construct_minimal_ds(**kwargs)
4341
fields = list(ds.data_vars)
@@ -74,7 +72,6 @@ def _isel_tester(ds_xr, sel, fields, coord, start_index):
7472

7573
@pytest.mark.parametrize("coord", ("latitude", "longitude", "depth"))
7674
def test_selection_isel(ds_xr, coord):
77-
7875
fields = list(ds_xr.data_vars)
7976

8077
sel_dict = {coord: slice(1, len(ds_xr.coords[coord]))}
@@ -129,7 +126,6 @@ def test_selection_units():
129126

130127

131128
def test_selection_errors(ds_xr):
132-
133129
coord = "latitude"
134130
sel_dict = {coord: slice(1, len(ds_xr.coords[coord]))}
135131
sel_dict_type = "isel"
@@ -352,7 +348,6 @@ def test_two_dimensional(use_callable):
352348
"geometry", ["cartesian", "spherical", "geographic", "internal_geographic"]
353349
)
354350
def test_finding_3rd_dim(geometry):
355-
356351
expected = _expected_geoms[geometry]
357352
# select any 2, make sure we add the 3rd back. repeat for every permutation
358353
choices = list(expected)
@@ -432,7 +427,6 @@ def test_time_check(dim_name, dim_vals, expected):
432427
],
433428
)
434429
def test_selection_interp_validation(geometry, stretched, interp_required):
435-
436430
if geometry == "cartesian":
437431
dim_names = ("x", "y", "z")
438432
elif geometry == "geographic":
@@ -467,7 +461,6 @@ def test_selection_interp_validation(geometry, stretched, interp_required):
467461
"yt_geom", ("cartesian", "spherical", "geographic", "internal_geographic")
468462
)
469463
def test_add_3rd_axis_name(yt_geom):
470-
471464
# get full list, remove on and make sure we get it back
472465
expected = list(xr2yt._expected_yt_axes[yt_geom])
473466
actual = xr2yt._add_3rd_axis_name(yt_geom, expected[:-1])

0 commit comments

Comments
 (0)