Ignore size-1 axes when shifting

This commit is contained in:
Jan Petykiewicz 2019-11-22 00:56:03 -08:00
parent 63ad67800a
commit 6f2faca7dc

View File

@ -531,6 +531,8 @@ def e_boundary_source(mask: vfield_t,
shift = lambda axis, polarity: shift_with_mirror(axis=axis, shape=shape, shift_distance=polarity) shift = lambda axis, polarity: shift_with_mirror(axis=axis, shape=shape, shift_distance=polarity)
for axis in (0, 1, 2): for axis in (0, 1, 2):
if shape[axis] == 1:
continue
for polarity in (-1, +1): for polarity in (-1, +1):
r = shift(axis, polarity) - sparse.eye(numpy.prod(shape)) # shifted minus original r = shift(axis, polarity) - sparse.eye(numpy.prod(shape)) # shifted minus original
r3 = sparse.block_diag((r, r, r)) r3 = sparse.block_diag((r, r, r))