Simplify norm_functions_semiramis.py
In particular, the following method is quite complex:
def mask_from_const(mat, dobj_list, n_platf, n_supports):
mat_const_orig = mat[:, : -n_platf * n_supports]
mat_const = mat_const_orig.reshape(-1, int(mat_const_orig.shape[1] / n_platf))
mat_to_zero = np.zeros(mat_const.shape)
# id_const = np.argmax(mat_const, axis=1).reshape(-1, n_platf)
id_const = mat_const.reshape(len(mat_const_orig), int(mat_const_orig.shape[1] / n_platf), n_platf)
mat_to_zero[np.arange(len(mat_to_zero)), np.argmax(mat_const, axis=1)] = 1
mat_to_zero = mat_to_zero.reshape(-1, mat_const_orig.shape[1])
mat_aux = []
for plat in range(n_platf):
# mat_aux.append(np.asarray(dobj_list[plat].id_to_cat(id_const[:, plat])).reshape(-1, 1))
mat_aux.append(np.asarray(dobj_list[plat].inverse_transform(id_const[:, :, plat])).reshape(-1, 1))
mat_aux = np.hstack(mat_aux).reshape(-1, 1)
mask_bin = num_to_binarray(mat_aux, n_supports).reshape(-1, n_platf * n_supports)
return mask_bin, mat_to_zero
Since this is an example, it would be nice to add some comments, and possibly simplify the computations.