[Numpy-discussion] PRs for MaskedArray bugs

2012-11-14 Thread Thomas Robitaille
I've recently opened a couple of pull requests that fix bugs with MaskedArray - these are pretty straightforward, so would it be possible to consider them in time for 1.7? https://github.com/numpy/numpy/pull/2703 https://github.com/numpy/numpy/pull/2733 Thanks! Tom

[Numpy-discussion] Numpy on Travis with Python 3

2012-11-27 Thread Thomas Robitaille
Hi everyone, I'm currently having issues with installing Numpy 1.6.2 with Python 3.1 and 3.2 using pip in Travis builds - see for example: https://travis-ci.org/astropy/astropy/jobs/3379866 The build aborts with a cryptic message: ValueError: underlying buffer has been detached Has anyone

[Numpy-discussion] Scalar output from sub-classed Numpy array

2013-05-10 Thread Thomas Robitaille
Hi everyone, I am currently trying to write a sub-class of Numpy ndarray, but am running into issues for functions that return scalar results rather than array results. For example, in the following case: import numpy as np class TestClass(np.ndarray): def __new__(cls,

Re: [Numpy-discussion] __array_priority__ don't work for gt, lt, ... operator

2013-05-12 Thread Thomas Robitaille
I've also been having issues with __array_priority__ - the following code behaves differently for __mul__ and __rmul__: import numpy as np class TestClass(object): def __init__(self, input_array): self.array = input_array def __mul__(self, other): print Called __mul__

[Numpy-discussion] __array_priority__ ignored if __array__ is present

2013-05-16 Thread Thomas Robitaille
Hi everyone, (this was posted as part of another topic, but since it was unrelated, I'm reposting as a separate thread) I've also been having issues with __array_priority__ - the following code behaves differently for __mul__ and __rmul__: import numpy as np class TestClass(object): def

Re: [Numpy-discussion] __array_priority__ ignored if __array__ is present

2013-05-30 Thread Thomas Robitaille
, type_tup, dtypes); Thanks for looking into this - should this be considered a bug? Tom HTH Fred On Thu, May 16, 2013 at 9:19 AM, Thomas Robitaille thomas.robitai...@gmail.com wrote: Hi everyone, (this was posted as part of another topic, but since it was unrelated, I'm reposting

[Numpy-discussion] Equality not working as expected with ndarray sub-class

2013-07-04 Thread Thomas Robitaille
Hi everyone, The following example: import numpy as np class SimpleArray(np.ndarray): __array_priority__ = 1 def __new__(cls, input_array, info=None): return np.asarray(input_array).view(cls) def __eq__(self, other): return False

[Numpy-discussion] Issue with np.median and array subclasses in 1.8.0rc (worked with 1.7.0)

2013-10-01 Thread Thomas Robitaille
Hi, The behavior for ``np.median`` and array sub-classes has changed in 1.8.0rc, which breaks unit-handling code (such as the ``quantities`` package, or ``astropy.units``): https://github.com/numpy/numpy/issues/3846 This previously worked from Numpy 1.5 (at least) to Numpy 1.7. Is there a new

[Numpy-discussion] Issue with dtype and nx1 arrays

2011-08-30 Thread Thomas Robitaille
Hello, Is the following behavior normal? In [1]: import numpy as np In [2]: np.dtype([('a','f4',2)]) Out[2]: dtype([('a', 'f4', (2,))]) In [3]: np.dtype([('a','f4',1)]) Out[3]: dtype([('a', 'f4')]) I.e. in the second case, the second dimension of the dtype (1) is being ignored? Is there a way

[Numpy-discussion] Automatic string length in recarray

2009-11-02 Thread Thomas Robitaille
Hi, I'm having trouble with creating np.string_ fields in recarrays. If I create a recarray using np.rec.fromrecords([(1,'hello'),(2,'world')],names=['a','b']) the result looks fine: rec.array([(1, 'hello'), (2, 'world')], dtype=[('a', 'i8'), ('b', '| S5')]) But if I want to specify the

Re: [Numpy-discussion] Automatic string length in recarray

2009-11-04 Thread Thomas Robitaille
Pierre GM-2 wrote: As a workwaround, perhaps you could use np.object instead of np.str while defining your array. You can then get the maximum string length by looping, as David suggested, and then use .astype to transform your array... I tried this:

Re: [Numpy-discussion] Automatic string length in recarray

2009-11-04 Thread Thomas Robitaille
Pierre GM-2 wrote: Confirmed, it's a bug all right. Would you mind opening a ticket ? I'll try to take care of that in the next few days. Done - http://projects.scipy.org/numpy/ticket/1283 Thanks! Thomas -- View this message in context:

Re: [Numpy-discussion] masked record arrays

2009-11-07 Thread Thomas Robitaille
Pierre GM-2 wrote: Mmh. With a recent (1.3) version of numpy, you should already be able to mask individual fields of a structured array without problems. If you need fields to be accessed as attributes the np.recarray way, you can give numpy.ma.mrecords.MaskedRecords a try. It's

[Numpy-discussion] Problem with set_fill_value for masked structured array

2009-12-13 Thread Thomas Robitaille
Hi, The following code doesn't seem to work: import numpy.ma as ma t = ma.array(zip([1,2,3],[4,5,6]),dtype=[('a',int),('b',int)]) print repr(t['a']) t['a'].set_fill_value(10) print repr(t['a']) As the output is masked_array(data = [1 2 3], mask = [False False False],

Re: [Numpy-discussion] Problem with set_fill_value for masked structured array

2009-12-14 Thread Thomas Robitaille
Pierre GM-2 wrote: Well, that's a problem indeed, and I'd put that as a bug. However, you can use that syntax instead: t.fill_value['a']=10 or set all the fields at once: t.fill_value=(10,99) Thanks for your reply - should I submit a bug report on the numpy trac site? Thomas --

[Numpy-discussion] Structured array sorting

2010-01-17 Thread Thomas Robitaille
I am having trouble sorting a structured array - in the example below, sorting by the first column (col1) seems to work, but not sorting by the second column (col2). Is this a bug? I am using numpy svn r8071 on MacOS 10.6. Thanks for any help, Thomas Python 2.6.1 (r261:67515, Jul 7 2009,

Re: [Numpy-discussion] Structured array sorting

2010-01-18 Thread Thomas Robitaille
Warren Weckesser-3 wrote: Looks like 'sort' is not handling endianess of the column data correctly. If you change the type of the floating point data to 'f8', the sort works. Thanks for identifying the issue - should I submit a bug report? Thomas -- View this message in context:

[Numpy-discussion] Broadcasting and indexing

2010-01-21 Thread Thomas Robitaille
Hello, I'm trying to understand how array broadcasting can be used for indexing. In the following, I use the term 'row' to refer to the first dimension of a 2D array, and 'column' to the second, just because that's how numpy prints them out. If I consider the following example: a =

[Numpy-discussion] np.fromstring and Python 3

2010-07-25 Thread Thomas Robitaille
Hi, The following example illustrates a problem I'm encountering a problem with the np.fromstring function in Python 3: Python 3.1.2 (r312:79360M, Mar 24 2010, 01:33:18) [GCC 4.0.1 (Apple Inc. build 5493)] on darwin Type help, copyright, credits or license for more information. import numpy

Re: [Numpy-discussion] np.fromstring and Python 3

2010-07-26 Thread Thomas Robitaille
Pauli Virtanen-3 wrote: That's a bug. It apparently implicitly encodes the Unicode string you pass in to UTF-8, instead of trying to encode in ASCII and fail, like it does on Python 2: Thanks! Should I file a bug report? Cheers, Tom -- View this message in context:

Re: [Numpy-discussion] dtype.type for structured arrays

2010-07-27 Thread Thomas Robitaille
Thomas Robitaille wrote: I seem to remember that this used not to be the case, and that even for vector columns, one could access array.dtype[0].type to get the numerical type. Is this a bug, or deliberate? I submitted a bug report: http://projects.scipy.org/numpy/ticket/1557 Cheers

[Numpy-discussion] Bug in loadtxt

2010-08-21 Thread Thomas Robitaille
Hi, I am running into a precision issue with np.loadtxt. I have a data file with the following contents: $ cat data.txt -9.61922814E-01 -9.96192290E-01 -9.99619227E-01 -9.99961919E-01 -9.6192E-01 -9.9611E-01 -1.E+00 If I

Re: [Numpy-discussion] Bug in loadtxt

2010-08-21 Thread Thomas Robitaille
josef.pktd wrote: are you sure this is not just a print precision problem? Thanks for pointing this out, it does seem to be just to do with the printing precision. I didn't notice this before, because for the last few elements of the array, print still gives just -1: In [19]: for x in a:

[Numpy-discussion] Array slices and number of dimensions

2010-09-01 Thread Thomas Robitaille
Hi, I'm trying to extract sub-sections of a multidimensional array while keeping the number of dimensions the same. If I just select a specific element along a given direction, then the number of dimensions goes down by one: import numpy as np a = np.zeros((10,10,10)) a.shape (10, 10, 10)

[Numpy-discussion] Concatenating string arrays

2009-03-18 Thread Thomas Robitaille
Hello, I am trying to find an efficient way to concatenate the elements of two same-length numpy str arrays. For example if I define the following arrays: import numpy as np arr1 = np.array(['a','b','c']) arr2 = np.array(['d','e','f']) I would like to produce a third array that would

Re: [Numpy-discussion] Concatenating string arrays

2009-03-18 Thread Thomas Robitaille
import numpy as np arr1 = np.array(['a','b','c']) arr2 = np.array(['d','e','f']) I would like to produce a third array that would contain ['ad','be','cf']. Is there an efficient way to do this? I could do this element by element, but I need a faster method, as I need to do this on arrays

Re: [Numpy-discussion] Numpy Trac site redirecting in a loop?

2009-05-06 Thread Thomas Robitaille
Hi, I'm having the exact same problem, trying to log in to the trac website for numpy, and getting stuck in a redirect loop. I tried different browsers, and no luck. The browser gets stuck on http://projects.scipy.org/numpy/prefs/account and stops loading after a while because of too many

Re: [Numpy-discussion] Numpy Trac site redirecting in a loop?

2009-05-06 Thread Thomas Robitaille
Could it be linked to specific users, since the problem occurs when loading the account page? I had the same problem on two different computers with two different browsers. Thomas -- View this message in context:

Re: [Numpy-discussion] Numpy Trac site redirecting in a loop?

2009-05-08 Thread Thomas Robitaille
Pauli Virtanen-3 wrote: I applied the patch from the ticket; I think password resets should work now, so you can try using your old accounts again. That worked, thanks! Now I think of it, the problem started occurring after I had forgotten my password and had to reset it. Thomas --

[Numpy-discussion] Rasterizing points onto an array

2009-05-31 Thread Thomas Robitaille
Hi, I have a set of n points with real coordinates between 0 and 1, given by two numpy arrays x and y, with a value at each point represented by a third array z. I am trying to then rasterize the points onto a grid of size npix*npix. So I can start by converting x and y to integer pixel

Re: [Numpy-discussion] Rasterizing points onto an array

2009-06-01 Thread Thomas Robitaille
Nathan Bell-4 wrote: image = np.histogram2d(x, y, bins=bins, weights=z)[0] This works great - thanks! Thomas -- View this message in context: http://www.nabble.com/Rasterizing-points-onto-an-array-tp23808494p23820216.html Sent from the Numpy-discussion mailing list archive at

[Numpy-discussion] unpacking bytes directly in numpy

2009-09-26 Thread Thomas Robitaille
Hi, To convert some bytes to e.g. a 32-bit int, I can do bytes = f.read(4) i = struct.unpack('i', bytes)[0] and the convert it to np.int32 with i = np.int32(i) However, is there a more direct way of directly transforming bytes into a np.int32 type without the intermediate 'struct.unpack'

[Numpy-discussion] rec_append_fields and n-dimensional fields

2009-10-14 Thread Thomas Robitaille
Hi, I'm interested in constructing a recarray with fields that have two or more dimensions. This can be done from scratch like this: r = np.recarray((10,),dtype=[('c1',float,(3,))]) However, I am interested in appending a field to an existing recarray. Rather than repeating existing code I

[Numpy-discussion] Random int64 and float64 numbers

2009-11-01 Thread Thomas Robitaille
Hi, I'm trying to generate random 64-bit integer values for integers and floats using Numpy, within the entire range of valid values for that type. To generate random 32-bit floats, I can use: np.random.uniform(low=np.finfo(np.float32).min,high=np.finfo (np.float32).max,size=10) which

[Numpy-discussion] Formatting uint64 number

2009-11-01 Thread Thomas Robitaille
Hello, I have a question concerning uint64 numbers - let's say I want to format a uint64 number that is 2**31, at the moment it's necessary to wrap the numpy number inside long before formatting In [3]: %40i % np.uint64(2**64-1) Out[3]: ' -1' In [4]:

Re: [Numpy-discussion] Setting up a newcomers label on the issue tracker ?

2014-12-01 Thread Thomas Robitaille
The issue with 'low hanging fruit' is that who is it low-hanging fruit for? Low hanging fruit for a core dev may be days of work for a newcomer. Also, 'newcomer' doesn't give a good idea of how long it will take. I would therefore like to second Tom Aldcroft's suggestion of following something

Re: [Numpy-discussion] Setting up a newcomers label on the issue tracker ?

2014-12-01 Thread Thomas Robitaille
Just to follow-on to my previous email, our labeling convention is described in more detail here: https://github.com/astropy/astropy/wiki/Issue-labeling-convention Cheers, Tom Thomas Robitaille wrote: The issue with 'low hanging fruit' is that who is it low-hanging fruit for? Low hanging

[Numpy-discussion] ANN: numtraits v0.2

2015-09-23 Thread Thomas Robitaille
Hi everyone, We have released a small experimental package called numtraits that builds on top of the traitlets package and provides a NumericalTrait class that can be used to validate properties such as: * number of dimension (for arrays) * shape (for arrays) * domain (e.g. positive, negative,

Re: [Numpy-discussion] ANN: numtraits v0.2

2015-09-24 Thread Thomas Robitaille
irst, I can try and work on it later in the year. Cheers, Tom > > Cheers, > > Sylvain > > > On Wed, Sep 23, 2015 at 12:39 PM, Thomas Robitaille > <thomas.robitai...@gmail.com <mailto:thomas.robitai...@gmail.com>> wrote: > > Hi everyone, > > We