# [Numpy-discussion] simple question

Bill Baxter wbaxter at gmail.com
Wed Jul 5 20:03:19 CDT 2006

```That's the kind of thing that should maybe be on the NumpyExample list:
http://www.scipy.org/Numpy_Example_List
But currently little syntactical tricks like that aren't listed there.   I'm
not sure how you'd list that even.

There is an example like that ( a[a<0.5]=0 ) on the Numpy for Matlab Users
page, though.   http://www.scipy.org/NumPy_for_Matlab_Users
It's supposed to be for matlab users, but if you just ignore the Matlab
column, the main table there is still a pretty good list of examples of
numpy syntax and basic functions.

--bb

On 7/6/06, Mathew Yeates <myeates at jpl.nasa.gov> wrote:
>
> ohhhh. I was looking at using "where"
>
>
>
> Keith Goodman wrote:
> > On 7/5/06, Mathew Yeates <myeates at jpl.nasa.gov> wrote:
> >> What is the typical way of doing the following
> >> starting with a 0 matrix, set all values to 1 when a certain condition
> >> is met, set to -1 when another condition is met, left alone if neither
> >> condition is met.
> >
> >
> >>> x = asmatrix(zeros((2,2)))
> >
> >>> x
> >
> > matrix([[0, 0],
> >       [0, 0]])
> >
> >>> y = asmatrix(rand(2,2))
> >
> >>> y
> >
> > matrix([[ 0.85219404,  0.48311427],
> >       [ 0.41026966,  0.2184193 ]])
> >
> >>> x[y > 0.5] = 1
> >
> >>> x[y < 0.5] = -1
> >
> >>> x
> >
> > matrix([[ 1, -1],
> >       [-1, -1]])
> >
>
>
> Using Tomcat but need to do more? Need to support web services, security?
> Get stuff done quickly with pre-integrated technology to make your job
> easier
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/numpy-discussion
>

--
William V. Baxter III
OLM Digital
Kono Dens Building Rm 302
1-8-8 Wakabayashi Setagaya-ku
Tokyo, Japan  154-0023
+81 (3) 3422-3380
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20060706/392a15ed/attachment.html
```