Skip to content

Commit c785e85

Browse files
authored
Update code for removing of dimensions to a np.squeeze()
1 parent 9e88926 commit c785e85

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

xarray_selafin/xarray_backend.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -244,16 +244,8 @@ def _raw_indexing_method(self, key):
244244
values = temp[plan_indices][:, node_indices]
245245
data[it] = np.reshape(values, (len(plan_indices), len(node_indices)))
246246

247-
# Remove dimension if key was an integer
248-
if isinstance(node_key, int):
249-
if plan_key is None:
250-
data = data[:, 0]
251-
else:
252-
data = data[:, :, 0]
253-
if isinstance(plan_key, int):
254-
data = data[:, 0, :]
255-
if isinstance(time_key, int):
256-
data = data[0, ...]
247+
# Remove dimension if the size was reduced to 1 due to indexing of integer
248+
data = data.squeeze()
257249
return data
258250

259251

0 commit comments

Comments
 (0)