outBlockList = []
// endmember solutions
if self.applyScaling:
for endmember in results[0]:
endmember = endmember.reshape(-1, inBlock.shape[-1])
endmember.clip(min=0, out=endmember)
endmember *= (1.0 / endmember.max())
After Change
// calculate R2
RSS = resid // without modification, resid is in fact RSS
TSS = np.sum((y - y.mean())**2, axis=0) // total sum of squares
R2 = 1 - RSS / TSS
resid = R2.reshape(1, -1, inBlock.shape[-1])
else:
resid = resid.reshape(1, -1, inBlock.shape[-1]) // extra dimension to match shape of endmembers
outBlocks = np.row_stack((endmembers, resid)) // resid can be either RSS or R2
// output pixel arrays of endmembers & residuals
pixelBlocks["output_pixels"] = outBlocks.astype(props["pixelType"])