Skip to content

Commit ce14343

Browse files
Don't use pad
1 parent d38c71b commit ce14343

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

pymc_extras/statespace/models/utilities.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -512,11 +512,15 @@ def ndim_pad_and_reorder(
512512

513513
if n_missing > 0:
514514
pad_size = [(0, 0) if i not in labeled_axis else (0, n_missing) for i in range(x.ndim)]
515-
new_shape = [
516-
shape + sum(size) if shape is not None else None
517-
for shape, size in zip(x.type.shape, pad_size)
518-
]
519-
x = pt.specify_shape(pt.pad(x, pad_size, mode="constant", constant_values=0), new_shape)
515+
for axis, (_, after) in enumerate(pad_size):
516+
if after > 0:
517+
shape = list(x.type.shape)
518+
shape[axis] = after
519+
zero_shape = [
520+
static_shape if static_shape is not None else x.shape[i]
521+
for i, static_shape in enumerate(shape)
522+
]
523+
x = pt.join(axis, x, pt.zeros(zero_shape))
520524

521525
return reorder_from_labels(x, labels, ordered_labels, labeled_axis)
522526

0 commit comments

Comments
 (0)