[Numpy-discussion] C-API: PyTypeObject* for NumPy scalar types

2011-07-28 Thread Johan Råde
How do I get the PyTypeObject* for a NumPy scalar type such as np.uint8? (The reason I'm asking is the following: I'm writing a C++ extension module. The Python interface to the module has a function f that takes a NumPy scalar type as an argument, for instance f(np.uint8). Then the correspondin

Re: [Numpy-discussion] Quaternion dtype for NumPy - initial implementation available

2011-07-28 Thread Martin Ling
On Wed, Jul 27, 2011 at 10:29:08PM -0500, Robert Love wrote: > > To use quaternions I find I often need conversion to/from matrices and > to/from Euler angles. Will you add that functionality? Yes, I intend to. Note that these conversions are already available in the standalone (non-dtype) imple

[Numpy-discussion] Issues with adding new dtypes - customizing ndarray attributes

2011-07-28 Thread Martin Ling
Hi, I'd like to kick off some discussion on general issues I've encountered while developing the quaternion dtype (see other thread, and the code at: https://github.com/martinling/numpy_quaternion) The basic issue is that the attributes of ndarray cannot be adapted to the dtype of a given array.

Re: [Numpy-discussion] Rationale for returning type-wrapped min() / max() scalars? (was: Problem with ufunc of a numpy.ndarray derived class)

2011-07-28 Thread Hans Meine
Hi again! Am Donnerstag, 21. Juli 2011, 16:56:21 schrieb Hans Meine: > import numpy > > class Test(numpy.ndarray): > pass > > a1 = numpy.ndarray((1,)) > a2 = Test((1,)) > > assert type(a1.min()) == type(a2.min()), \ > "%s != %s" % (type(a1.min()), type(a2.min())) > # -

Re: [Numpy-discussion] Rationale for returning type-wrapped min() / max() scalars? (was: Problem with ufunc of a numpy.ndarray derived class)

2011-07-28 Thread Matthew Brett
Hi, On Thu, Jul 28, 2011 at 7:58 AM, Hans Meine wrote: > Hi again! > > Am Donnerstag, 21. Juli 2011, 16:56:21 schrieb Hans Meine: >> import numpy >> >> class Test(numpy.ndarray): >>     pass >> >> a1 = numpy.ndarray((1,)) >> a2 = Test((1,)) >> >> assert type(a1.min()) == type(a2.min()), \ >>   "%

Re: [Numpy-discussion] dtype repr change?

2011-07-28 Thread Ralf Gommers
On Thu, Jul 28, 2011 at 1:29 AM, Gael Varoquaux < gael.varoqu...@normalesup.org> wrote: > On Wed, Jul 27, 2011 at 05:25:20PM -0600, Charles R Harris wrote: > >Well, doc tests are just a losing proposition, no one should be using > them > >for writing tests. It's not like this is a new disc

Re: [Numpy-discussion] dtype repr change?

2011-07-28 Thread Matthew Brett
Hi, On Thu, Jul 28, 2011 at 10:13 AM, Ralf Gommers wrote: > > > On Thu, Jul 28, 2011 at 1:29 AM, Gael Varoquaux > wrote: >> >> On Wed, Jul 27, 2011 at 05:25:20PM -0600, Charles R Harris wrote: >> >    Well, doc tests are just a losing proposition, no one should be using >> > them >> >    for wri

Re: [Numpy-discussion] dtype repr change?

2011-07-28 Thread Nathaniel Smith
I have a different question about this than the rest of the thread. I'm confused at why there isn't a programmatic way to create a datetime dtype, other than by going through this special string-based mini-language. I guess I generally think of string-based dtype descriptors as being a legacy thing

Re: [Numpy-discussion] dtype repr change?

2011-07-28 Thread Stéfan van der Walt
On Thu, Jul 28, 2011 at 10:19 AM, Matthew Brett wrote: > I don't think anyone suggested that doctests should replace unit > tests; it's a bit difficult to see why that discussion started. The conversation started because array([True], dtype=bool) changed to array([True], dtype='bool') or somethin

Re: [Numpy-discussion] dtype repr change?

2011-07-28 Thread Matthew Brett
Hi, 2011/7/28 Stéfan van der Walt : > On Thu, Jul 28, 2011 at 10:19 AM, Matthew Brett > wrote: >> I don't think anyone suggested that doctests should replace unit >> tests; it's a bit difficult to see why that discussion started. > > The conversation started because array([True], dtype=bool) cha

[Numpy-discussion] ticket 1793

2011-07-28 Thread Paul Anton Letnes
Hi! In my quest for a bug-free numpy I have, I think, fixed ticket 1793. https://github.com/numpy/numpy/pull/123 Enjoy - feedback welcome, of course. Cheers, Paul. ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailma

[Numpy-discussion] Can I index array starting with 1?

2011-07-28 Thread Jeremy Conlin
I have a need to index my array(s) starting with a 1 instead of a 0. The reason for this is to be consistent with the documentation of a format I'm accessing. I know I can just '-1' from what the documentation says, but that can get cumbersome. Is there a magic flag I can pass to a numpy array (ma

Re: [Numpy-discussion] dtype repr change?

2011-07-28 Thread Stéfan van der Walt
On Thu, Jul 28, 2011 at 1:48 PM, Matthew Brett wrote: > The thread was first about how to deal with the change, and second I'm still curious to know of a technical solution with doctests. Ideally, one would like to specify a set of rules that a line must pass to know whether it matched. The curr

Re: [Numpy-discussion] ticket 1793

2011-07-28 Thread Stéfan van der Walt
On Thu, Jul 28, 2011 at 2:05 PM, Paul Anton Letnes wrote: > In my quest for a bug-free numpy I have, I think, fixed ticket 1793. > https://github.com/numpy/numpy/pull/123 This brings up an interesting question. When raising warnings, they only show for the first time, unless the system is specia

Re: [Numpy-discussion] Can I index array starting with 1?

2011-07-28 Thread Stéfan van der Walt
Hi Jeremy On Thu, Jul 28, 2011 at 3:19 PM, Jeremy Conlin wrote: > I have a need to index my array(s) starting with a 1 instead of a 0. > The reason for this is to be consistent with the documentation of a > format I'm accessing. I know I can just '-1' from what the > documentation says, but that

Re: [Numpy-discussion] Can I index array starting with 1?

2011-07-28 Thread Anne Archibald
Don't forget the everything-looks-like-a-nail approach: make all your arrays one bigger than you need and ignore element zero. Anne On 7/28/11, Stéfan van der Walt wrote: > Hi Jeremy > > On Thu, Jul 28, 2011 at 3:19 PM, Jeremy Conlin wrote: >> I have a need to index my array(s) starting with a

Re: [Numpy-discussion] Can I index array starting with 1?

2011-07-28 Thread Stéfan van der Walt
On Thu, Jul 28, 2011 at 4:10 PM, Anne Archibald wrote: > Don't forget the everything-looks-like-a-nail approach: make all your > arrays one bigger than you need and ignore element zero. Hehe, why didn't I think of that :) I guess the kind of problem I struggle with more frequently is books writt

Re: [Numpy-discussion] dtype repr change?

2011-07-28 Thread Matthew Brett
Hi, 2011/7/28 Stéfan van der Walt : > On Thu, Jul 28, 2011 at 1:48 PM, Matthew Brett > wrote: >> The thread was first about how to deal with the change, and second > > I'm still curious to know of a technical solution with doctests. > Ideally, one would like to specify a set of rules that a line

Re: [Numpy-discussion] Can I index array starting with 1?

2011-07-28 Thread Derek Homeier
On 29.07.2011, at 1:19AM, Stéfan van der Walt wrote: > On Thu, Jul 28, 2011 at 4:10 PM, Anne Archibald > wrote: >> Don't forget the everything-looks-like-a-nail approach: make all your >> arrays one bigger than you need and ignore element zero. > > Hehe, why didn't I think of that :) > > I gues

Re: [Numpy-discussion] Can I index array starting with 1?

2011-07-28 Thread Stéfan van der Walt
On Thu, Jul 28, 2011 at 4:26 PM, Derek Homeier wrote: >> I guess the kind of problem I struggle with more frequently is books >> written with summations over -m to +n.  In those cases, it's often >> convenient to use the mapping function, so that I can enter the >> formulas as they occur. > > I do

Re: [Numpy-discussion] Can I index array starting with 1?

2011-07-28 Thread Anne Archibald
The can is open and the worms are everywhere, so: The big problem with one-based indexing for numpy is interpretation. In python indexing, -1 is the last element of the array, and ranges have a specific meaning. In a hypothetical one-based indexing scheme, would the last element be element 0? if n

Re: [Numpy-discussion] Can I index array starting with 1?

2011-07-28 Thread Derek Homeier
On 29.07.2011, at 1:38AM, Anne Archibald wrote: > The can is open and the worms are everywhere, so: > > The big problem with one-based indexing for numpy is interpretation. > In python indexing, -1 is the last element of the array, and ranges > have a specific meaning. In a hypothetical one-based

Re: [Numpy-discussion] Quaternion dtype for NumPy - initial implementation available

2011-07-28 Thread Robert Love
On Jul 28, 2011, at 7:42 AM, Martin Ling wrote: > On Wed, Jul 27, 2011 at 10:29:08PM -0500, Robert Love wrote: >> >> To use quaternions I find I often need conversion to/from matrices and >> to/from Euler angles. Will you add that functionality? > > Yes, I intend to. Note that these conversion

Re: [Numpy-discussion] Quaternion dtype for NumPy - initial implementation available

2011-07-28 Thread Robert Kern
On Thu, Jul 28, 2011 at 21:48, Robert Love wrote: > > On Jul 28, 2011, at 7:42 AM, Martin Ling wrote: > >> On Wed, Jul 27, 2011 at 10:29:08PM -0500, Robert Love wrote: >>> >>> To use quaternions I find I often need conversion to/from matrices and >>> to/from Euler angles.  Will you add that functi

Re: [Numpy-discussion] ticket 1793

2011-07-28 Thread Robert Kern
2011/7/28 Stéfan van der Walt : > On Thu, Jul 28, 2011 at 2:05 PM, Paul Anton Letnes > wrote: >> In my quest for a bug-free numpy I have, I think, fixed ticket 1793. >> https://github.com/numpy/numpy/pull/123 > > This brings up an interesting question.  When raising warnings, they > only show for

Re: [Numpy-discussion] Quaternion dtype for NumPy - initial implementation available

2011-07-28 Thread Charles R Harris
On Thu, Jul 28, 2011 at 8:48 PM, Robert Love wrote: > > On Jul 28, 2011, at 7:42 AM, Martin Ling wrote: > > > On Wed, Jul 27, 2011 at 10:29:08PM -0500, Robert Love wrote: > >> > >> To use quaternions I find I often need conversion to/from matrices and > >> to/from Euler angles. Will you add that

Re: [Numpy-discussion] Quaternion dtype for NumPy - initial implementation available

2011-07-28 Thread Charles R Harris
On Thu, Jul 28, 2011 at 8:48 PM, Robert Love wrote: > > On Jul 28, 2011, at 7:42 AM, Martin Ling wrote: > > > On Wed, Jul 27, 2011 at 10:29:08PM -0500, Robert Love wrote: > >> > >> To use quaternions I find I often need conversion to/from matrices and > >> to/from Euler angles. Will you add that