As long as you want the original values of a
and b
to be stored in the "upper left", you could go with initializing a new array with your wanted fill_value
(say, 99) and place your smaller arrays in it like this:
import numpy as np
a = np.ones(shape=(3,3))
b = np.ones(shape=(5,5))
c = np.ones(shape=(10,10))
a2 = np.full(shape=(10,10), fill_value=99)
a2[:a.shape[0], :a.shape[1]] = a
b2 = np.full(shape=(10,10), fill_value=99)
b2[:b.shape[0], :b.shape[1]] = b
##
>> a2:
[[ 1 1 1 99 99 99 99 99 99 99]
[ 1 1 1 99 99 99 99 99 99 99]
[ 1 1 1 99 99 99 99 99 99 99]
[99 99 99 99 99 99 99 99 99 99]
[99 99 99 99 99 99 99 99 99 99]
[99 99 99 99 99 99 99 99 99 99]
[99 99 99 99 99 99 99 99 99 99]
[99 99 99 99 99 99 99 99 99 99]
[99 99 99 99 99 99 99 99 99 99]
[99 99 99 99 99 99 99 99 99 99]]
Edit:
If you want to do this automatically, without having to know the dimension of the largest square array:
a = np.ones(shape=(3,3))
b = np.ones(shape=(5,5))
c = np.ones(shape=(10,10))
list_of_arrays = [a, b, c]
shapes = [arr.shape for arr in list_of_arrays]
max_shape = max(shapes)
for iarr, arr in enumerate(list_of_arrays):
arr_new = np.full(shape=max_shape, fill_value=99)
arr_new[:arr.shape[0], :arr.shape[1]] = arr
list_of_arrays[iarr] = arr_new
>> print(list_of_arrays[1])
[[ 1 1 1 1 1 99 99 99 99 99]
[ 1 1 1 1 1 99 99 99 99 99]
[ 1 1 1 1 1 99 99 99 99 99]
[ 1 1 1 1 1 99 99 99 99 99]
[ 1 1 1 1 1 99 99 99 99 99]
[99 99 99 99 99 99 99 99 99 99]
[99 99 99 99 99 99 99 99 99 99]
[99 99 99 99 99 99 99 99 99 99]
[99 99 99 99 99 99 99 99 99 99]
[99 99 99 99 99 99 99 99 99 99]]