Skip to content

Commit 6551942

Browse files
committed
a slight fix ndg reshape to flatten
1 parent 640361b commit 6551942

1 file changed

Lines changed: 3 additions & 7 deletions

File tree

csaps/_reshape.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ def umv_coeffs_to_flatten(arr: np.ndarray):
151151
shape = (arr.shape[2], prod(arr.shape[:2]))
152152
strides = arr.strides[:-3:-1]
153153
arr_view = as_strided(arr, shape=shape, strides=strides)
154-
else:
154+
else: # pragma: no cover
155155
raise ValueError(
156156
f"The array ndim must be 2 or 3, but given array has ndim={arr.ndim}.")
157157

@@ -178,16 +178,12 @@ def ndg_coeffs_to_canonical(arr: np.ndarray, pieces: ty.Tuple[int]) -> np.ndarra
178178
179179
"""
180180

181-
shape = tuple(sz // p for sz, p in zip(arr.shape, pieces)) + pieces
182-
183-
if shape == arr.shape:
181+
if arr.ndim > len(pieces):
184182
return arr
185183

184+
shape = tuple(sz // p for sz, p in zip(arr.shape, pieces)) + pieces
186185
strides = tuple(st * p for st, p in zip(arr.strides, pieces)) + arr.strides
187186

188-
if len(shape) != len(strides):
189-
return arr
190-
191187
return as_strided(arr, shape=shape, strides=strides)
192188

193189

0 commit comments

Comments
 (0)