Re: [Numpy-discussion] Need **working** code example of 2-D arrays
Stéfan van der Walt wrote: Linda, 2008/10/13 Linda Seltzer [EMAIL PROTECTED]: Those statements are not demeaning; lighten up. STOP IT. JUST STOP IT. STOP IT RIGHT NOW. Is there a moderator on the list to put a stop to these kinds of statements? I deserve to be treated with respect. I deserve to have my questions treated with respect. I deserve to receive technical information without personal attacks. I think you'll be hard pressed to find a more friendly, open and relaxed mailing list than this one. We're like having piña coladas while we type. That said, keep in mind that you are asking professionals to donate *their* valuable time to solve *your* problem. They gladly do so, but at the same time they try to be efficient; so if you sometimes receive a curt answer, it certainly wasn't meant to be rude. Many of us also sprinkle our responses with a liberal dose of Tongue In Cheek :) It looks like you received some good answers to your question, but let us know if your problems persist and we'll help you sort it out. Well said. Ryan -- Ryan May Graduate Research Assistant School of Meteorology University of Oklahoma ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Using 2-D arrays in Numeric Python (numpy)
Bill Baxter wrote: import numpy as npy Bill, for what it's worth, I *think* this group has reached a consensus to use: import numpy as np We all have different tastes for how they might want to spell it, but the more consistent we are, the easier it will be for newbies. -Chris -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/ORR(206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception [EMAIL PROTECTED] ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Using 2-D arrays in Numeric Python (numpy)
Linda Seltzer wrote: I would appreciate it if someone could answer my question without referring to subjects such as APIs and interfaces, since I am only concerned with a mathematical application at this time. caution: this is a bit rude -- that was an excellent and informative answer to your not-very-clear question. No matter how you slice it, you're going to need to learn a bit about computer programming in general, and python in particular, in order to be productive with numpy. I wish that tutorials provided real world examples. They certainly do -- just not the one you happen to be looking for. It's not good form to criticize folks work that they have generously donated. I would appreciate it if someone could give me the actual statements needed to define and initialize a 2-D array of size NxN, where N can be any large number, There are a few ways to initialize numpy arrays: import numpy as np a = np.zeros((M,N)) a = np.ones ((M,N)) a = np.empty((M,N), dtype=np.float) In Matlab, this is done as a = zeros(256,256). If you are familiar with Matlab, you'll want to take a look at the Wiki pages that describe the similarities and differences between numpy and Matlab: http://www.scipy.org/NumPy_for_Matlab_Users numpy is more complex, but also more powerful than Matlab -- it will take a bit of learning, but it's worth it. Also, read some of the intros to python itself -- you'll need to understand importing and name spaces. a couple quick examples: 1) numpy has many different data types. In the examples above, you will get double precision floats by default (like Matlab), but you can also get other data types (with your image examples, you'll want that). For example, one way to store an RBG image: a = np.zeros((w,h,3), dtype=np.uint8) that is, a width x height x 3 array of 8bit unsigned integers. 2) arrays and matrices are different. 3) numpy provides n-d matrices, not just 2-d 4) importing and name spaces. If I try this in python, it won't let the program overwrite the zeros. if something doesn't work as expected, always post your code, exactly as you tested it, so we can tell you what's wrong. Also, post specific questions -- you first question was something like can I work with arrays, which is quite different than this one: how do I create an array of nXn size full of zeros? -Chris -- Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/ORR(206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception [EMAIL PROTECTED] ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Need **working** code example of 2-D arrays
Linda, 2008/10/13 Linda Seltzer [EMAIL PROTECTED]: Those statements are not demeaning; lighten up. STOP IT. JUST STOP IT. STOP IT RIGHT NOW. Is there a moderator on the list to put a stop to these kinds of statements? I deserve to be treated with respect. I deserve to have my questions treated with respect. I deserve to receive technical information without personal attacks. I think you'll be hard pressed to find a more friendly, open and relaxed mailing list than this one. We're like having piña coladas while we type. That said, keep in mind that you are asking professionals to donate *their* valuable time to solve *your* problem. They gladly do so, but at the same time they try to be efficient; so if you sometimes receive a curt answer, it certainly wasn't meant to be rude. Many of us also sprinkle our responses with a liberal dose of Tongue In Cheek :) It looks like you received some good answers to your question, but let us know if your problems persist and we'll help you sort it out. Regards Stéfan ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
[Numpy-discussion] Priority rules between numpy scalars and 0d arrays
All, Sorry to bring back this subject, but I still haven't got any proper answers: * What are the priority rules between numpy scalars and 0d arrays ? When multiplying a numpy scalar by a 0d array, shouldn't the __mul__ or __rmul__ methods of the array be called ? Should the result be a numpy scalar, or a 0d array (possibly recasted to the higher dtype) ? The problem occurs with numpy.ma.masked, defined as a 0d, np.float64 MaskedArray, which has the __mul__ and __rmul__ of a MaskedArray. np.float(1)*ma.masked gives ma.masked, as it should np.float(64)* ma.masked gives 0, when ma.masked should have been obtained: that leads me to think that ma.masked.__rmul__ isn't called. Why ? Are 0d arrays that special beasts ? ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Priority rules between numpy scalars and 0d arrays
Pierre GM wrote: All, Sorry to bring back this subject, but I still haven't got any proper answers: * What are the priority rules between numpy scalars and 0d arrays ? There aren't really any specified. However, there is behavior that emerges from what is specified. The problem is that there has never been a formal resolution (that I recall) of when should something be returned as a 0-d array and when it should be returned as a scalar. There is rather an informal implementation of what actually happens. Their are some rules of thumb that have emerged (like array-operations --- e.g. reshaping --- should return 0-d arrays and not scalars). The other issue is that there is the rule that when scalars and arrays mix, the data-type of the array determines the result, but there aren't fixed rules about what the sub-type should be. The problem occurs with numpy.ma.masked, defined as a 0d, np.float64 MaskedArray, which has the __mul__ and __rmul__ of a MaskedArray. np.float(1)*ma.masked gives ma.masked, as it should np.float(64)* ma.masked gives 0, when ma.masked should have been obtained: that leads me to think that ma.masked.__rmul__ isn't called. Why ? Are 0d arrays that special beasts ? Could you post code to describe what you mean? np.float(64) should be the same type as np.float(1) so I don't get what you are saying exactly. I think the issue is that numpy scalars are currently wrapped into 0-d arrays for all math and so the 'priority' issue might really an issue between numpy arrays and masked arrays. -Travis ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Need **working** code example of 2-D arrays
Where is the moderator? Please get these condescending, demeaning personal comments off of this list. I asked technical question. Now please send technical information only. Stéfan van der Walt wrote: I think you'll be hard pressed to find a more friendly, open and relaxed mailing list than this one. We're like having piña coladas while we type. That said, keep in mind that you are asking professionals to donate *their* valuable time to solve *your* problem. They gladly do so, but at the same time they try to be efficient; so if you sometimes receive a curt answer, it certainly wasn't meant to be rude. Many of us also sprinkle our responses with a liberal dose of Tongue In Cheek :) It looks like you received some good answers to your question, but let us know if your problems persist and we'll help you sort it out. Well said. Ryan -- Ryan May Graduate Research Assistant School of Meteorology University of Oklahoma ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Using 2-D arrays in Numeric Python (numpy)
Christopher Barker wrote: No matter how you slice it, you're going to need to learn a bit about computer programming in general, and python in particular, in order to be productive with numpy. WHERE IS THE MODERATOR? I deserve not to be insulted in front of the professional community with personal slurs such as this. My computer programming background includes thorough training in C at Bell Labs in the early days, and experience developing more than 65,000 lines of code. My software in C was used in the ATT telephone network, the Sprint network operations system, and the Silicon Graphics workstation. My assembly language DSP software is running in the Coast Guard communications system that coordinated the ship locations during Katrina. I got a large memory physical chemistry simulation to run at Princeton University, which enabled a chemistry lab to obtain results a year ahead of other universities. I have a long record of doing accurate, high quality work on algorithms and software and I would appreciate it if persons on this list would provide technical information only and stop making snide, superior personal comments and slours about a person's knowledge, background or ability. Also, I do not appreciate personal comments alleging that I am being overly sensitive. Where is the moderator during all of this? I asked professional, technical questions and I expect professional, technical answers. ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Priority rules between numpy scalars and 0d arrays
Travis, The problem is that there has never been a formal resolution (that I recall) of when should something be returned as a 0-d array and when it should be returned as a scalar. There is rather an informal implementation of what actually happens. Ah. It might be worth putting the current informal rules or rule-of-thumb black-on-white (or green-on-black) somewhere The other issue is that there is the rule that when scalars and arrays mix, the data-type of the array determines the result, but there aren't fixed rules about what the sub-type should be. I would expect something like return a scalar unless specified otherwise by a subclass. Could you post code to describe what you mean? In MaskedArray, we check whether the output of an operation is 0d: if it is and that the result is masked, then ma.masked is output. if the result is 0d without a mask, a numpy scalar is output. ma.masked is defined as MaskedArray(0,mask=True,dtype=np.float) First, let's check the left multiplication ma.masked * 1 masked_array(data = --, mask = True, fill_value=1e+20) ma.masked * np.float64(1) masked_array(data = --, mask = True, fill_value=1e+20) ma.masked * np.float128(1) masked_array(data = --, mask = True, fill_value=1e+20) Everythng works as planned. Now, for the right multiplication: 1.*ma.masked masked_array(data = --, mask = True, fill_value=1e+20) np.float64(1)*ma.masked 0.0 np.float128(1)*ma.masked 0.0 And that's where the problem is. It looks like ma.masked.__rmul__ or ma.masked.__mul__ are *NOT* called in the last two cases, when I expected it would. But if we have a 1d array: np.array(1., dtype=np.float128)*ma.masked masked_array(data = --, mask = True, fill_value=1e+20) I think the issue is that numpy scalars are currently wrapped into 0-d arrays for all math and so the 'priority' issue might really an issue between numpy arrays and masked arrays. I don't think it's a problem of __array__priority__. MaskedArrays have currently a __array_priority__ of 15, switching to 1e99 or even np.inf doesn't change anything. It looks like the dtype is checked first, which dictates which method is being called (ndarray.__mul__ instead of MaskedArray.__rmul__). What surprises me also is that numpy scalar are supposed to have a very low priority (negative). In short, Travis, could you explain me what's happening ? ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Need **working** code example of 2-D arrays
On Oct 13, 2008, at 7:21 AM, Linda Seltzer wrote: Is there a moderator on the list to put a stop to these kinds of statements? No. Andrew [EMAIL PROTECTED] ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Need **working** code example of 2-D arrays
Linda Seltzer wrote: Where is the moderator? Please get these condescending, demeaning personal comments off of this list. I asked technical question. Now please send technical information only. The problem is, you did not just ask for technical information. You also accused people of being condescending and demeaning. But nobody was condescending or demeaning. As several people **politely** explained to you, you are wrong about that. If you stop making such accusations, you will stop receiving such corrections. There is no reason that list members should allow your accusations to go unchallenged. Stick to technical inquiries *only*, and you will get responses more to your taste. Cheers, Alan Isaac ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Using 2-D arrays in Numeric Python (numpy)
On Mon, Oct 13, 2008 at 13:36, Linda Seltzer [EMAIL PROTECTED] wrote: Christopher Barker wrote: No matter how you slice it, you're going to need to learn a bit about computer programming in general, and python in particular, in order to be productive with numpy. WHERE IS THE MODERATOR? There is no moderator. I may be the closest to such a thing, but I have no intention of silencing anyone at this point in time. I deserve not to be insulted in front of the professional community with personal slurs such as this. These are not such. They may be blunt or assume too much, but the proper response is a plain correction, not a call to a moderator to silence someone. You have been initially treated with respect, and we tried to answer your technical questions the best we could, but our patience is rapidly thinning. You took purely technical responses as personal insults where nothing of the kind was intended. And now we are lost in the non-technical weeds of accusation and counter-accusation. Whether you believe it or not, this mailing list is about as good as it gets when it comes to lists for open source software (and you have received a far gentler treatment given your behavior than you would have elsewhere), but the medium of email has its limitations. It is not the subtlest form of communication. Messages may seem blunter than you might think is appropriate. That's just the way email is, so you have to give the other person the benefit of the doubt and assume that they did not intend to offend you. By participating in this list, we have all implicitly agreed to this rule. If you can not or will not do the same, then it seems clear to me that further participation on the list on your part will not serve your interests, much less ours. -- Robert Kern I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth. -- Umberto Eco ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Need **working** code example of 2-D arrays
On Mon, Oct 13, 2008 at 2:29 PM, Alan G Isaac [EMAIL PROTECTED] wrote: The problem is, you did not just ask for technical information. You also accused people of being condescending and demeaning. But nobody was condescending or demeaning. As several people **politely** explained to you, you are wrong about that. Here is a simple example of loading some 2D data into an array and manipulating the contents import numpy as np # load a 2D array of integers X = np.loadtxt('somefile.txt').astype(int) print X.shape # X is a 2D array # display the contents of X as a string print '\n'.join([''.join([chr(c) for c in row]) for row in X]) The input file somefile.txt is attached JDH 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 95 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 47 124 32 32 47 124 32 32 124 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 124 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 124 124 95 95 124 124 32 32 124 32 32 32 32 32 32 32 80 108 101 97 115 101 32 100 111 110 39 116 32 32 32 32 32 32 32 124 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 47 32 32 32 79 32 79 92 95 95 32 32 32 32 32 32 32 32 32 32 32 102 101 101 100 32 32 32 32 32 32 32 32 32 32 32 124 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 47 32 32 32 32 32 32 32 32 32 32 92 32 32 32 32 32 32 32 116 104 101 32 116 114 111 108 108 115 32 32 32 32 32 32 32 32 124 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 47 32 32 32 32 32 32 92 32 32 32 32 32 92 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 124 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 47 32 32 32 95 32 32 32 32 92 32 32 32 32 32 92 32 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 47 32 32 32 32 124 92 95 95 95 95 92 32 32 32 32 32 92 32 32 32 32 32 124 124 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 47 32 32 32 32 32 124 32 124 32 124 32 124 92 95 95 95 95 47 32 32 32 32 32 124 124 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 47 32 32 32 32 32 32 32 92 124 95 124 95 124 47 32 32 32 124 32 32 32 32 95 95 124 124 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 47 32 32 47 32 32 92 32 32 32 32 32 32 32 32 32 32 32 32 124 95 95 95 95 124 32 124 124 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 47 32 32 32 124 32 32 32 124 32 47 124 32 32 32 32 32 32 32 32 124 32 32 32 32 32 32 45 45 124 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 124 32 32 32 124 32 32 32 124 47 47 32 32 32 32 32 32 32 32 32 124 95 95 95 95 32 32 45 45 124 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 42 32 95 32 32 32 32 124 32 32 124 95 124 95 124 95 124 32 32 32 32 32 32 32 32 32 32 124 32 32 32 32 32 92 45 47 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 42 45 45 32 95 45 45 92 32 95 32 92 32 32 32 32 32 47 47 32 32 32 32 32 32 32 32 32 32 32 124 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 47 32 32 95 32 32 32 32 32 92 32 95 32 47 47 32 32 32 124 32 32 32 32 32 32 32 32 47 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 42 32 32 47 32 32 32 92 95 32 47 45 32 124 32 45 32 32 32 32 32 124 32 32 32 32 32 32 32 124 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 42 32 32 32 32 32 32 95 95 95 32 99 95 99 95 99 95 67 47 32 92 67 95 99 95 99 95 99 95 95 95 95 95 95 95 95 95 95 95 95 32 32 32 32 32 32 32 32 32 32 32 32 32 32 ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Need **working** code example of 2-D arrays
Your reply is inappropriate. it is not a correction. A request was made to stop posting mail that did not concern math and you have continued with your put downs. Stop it. Just stop it. Stop it right now. Linda Seltzer wrote: Where is the moderator? Please get these condescending, demeaning personal comments off of this list. I asked technical question. Now please send technical information only. The problem is, you did not just ask for technical information. You also accused people of being condescending and demeaning. But nobody was condescending or demeaning. As several people **politely** explained to you, you are wrong about that. If you stop making such accusations, you will stop receiving such corrections. There is no reason that list members should allow your accusations to go unchallenged. Stick to technical inquiries *only*, and you will get responses more to your taste. Cheers, Alan Isaac ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Need **working** code example of 2-D arrays
Alan, Stop tuyrning this around. Stop referring to my request as an accusation and stop referring to your put-downs as a correction. On Mon, Oct 13, 2008 at 2:29 PM, Alan G Isaac [EMAIL PROTECTED] wrote: The problem is, you did not just ask for technical information. You also accused people of being condescending and demeaning. But nobody was condescending or demeaning. As several people **politely** explained to you, you are wrong about that. ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Need **working** code example of 2-D arrays
Ordinarily I avoid becoming involved in such acrimony, but I take this single opportunity to state clearly that I find Linda Seltzer's behavior utterly rude and childish. Having been a member of this mailing list for over 6 years, I take exception to the pointless ranting and vitriolic comments of people, like Linda, who are using NumPy/SciPy, and demand immediate attention to their special problem, while hurling false accusations, and creating hard feelings among the comm- unity. NumPy and SciPy are software packages of the highest caliber that have been produced, supported, and nurtured by a community of -volunteers- at no cost to the users. In siutations like this, it may be helpful to review proper etiquette and the fun- damental purpose for mailing/support lists of open source tools. Two docum- ents that help reaffirm what this list is all about can be found below. Linda, I highly recommend you read the sections titled Dealing with rudeness and On not acting like a loser of the following document: http://www.catb.org/~esr/faqs/smart-questions.htmlhttp://www.catb.org/%7Eesr/faqs/smart-questions.html http://www.catb.org/~esr/faqs/smart-questions.html#keepcoolhttp://www.catb.org/%7Eesr/faqs/smart-questions.html#keepcool http://www.catb.org/~esr/faqs/smart-questions.html#not_losinghttp://www.catb.org/%7Eesr/faqs/smart-questions.html#not_losing You might also benefit from seeing things from the perspective of developers, who again, volunteer their precious time to developing and supporting open source software, so that you can do your work more efficiently and smartly. Give this a read over a cup of tea: http://math-atlas.sourceforge.net/faq.html#utone Perhaps when you calm down, and allow yourself to reflect upon this experience, you will realize how badly you've behaved to a group of professional, friendly people whose only desire is to support and nuture a great tool. I will say nothing more about this topic, and under no circumstances will I reply to future messages from Linda Seltzer. Daran ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Need **working** code example of 2-D arrays
This ia another example of non-scientific attacking that does not belong on the list. As I mentioned earlier: Please keep all non-mathematical or non-computer science remarks off the list. Ordinarily I avoid becoming involved in such acrimony, but I take this single opportunity to state clearly that I find Linda Seltzer's behavior utterly rude and childish. Having been a member of this mailing list for over 6 years, I take exception to the pointless ranting and vitriolic comments of people, like Linda, who are using NumPy/SciPy, and demand immediate attention to their special problem, while hurling false accusations, and creating hard feelings among the comm- unity. NumPy and SciPy are software packages of the highest caliber that have been produced, supported, and nurtured by a community of -volunteers- at no cost to the users. In siutations like this, it may be helpful to review proper etiquette and the fun- damental purpose for mailing/support lists of open source tools. Two docum- ents that help reaffirm what this list is all about can be found below. Linda, I highly recommend you read the sections titled Dealing with rudeness and On not acting like a loser of the following document: http://www.catb.org/~esr/faqs/smart-questions.htmlhttp://www.catb.org/%7Eesr/faqs/smart-questions.html http://www.catb.org/~esr/faqs/smart-questions.html#keepcoolhttp://www.catb.org/%7Eesr/faqs/smart-questions.html#keepcool http://www.catb.org/~esr/faqs/smart-questions.html#not_losinghttp://www.catb.org/%7Eesr/faqs/smart-questions.html#not_losing You might also benefit from seeing things from the perspective of developers, who again, volunteer their precious time to developing and supporting open source software, so that you can do your work more efficiently and smartly. Give this a read over a cup of tea: http://math-atlas.sourceforge.net/faq.html#utone Perhaps when you calm down, and allow yourself to reflect upon this experience, you will realize how badly you've behaved to a group of professional, friendly people whose only desire is to support and nuture a great tool. I will say nothing more about this topic, and under no circumstances will I reply to future messages from Linda Seltzer. Daran ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Need **working** code example of 2-D arrays
On Oct 13, 2008, at 4:16 PM, Linda Seltzer wrote: Alan, Stop tuyrning this around. Stop referring to my request as an accusation and stop referring to your put-downs as a correction. Linda, from what I can tell, the tone in this discussion thread changed from the professional, technical mode with this statement: Please, no demeaning statements like you forgot a parenthesis or you were using someone else's code - just the lines of code for a file that actually *works.* The folks on this list are a very friendly and helpful bunch, and I think some of them did not take well to your implying that they were demeaning to you. You might not have meant it to be accusatory, but it certainly seems to have been interpreted that way. Further appeals to a non-existent moderator and typing in ALL CAPS only fanned the flames, and so I think perhaps it would be good if folks just stepped back from the keyboard a bit and took some deep breaths. Also, Linda, I would like to stress that although this mailing list is an open, unmoderated forum for technical discussion, even the veterans don't go about making proclamations about what people should and should not post... I think if you stick to asking technical questions, people will respond in kind. -Peter ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
[Numpy-discussion] End of Discussion (was Re: Need **working** code example of 2-D arrays)
Linda has informed me that she has left the mailing list. Please consider this and all related threads closed. -- Robert Kern I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth. -- Umberto Eco ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Need **working** code example of 2-D arrays
I know, I know, last one... http://www.catb.org/~esr/faqs/smart-questions.html I had forgotten this wise quote from the smart questions FAQ: Be gentle. Problem-related stress can make people seem rude or stupid even when they're not. Best, Matthew ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
[Numpy-discussion] how to tell if a point is inside a polygon
Is there a routine in scipy for telling whether a point is inside a convex 4 sided polygon? Mathew ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] how to tell if a point is inside a polygon
2008/10/13 Mathew Yeates [EMAIL PROTECTED] Is there a routine in scipy for telling whether a point is inside a convex 4 sided polygon? Not specifically in scipy, as far as I know, but there are several supplementary packages that provide this functionality, including matplotlib: http://projects.scipy.org/pipermail/scipy-user/2008-February/015418.html http://groups.google.com/group/Numpy-discussion/browse_thread/thread/2fca22bd29546ff2 Angus. -- AJC McMorland Post-doctoral research fellow Neurobiology, University of Pittsburgh ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] how to tell if a point is inside a polygon
2008/10/13 Mathew Yeates [EMAIL PROTECTED] Is there a routine in scipy for telling whether a point is inside a convex 4 sided polygon? Mathew, You could use OGR (www.gdal.org) Example - import osgeo.ogr as ogr vert = [(0,0),(0,1),(1,1),(1,0)] listvert = [ %s %s % (x,y) for (x,y) in vert] listvert.append(listvert[0]) geo = ogr.CreateGeometryFromWkt(POLYGON ((%s)) % ','.join(listvert)) querypoint = (0.5, 0.5) qpt = ogr.CreateGeometryFromWkt(POINT(%s %s) % querypoint) assert geo.Contains(qpt) querypoint = (0.5, 1.5) qpt = ogr.CreateGeometryFromWkt(POINT(%s %s) % querypoint) assert not geo.Contains(qpt) ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] how to tell if a point is inside a polygon
On Tue, Oct 14, 2008 at 8:46 AM, Pierre GM [EMAIL PROTECTED] wrote: 2008/10/13 Mathew Yeates [EMAIL PROTECTED] Is there a routine in scipy for telling whether a point is inside a convex 4 sided polygon? Mathew, You could use OGR (www.gdal.org) Example - import osgeo.ogr as ogr vert = [(0,0),(0,1),(1,1),(1,0)] listvert = [ %s %s % (x,y) for (x,y) in vert] listvert.append(listvert[0]) geo = ogr.CreateGeometryFromWkt(POLYGON ((%s)) % ','.join(listvert)) querypoint = (0.5, 0.5) qpt = ogr.CreateGeometryFromWkt(POINT(%s %s) % querypoint) assert geo.Contains(qpt) querypoint = (0.5, 1.5) qpt = ogr.CreateGeometryFromWkt(POINT(%s %s) % querypoint) assert not geo.Contains(qpt) If all you really need is a point in convex polygon test, it's probably a little too trivial to be worth dragging in a dependency on anything. But if you may find yourself needing more geometric tests then it might be a good idea to get a good geom lib now. As for this test, all you need to do is check that the point is to the left of each of the edges, taken counter-clockwise. Here's some code I wrote a while back that does a more general even-odd test, but should work for your case too: def inside_shape(p, verts, edges=None): Test whether the point p is inside the specified shape. The shape is specified by 'verts' and 'edges' Arguments: p - the 2d point verts - (N,2) array of points edges - (N,2) array of vert indices indicating edges If edges is None then assumed to be in order. I.e. [[0,1], [1,2], [2,3] ... [N-1,0]] Returns: - True/False based on result of in/out test. Uses the 'ray to infinity' even-odd test. Let the ray be the horizontal ray starting at p and going to +inf in x. verts = npy.asarray(verts) if edges is None: N = verts.shape[0] edges = npy.column_stack([npy.c_[0:N],npy.c_[1:N,0]]) inside = False x,y=p[0],p[1] for e in edges: v0,v1 = verts[e[0]],verts[e[1]] # Check if both verts to the left of ray if v0[0]x and v1[0]x: continue # check if both on the same side of ray if (v0[1]y and v1[1]y) or (v0[1]y and v1[1]y): continue #check for horizontal line - another horz line can't intersect it if (v0[1]==v1[1]): continue # compute x intersection value xisect = v0[0] + (v1[0]-v0[0])*((y-v0[1])/(v1[1]-v0[1])) if xisect = x: inside = not inside return inside License: public domain. --bb ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
[Numpy-discussion] SWIG, typemaps, 2D argout arrays
Hi, I'm new to using SWIG and my reading of numpy_swig.pdf tells me that the following typemap does not exist: (int* ARGOUT_ARRAY2, int DIM1, int DIM2) What is the recommended way to output a 2D array? It seems like I should use: (int* ARGOUT_ARRAY1, int DIM1) and then provide a python function which reshapes the 1D array? Is it correct that there will be insignificant performance disadvantages to this? Also, is there any way to do this in an automated fashion? My first thought is that I'd need to create this function outside of the python module that SWIG creates. Thanks! ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] how to tell if a point is inside a polygon
Hi Matthew Here is an implementation in Python, ctypes and in weave: http://mentat.za.net/source/pnpoly.tar.bz2 Regards Stéfan ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion