-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
def array_reshaper(A, B):
"""Checks to see if arrays are same shape, if not, increase dimensionality of array until shapes match.
Parameters
----------
A : array
B : array
Returns
-------
A : array
Reshaped copy of input array
B : array
Reshaped copy of input array
"""
A = A.copy()
B = B.copy()
for a,b in zip(A.shape, B.shape):
if a == 1 or b == 1:
continue
if a != b:
raise ValueError
a_sh = list(A.shape)
b_sh = list(B.shape)
while len(a_sh) < len(b_sh):
a_sh.append(1)
while len(b_sh) < len(a_sh):
b_sh.append(1)
A = np.reshape(A, a_sh)
B = np.reshape(B, b_sh)
return A, B
Metadata
Metadata
Assignees
Labels
No labels