Thanks, makes sense. In my case, as I just have only one dimension, using sourceGrid.value[i] or sourceGrid[...,i] should be equivalent though?
On Tue, Apr 9, 2019 at 3:32 PM Guyer, Jonathan E. Dr. (Fed) via fipy < [email protected]> wrote: > > On Apr 8, 2019, at 6:38 PM, Dario Panada <[email protected]> wrote: > > > DP: I guess what confuses me here is the [..., i] syntax on the > CellVariable object thought. > > FiPy is built on NumPy. `...` or Ellipsis means "all the indices except > for the one specified". FiPy stores cells in the last index of the internal > NumPy array. A CellVariable can potentially be a field of vectors or > tensors, so there could be more leading dimensions. Writing `[..., i]` > ensures you're inserting data where you want. > > > https://docs.scipy.org/doc/numpy/reference/arrays.indexing.html?highlight=ellipsis%20expand > > > > Between this approach and .value, which one would you recommend? > > >>> i = np.ravel_multi_index([coordinate[0], coordinate[1], > coordinate[2]], (20, 20, 20)) > >>> sourceGrid[..., i] = sourceRate > > > _______________________________________________ > fipy mailing list > [email protected] > http://www.ctcms.nist.gov/fipy > [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ] >
_______________________________________________ fipy mailing list [email protected] http://www.ctcms.nist.gov/fipy [ NIST internal ONLY: https://email.nist.gov/mailman/listinfo/fipy ]
