[email protected] writes:

I throw two errors in my answer, see the inline corrections

> Possibility 1
>
> c = np.outer(D, s) # c has shape (i*j, k) as outer flattens its arguments 
> c = sum(c, 1)      # c has shape (i*j) because se summed over 2nd index

  c = np.sum(c, 1)   # c has shape (i*j) because se summed over 2nd index
  
> c.reshape(D.shape) # c has the shape of D, i.e., (i, j)
>
> Possibility 2
>
> # https://docs.scipy.org/doc/numpy/reference/generated/numpy.einsum.html
> stackoverflow.com/questions/26089893/understanding-numpys-einsum

  # http://stackoverflow.com/questions/26089893/understanding-numpys-einsum

> c = np.einsum('ij,k -> ij', D, s)

in particular `c = sum(...)` instead of `c = np.sum(...)` is a nasty
error because `sum` is a builtin and the error message one gets could be
misleading

_______________________________________________
Tutor maillist  -  [email protected]
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to