Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jul 17, 2023
1 parent 88b0198 commit 2ff6b6a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cf_xarray/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ def cf_to_lines(ds: xr.Dataset):
if indexes.shape == (0, 2):
geoms[i] = LineString(xy[j : j + n, :])
else:
geoms[i] = MultiLineString([xy[ii[0]: ii[1], :] for ii in indexes])
geoms[i] = MultiLineString([xy[ii[0] : ii[1], :] for ii in indexes])
j += n

return xr.DataArray(geoms, dims=part_node_count.dims, coords=part_node_count.coords)
10 changes: 7 additions & 3 deletions cf_xarray/tests/test_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def geometry_ds():

@pytest.fixture
def geometry_line_ds():
from shapely.geometry import MultiLineString, LineString
from shapely.geometry import LineString, MultiLineString

# empty/fill workaround to avoid numpy deprecation(warning) due to the array interface of shapely geometries.
geoms = np.empty(3, dtype=object)
Expand All @@ -70,8 +70,12 @@ def geometry_line_ds():
shp_ds = ds.assign(geometry=xr.DataArray(geoms, dims=("index",)))

cf_ds = ds.assign(
x=xr.DataArray([0, 1, 4, 5, 0, 1, 1, 1.0, 2.0, 1.7], dims=("node",), attrs={"axis": "X"}),
y=xr.DataArray([0, 2, 4, 6, 0, 0, 1, 1.0, 2.0, 9.5], dims=("node",), attrs={"axis": "Y"}),
x=xr.DataArray(
[0, 1, 4, 5, 0, 1, 1, 1.0, 2.0, 1.7], dims=("node",), attrs={"axis": "X"}
),
y=xr.DataArray(
[0, 2, 4, 6, 0, 0, 1, 1.0, 2.0, 9.5], dims=("node",), attrs={"axis": "Y"}
),
part_node_count=xr.DataArray([4, 3, 3], dims=("index",)),
node_count=xr.DataArray([2, 2, 3, 3], dims=("counter",)),
crd_x=xr.DataArray([1.0, 3.0, 4.0], dims=("index",), attrs={"nodes": "x"}),
Expand Down

0 comments on commit 2ff6b6a

Please sign in to comment.