FiPy is built on NumPy, but we specialize the use of its data structures in a way that there are times you need our numerix versions of the routines to know the right thing to do with an array. To the greatest extent possible, we use the numpy routines, but the way for you as a user to not need to worry about it is to all ways call numerix and let us worry about when we need to override.
On Feb 7, 2014, at 3:48 PM, yuan wang <[email protected]> wrote: > Hi Jon, > > Thanks. It works! > > I wonder why numpy should not be directly used? Is it related to model > structure? > > Thanks, > Rose > > > On Mon, Feb 3, 2014 at 11:31 AM, Guyer, Jonathan E. Dr. > <[email protected]> wrote: > This is fine[*], but I would write either > > a.setValue(0., where=a < 0) > > or > > a[(a < 0).value] = 0. > > > [*] You should never use numpy (np) directly with FiPy objects. It will often > work, but not always. Instead, do > > from fipy import numerix as nx > nx.maximum(...) > > and so on. > > > On Feb 2, 2014, at 7:05 PM, yuan wang <[email protected]> wrote: > > > Sorry for the spam. I just found a quick way to do that: > > > > np.maximum(a,zeros(n)) > > > > where a is a CellVariable and n is the number of cells. > > > > This is an element wise comparison of the two arrays. The bigger value of > > each comparison will be returned. The result is also a CellVariable. I'm > > emailing in case others have the same problem. > > > > > > > > > > On Sun, Feb 2, 2014 at 11:42 AM, yuan wang <[email protected]> wrote: > > Dear Fipyers, > > > > May I know how to quickly assign zero to negative values in a cellvariable? > > It could be achieved in the following loop format, but I think there might > > be an easier method to do it, which I'm not aware of. > > > > for j in range(n): > > if a.value(j)>0: > > a.value(j) =0 > > > > Thank you. > > > > Best regards, > > Rose > > > > -- > > Yuan (Rose) Wang > > PhD Candidate, Tufts University > > Cellphone: 617-699-8006 > > > > > > > > -- > > Yuan (Rose) Wang > > PhD Candidate, Tufts University > > Cellphone: 617-699-8006 > > _______________________________________________ > > 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 ] > > > > -- > Yuan (Rose) Wang > PhD Candidate, Tufts University > Cellphone: 617-699-8006 > _______________________________________________ > 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 ]
