[Numpy-discussion] Error building numpy documentation

2009-02-04 Thread Nadav Horesh
I just dowloads the latest numpy's svn version and tried to build its
documentation with

$ make latex 

on the doc subdirectory, and got the following error message:

writing... Sphinx error:
too many nesting section levels for LaTeX, at heading:
numpy.ma.MaskedArray.__lt__
make: *** [latex] Error 1

Machine: 64 bit gentoo linux running texlive2007

Any ideas?

  Nadav
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Numpy 1.3 release date ?

2009-02-04 Thread Pauli Virtanen
Wed, 04 Feb 2009 11:04:25 +0900, David Cournapeau wrote:
[clip]
 Talking about the things I have worked on for 1.3, I did not have the
 time to finish everything. The things which I would like to be done
 before a 1.3.0 release are:
  - fix formatting issues that Pauli and me worked on (for locale
 independence and all): I believe it is mostly a matter of merging the
 changes in the trunk, and testing. Pauli, do you agree ?

Agree, I think it should be OK, and IIRC tests passed also on Windows 
(well, Wine to be accurate). I don't recall anything more that would be 
required to do.

It might be nice also to address this wart: 
http://scipy.org/scipy/numpy/ticket/883 for Numpy 1.3. But it's a 
separate issue from the locale and formatting problems.

Pauli

___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Few minor issues with numscons

2009-02-04 Thread David Cournapeau
Brian Granger wrote:
 The releases are on Pypi for quite some time. I converted the repo to
 git and put it on github, but I have not really worked on numscons for
 several months now for lack of time ( and because numscons it mostly
 done and the main limitations of numscons are not fixable without
 fixing some fairly major scons limitations).

 Basically, the repo on github is only the convertion from bzr, without
 any new features.
 

 Do you have plans to continue to maintain it though?
   

I can't say for sure; I am still quite interested in working on
build/distributions problems in numpy and more generally python. But in
my mind, this work only really makes sense if it becomes integrated to
numpy.distutils and even can be used by arbitrary python extension as
some point. And that's just not realistic at this point because of some
fundamental scons limitations (I would like scons to be callable from a
pure python scripts, as a library). So I spent quite some time on scons
itself  (and more recently waf, which started as a scons fork).

There is also the fundamental time problem, but we all are in the same
boat on this one :)

 One other things I forgot to mention.  I first tried the head of your
 git repo and numpy complained that the version of numscons (0.10) was
 too *old*.  It wanted the version to be greater than somehting like
 0.9.1, and clearly it was, so it looks like there is a bug in the
 numscons version parsing in numpy.distutils.
   

Can be a stupid bug in the version check. It should be ok with numpy
trunk, though.

David
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Error building numpy documentation

2009-02-04 Thread Scott Sinclair
 2009/2/4 Nadav Horesh nad...@visionsense.com:
 I just dowloads the latest numpy's svn version and tried to build its
 documentation with

 $ make latex

 on the doc subdirectory, and got the following error message:

 writing... Sphinx error:
 too many nesting section levels for LaTeX, at heading:
 numpy.ma.MaskedArray.__lt__
 make: *** [latex] Error 1

 Machine: 64 bit gentoo linux running texlive2007

 Any ideas?

No ideas, but this has been reported before:

http://projects.scipy.org/pipermail/numpy-discussion/2009-January/039917.html

I've filed a ticket:

http://scipy.org/scipy/numpy/ticket/998

Cheers,
Scott
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Numpy 1.3 release date ?

2009-02-04 Thread David Cournapeau
Scott Sinclair wrote:

 There are a bunch of documentation patches that should to be reviewed
 and applied to SVN before the release (especially those marked 'Needs
 review' or better).

 http://docs.scipy.org/numpy/patch/

In my mind, documentations fixes are much less important than code, not
because documentation matters less, but because it can be handled at the
last moment much more easily - there is little chance that a doc change
breaks on windows only, for example.

David
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] poly1d left versus right multiplication with np numbers

2009-02-04 Thread Pierre GM

On Feb 4, 2009, at 11:00 AM, josef.p...@gmail.com wrote:

 I just had a hard to find bug in my program. poly1d  treats numpy
 scalars differently than python numbers when left or right
 multiplication is used.

 Essentially, if the first term is the numpy scalar, multiplied by a
 polynomial, then the result is an np.array.
 If the order is reversed, then the result is an instance of np.poly1d.
 The return types are also the same for numpy arrays, which is at least
 understandable, although a warning would be good)

 When using plain (python) numbers, then both left and right
 multiplication of the number with the polynomial returns a polynomial.

 Is this a bug or a feature? I didn't see it mentioned in the docs.

Looks like yet another example of ticket #826:
http://scipy.org/scipy/numpy/ticket/826
This one is getting quite a problem, and I have no idea how to fix  
it... 
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


[Numpy-discussion] Resolver One -- .NET spreadsheet with NumPy -- beta testers?

2009-02-04 Thread William Reade
Hi all

We're about to release the first public beta of Resolver One, our 
Pythonic spreadsheet, with (rather basic) NumPy integration. It requires 
32-bit Windows and .NET 2.0SP1 to run, so it may not be appropriate for 
everyone, but -- if anyone is interested in playing with it -- it would 
be really useful to have some real live NumPy users telling us what we 
could improve. If anyone here would like to try it out, please let me 
know, and I'll arrange beta access.

Cheers
William
http://resolversystems.com/
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] poly1d left versus right multiplication with np numbers

2009-02-04 Thread josef . pktd
On Wed, Feb 4, 2009 at 11:19 AM, Pierre GM pgmdevl...@gmail.com wrote:

 On Feb 4, 2009, at 11:00 AM, josef.p...@gmail.com wrote:

 I just had a hard to find bug in my program. poly1d  treats numpy
 scalars differently than python numbers when left or right
 multiplication is used.

 Essentially, if the first term is the numpy scalar, multiplied by a
 polynomial, then the result is an np.array.
 If the order is reversed, then the result is an instance of np.poly1d.
 The return types are also the same for numpy arrays, which is at least
 understandable, although a warning would be good)

 When using plain (python) numbers, then both left and right
 multiplication of the number with the polynomial returns a polynomial.

 Is this a bug or a feature? I didn't see it mentioned in the docs.

 Looks like yet another example of ticket #826:
 http://scipy.org/scipy/numpy/ticket/826
 This one is getting quite a problem, and I have no idea how to fix
 it...

Thanks, yes it looks exactly like this ticket. At least, once I know
about it, it is not too difficult to work around, but it costs a lot
of debugging time to figure this out.

Josef
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Numpy 1.3 release date ?

2009-02-04 Thread jh
Scott Sinclair scott.sinclair...@gmail.com wrote:
 2009/2/4 David Cournapeau courn...@gmail.com:
 On Tue, Feb 3, 2009 at 11:49 PM, Pierre GM pgmdevl...@gmail.com wrote:
 All,
 When can we expect numpy 1.3 to be released ?

 I think official 2.6 support (with binaries for the platforms where we
 support binaries), x64 support and everything which has been done
 already would be enough to make a release.

I'd like to see a self-consistent and reasonably recent numpy/scipy
make the Ubuntu 9.04 FeatureFreeze deadline of 19 February.  Is this
possible?  One of the reasons we had discussed doing more frequent
releases was to get consistent and recent packages in the mainstream
Linuxes, and Ubuntu is very popular in our community.

There are a bunch of documentation patches that should to be reviewed
and applied to SVN before the release (especially those marked 'Needs
review' or better).

http://docs.scipy.org/numpy/patch/

At this point, we're focussing on getting semi-decent drafts of as
many docstrings as possible rather than on polishing the ones we have
as drafts, on the basis of something is always better than nothing as
long as it's not wrong.  So, please don't hold up a release for
review, just get as many drafts in as possible.

Also, it has become clear that we need separate technical and writing
reviews, as a number of pages marked as reviewed are deficient in
one or the other area, probably the one that wasn't the strength of
the reviewer.  That entails discussion and revamping of the site,
which can happen once we have a larger percentage of the docstrings in
draft form.  (Any discussion on the merits of this should take place
on scipy-dev, which is the home of doc discussions.)

--jh--
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Numpy 1.3 release date ?

2009-02-04 Thread Scott Sinclair
 2009/2/4 David Cournapeau da...@ar.media.kyoto-u.ac.jp:
 Scott Sinclair wrote:

 There are a bunch of documentation patches that should to be reviewed
 and applied to SVN before the release (especially those marked 'Needs
 review' or better).

 http://docs.scipy.org/numpy/patch/

 In my mind, documentations fixes are much less important than code, not
 because documentation matters less, but because it can be handled at the
 last moment much more easily - there is little chance that a doc change
 breaks on windows only, for example.

Sure. Just trying to encourage a few more reviews and documentation
contributions.

Cheers,
Scott
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] porting NumPy to Python 3

2009-02-04 Thread James Watson
Hi Ondrej,

To get 2to3 to run without warnings, the following files require minor changes:
- numpy/distutils/fcompiler/intel.py
- numpy/distutils/misc_util.py
- numpy/distutils/command/build_src.py
- numpy/f2py/crackfortran.py
- numpy/lib/function_base.py
- numpy/linalg/lapack_lite/make_lite.py

There are also other (possibly many, still working on this) files that
require syntactic changes to run post 2to3.

Is there anywhere specific I should upload these changes?  Is this
list appropriate?  Is there a developer I can send these and future
patches to?

James.



 Date: Tue, 3 Feb 2009 01:03:15 -0800
 From: Ondrej Certik ond...@certik.cz
 Subject: Re: [Numpy-discussion] porting NumPy to Python 3
 To: Discussion of Numerical Python numpy-discussion@scipy.org
 Message-ID:
85b5c3130902030103w69180a6bm4143050b4b82b...@mail.gmail.com
 Content-Type: text/plain; charset=UTF-8

 Hi James,

 On Thu, Jan 29, 2009 at 2:11 AM, James Watson watson@gmail.com wrote:
 Hi,

 I am interested in contributing to the port of NumPy to Python 3.  Who
 I should coordinate effort with?

 I have started at the Python end of the problem (as opposed to
 http://www.scipy.org/Python3k), e.g. I have several patches to get
 2to3 to work on NumPy's Python source code.

 I am sorry that noone has replied to your email. Could you please
 upload your patches somewhere?

 Ondrej
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


[Numpy-discussion] genfromtxt view with object dtype

2009-02-04 Thread Brent Pedersen
hi, i am using genfromtxt, with a dtype like this:
[('seqid', '|S24'), ('source', '|S16'), ('type', '|S16'), ('start',
'i4'), ('end', 'i4'), ('score', 'f8'), ('strand', '|S1'), ('phase',
'i4'), ('attrs', '|O4')]

where i'm having problems with the attrs column which i'd like to be a
dict. i can specify a convertor to parse a string into a dict, and it
is correctly converted to a dict,
but then in io.py it tries to take a view() of that dtype and it gives
the error:

A = np.genfromtxt(fname, **kwargs)
  File /usr/lib/python2.5/site-packages/numpy/lib/io.py, line 922,
in genfromtxt
output = rows.view(dtype)
 TypeError: Cannot change data-type for object array.


is there anyway around this or must that col be kept as a string?
it seems like genfromtxt expects you to specify either a dtype _or_ a
convertor, not both.

thanks,
-brent
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] porting NumPy to Python 3

2009-02-04 Thread Charles R Harris
On Wed, Feb 4, 2009 at 10:02 AM, James Watson watson@gmail.com wrote:

 Hi Ondrej,

 To get 2to3 to run without warnings, the following files require minor
 changes:
 - numpy/distutils/fcompiler/intel.py
 - numpy/distutils/misc_util.py
 - numpy/distutils/command/build_src.py
 - numpy/f2py/crackfortran.py
 - numpy/lib/function_base.py
 - numpy/linalg/lapack_lite/make_lite.py

 There are also other (possibly many, still working on this) files that
 require syntactic changes to run post 2to3.

 Is there anywhere specific I should upload these changes?  Is this
 list appropriate?  Is there a developer I can send these and future
 patches to?


Maybe we could add a python 3 milestone so folks could post tickets for
these sorts of things. For the time being you could just post to the list
here with the patches and something in the subject line that identifies it
as a patch for python 3. I think we could make any small changes as long as
they are compatible with python 2.4.

Chuck
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Numpy 1.3 release date ?

2009-02-04 Thread Charles R Harris
On Wed, Feb 4, 2009 at 10:01 AM, j...@physics.ucf.edu wrote:

 Scott Sinclair scott.sinclair...@gmail.com wrote:
  2009/2/4 David Cournapeau courn...@gmail.com:
  On Tue, Feb 3, 2009 at 11:49 PM, Pierre GM pgmdevl...@gmail.com
 wrote:
  All,
  When can we expect numpy 1.3 to be released ?
 
  I think official 2.6 support (with binaries for the platforms where we
  support binaries), x64 support and everything which has been done
  already would be enough to make a release.

 I'd like to see a self-consistent and reasonably recent numpy/scipy
 make the Ubuntu 9.04 FeatureFreeze deadline of 19 February.  Is this
 possible?  One of the reasons we had discussed doing more frequent
 releases was to get consistent and recent packages in the mainstream
 Linuxes, and Ubuntu is very popular in our community.


That deadline is pretty close ;) There has been a dearth of developer time
these last few months, what with work, holidays, and dissertations, and I
don't know when that is going to get better.

Chuck
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] porting NumPy to Python 3

2009-02-04 Thread Bruce Southey
Charles R Harris wrote:


 On Wed, Feb 4, 2009 at 10:02 AM, James Watson watson@gmail.com 
 mailto:watson@gmail.com wrote:

 Hi Ondrej,

 To get 2to3 to run without warnings, the following files require
 minor changes:
 - numpy/distutils/fcompiler/intel.py
 - numpy/distutils/misc_util.py
 - numpy/distutils/command/build_src.py
 - numpy/f2py/crackfortran.py
 - numpy/lib/function_base.py
 - numpy/linalg/lapack_lite/make_lite.py

 There are also other (possibly many, still working on this) files that
 require syntactic changes to run post 2to3.

 Is there anywhere specific I should upload these changes?  Is this
 list appropriate?  Is there a developer I can send these and future
 patches to?


 Maybe we could add a python 3 milestone so folks could post tickets 
 for these sorts of things. For the time being you could just post to 
 the list here with the patches and something in the subject line that 
 identifies it as a patch for python 3. I think we could make any small 
 changes as long as they are compatible with python 2.4.

 Chuck


 

 ___
 Numpy-discussion mailing list
 Numpy-discussion@scipy.org
 http://projects.scipy.org/mailman/listinfo/numpy-discussion
   
If you follow Guido's recommendation (at the bottom of 
http://docs.python.org/dev/3.0/whatsnew/3.0.html), then we should first 
be compatible with Python 2.6 (about the current stage) . Then 
compatible using Python 2.3 with the -3 flag (warn about Python 3.x 
incompatibilities) and fix warnings like:
 numpy/core/__init__.py:11: DeprecationWarning: the cPickle module has 
been removed in Python 3.0
(Of course you lose speed of cPickle if you blindly change it to use the 
old Pickle in Python 2.x)

Finally use the 2to3 tool to get a Python 3 version.

Bruce


___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


[Numpy-discussion] ImportError: No module named dateutil.parser

2009-02-04 Thread Bruce Southey
Hi,
I just updated to the latest SVN but I get a failure when running the 
tests due to missing dateutil.parser. Should this module exist in Numpy 
or just a inappropriate test?

Bruce

  numpy.test()
Running unit tests for numpy
NumPy version 1.3.0.dev6338
NumPy is installed in /usr/lib64/python2.5/site-packages/numpy
Python version 2.5.2 (r252:60911, Sep 30 2008, 15:42:03) [GCC 4.3.2 
20080917 (Red Hat 4.3.2-4)]
nose version 0.10.3
.....K.E..
 
..
==
ERROR: Tests updatemapper
--
Traceback (most recent call last):
  File 
/usr/lib64/python2.5/site-packages/numpy/lib/tests/test__iotools.py, 
line 133, in test_upgrademapper
import dateutil.parser
ImportError: No module named dateutil.parser

--
Ran 1888 tests in 6.084s

FAILED (KNOWNFAIL=9, errors=1)
nose.result.TextTestResult run=1888 errors=1 failures=0


___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] ImportError: No module named dateutil.parser

2009-02-04 Thread Robert Kern
On Wed, Feb 4, 2009 at 14:40, Bruce Southey bsout...@gmail.com wrote:
 Hi,
 I just updated to the latest SVN but I get a failure when running the
 tests due to missing dateutil.parser. Should this module exist in Numpy
 or just a inappropriate test?

It's a bad test.

-- 
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] ImportError: No module named dateutil.parser

2009-02-04 Thread Robert Kern
On Wed, Feb 4, 2009 at 14:54, Pierre GM pgmdevl...@gmail.com wrote:

 On Feb 4, 2009, at 3:40 PM, Bruce Southey wrote:

 Hi,
 I just updated to the latest SVN but I get a failure when running the
 tests due to missing dateutil.parser. Should this module exist in
 Numpy
 or just a inappropriate test?

 I put the corresponding tests in a try/except ImportError block
 (r6339), that should fix it.

No, rewrite the test to not use external libraries, please. Test the
functionality without needing dateutils.

-- 
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


[Numpy-discussion] Multiplying a matrix by a vector

2009-02-04 Thread Simon Palmer

Bit of a newb question I suspect...

I have a matrix and a vector which has the same number of elements as the
matrix has rows.  I want to multiply each element in a row in the matrix by
the corresponding element in the vector.  I can obviously do this with a
loop, but am guessing there is a more elegant (and faster?) solution.  

Just for clarity...
Matrix
[X1, X2, X3]
[Y1, Y2, Y3]

Vector
[A, B]

Desired result
[X1*A, X2*A, X3*A]
[Y1*B, Y2*B, Y3*B]
-- 
View this message in context: 
http://www.nabble.com/Multiplying-a-matrix-by-a-vector-tp21839828p21839828.html
Sent from the Numpy-discussion mailing list archive at Nabble.com.

___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


[Numpy-discussion] Array dtype problems

2009-02-04 Thread Andrew Collette
Hello,

I'm having an issue with 'array' dtypes; if I do this:

mydtype = numpy.dtype(('i', (4,)))
arr = numpy.empty((100,), dtype=mydtype)

then the array datatype shape is absorbed into the shape of the
array.  This simplifies indexing, but is really annoying as it means
that the dtype doesn't round trip; I can't even use use astype as it
complains about a shape mismatch.  How can I create an array in a
manner that preserves the dtype array information?  Or is there a way
to take an existing array of the correct shape and re-cast it to use
an array dtype?

Thanks,
Andrew Collette
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] ImportError: No module named dateutil.parser

2009-02-04 Thread Pierre GM

On Feb 4, 2009, at 3:56 PM, Robert Kern wrote:


 No, rewrite the test to not use external libraries, please. Test the
 functionality without needing dateutils.

OK then, should be fixed in r6340.
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] ImportError: No module named dateutil.parser

2009-02-04 Thread Robert Kern
On Wed, Feb 4, 2009 at 16:12, Pierre GM pgmdevl...@gmail.com wrote:

 On Feb 4, 2009, at 3:56 PM, Robert Kern wrote:

 No, rewrite the test to not use external libraries, please. Test the
 functionality without needing dateutils.

 OK then, should be fixed in r6340.

Thank you!

-- 
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] Multiplying a matrix by a vector

2009-02-04 Thread Christopher Barker
Simon Palmer wrote:
 I have a matrix and a vector which has the same number of elements as the
 matrix has rows.  I want to multiply each element in a row in the matrix by
 the corresponding element in the vector.

  M = np.arange(6).reshape((2,3))
  M
array([[0, 1, 2],
[3, 4, 5]])
  v = np.array((4,5)).reshape((-1,1)) # make it a column vector
  v
array([[4],
[5]])
  M * v
array([[ 0,  4,  8],
[15, 20, 25]])


you can also do it with np.newaxis:

  v = np.array((4,5))
  M * v[:,np.newaxis]
array([[ 0,  4,  8],
[15, 20, 25]])



http://www.scipy.org/EricsBroadcastingDoc


If you are really working with a matrix, rather than a 2-d array, you 
may want to look at the np.matrix object.

-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

chris.bar...@noaa.gov
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


[Numpy-discussion] Renaming a field of an object array

2009-02-04 Thread Pierre GM
All,
I'm a tad puzzled by the following behavior (I'm trying to correct a  
bug in genfromtxt):

I'm creating an empty structured ndarray, using np.object as dtype.

  a = np.empty(1,dtype=[('',np.object)])
array([(None,)],
   dtype=[('f0', '|O4')])

Now, I'd like to rename the field:
  a.view([('NAME',np.object)])
TypeError: Cannot change data-type for object array.

I understand why I can't change the *type* of the field, but not why I  
can't change its name that way. What would be an option that wouldn't  
involve creating a new array ?
Thx in advance.

___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Renaming a field of an object array

2009-02-04 Thread Brent Pedersen
On Wed, Feb 4, 2009 at 2:50 PM, Pierre GM pgmdevl...@gmail.com wrote:
 All,
 I'm a tad puzzled by the following behavior (I'm trying to correct a
 bug in genfromtxt):

 I'm creating an empty structured ndarray, using np.object as dtype.

   a = np.empty(1,dtype=[('',np.object)])
 array([(None,)],
   dtype=[('f0', '|O4')])

 Now, I'd like to rename the field:
   a.view([('NAME',np.object)])
 TypeError: Cannot change data-type for object array.

 I understand why I can't change the *type* of the field, but not why I
 can't change its name that way. What would be an option that wouldn't
 involve creating a new array ?
 Thx in advance.

 ___
 Numpy-discussion mailing list
 Numpy-discussion@scipy.org
 http://projects.scipy.org/mailman/listinfo/numpy-discussion


hi, i was looking at this as well. the code in arrayobject.c doesnt
match the error string. i changed the code to do what the error string
says and seems thing to work.
i think the if-block below it should also use xor (not changed in this
patch), but i'm not a c programmer so i may be missing something
obvious.

svn diff numpy/core/src/arrayobject.c
Index: numpy/core/src/arrayobject.c
===
--- numpy/core/src/arrayobject.c(revision 6338)
+++ numpy/core/src/arrayobject.c(working copy)
@@ -6506,9 +6506,16 @@
 PyErr_SetString(PyExc_TypeError, invalid data-type for array);
 return -1;
 }
-if (PyDataType_FLAGCHK(newtype, NPY_ITEM_HASOBJECT) ||
-PyDataType_FLAGCHK(newtype, NPY_ITEM_IS_POINTER) ||
-PyDataType_FLAGCHK(self-descr, NPY_ITEM_HASOBJECT) ||
+if (PyDataType_FLAGCHK(newtype, NPY_ITEM_HASOBJECT) ^
+PyDataType_FLAGCHK(self-descr, NPY_ITEM_HASOBJECT)) {
+PyErr_SetString(PyExc_TypeError,  \
+Cannot change data-type for object  \
+array.);
+Py_DECREF(newtype);
+return -1;
+}
+
+if (PyDataType_FLAGCHK(newtype, NPY_ITEM_IS_POINTER) ||
 PyDataType_FLAGCHK(self-descr, NPY_ITEM_IS_POINTER)) {
 PyErr_SetString(PyExc_TypeError,  \
 Cannot change data-type for object  \
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Numpy 1.3 release date ?

2009-02-04 Thread David Cournapeau
On Thu, Feb 5, 2009 at 2:48 AM, Charles R Harris
charlesr.har...@gmail.com wrote:


 On Wed, Feb 4, 2009 at 10:01 AM, j...@physics.ucf.edu wrote:

 Scott Sinclair scott.sinclair...@gmail.com wrote:
  2009/2/4 David Cournapeau courn...@gmail.com:
  On Tue, Feb 3, 2009 at 11:49 PM, Pierre GM pgmdevl...@gmail.com
  wrote:
  All,
  When can we expect numpy 1.3 to be released ?
 
  I think official 2.6 support (with binaries for the platforms where we
  support binaries), x64 support and everything which has been done
  already would be enough to make a release.

 I'd like to see a self-consistent and reasonably recent numpy/scipy
 make the Ubuntu 9.04 FeatureFreeze deadline of 19 February.  Is this
 possible?  One of the reasons we had discussed doing more frequent
 releases was to get consistent and recent packages in the mainstream
 Linuxes, and Ubuntu is very popular in our community.

 That deadline is pretty close ;)

I think it is safe to say it will not be possible to release numpy for
that date.

Concerning Ubuntu, it sounds more realistic to make sure it is updated
to 1.2.1, and if possible to release 0.7.0.

David
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] genfromtxt view with object dtype

2009-02-04 Thread Pierre GM
OK, Brent, try r6341.
I fixed genfromtxt for cases like yours (explicit dtype involving a  
np.object).
Note that the fix won't work if the dtype is nested and involves  
np.objects (as we would hit the pb of renaming fields we observed...).
Let me know how it goes.
P.

On Feb 4, 2009, at 4:03 PM, Brent Pedersen wrote:

 On Wed, Feb 4, 2009 at 9:36 AM, Pierre GM pgmdevl...@gmail.com  
 wrote:

 On Feb 4, 2009, at 12:09 PM, Brent Pedersen wrote:

 hi, i am using genfromtxt, with a dtype like this:
 [('seqid', '|S24'), ('source', '|S16'), ('type', '|S16'), ('start',
 'i4'), ('end', 'i4'), ('score', 'f8'), ('strand', '|S1'),  
 ('phase',
 'i4'), ('attrs', '|O4')]

 Brent,
 Please post a simple, self-contained example with a few lines of the
 file you want to load.

 ___
 Numpy-discussion mailing list
 Numpy-discussion@scipy.org
 http://projects.scipy.org/mailman/listinfo/numpy-discussion


 hi pierre, here is an example.
 thanks,
 -brent

 ##

 import numpy as np
 from cStringIO import StringIO

 gffstr = \
 ##gff-version 3
 1\tucb\tgene\t2234602\t2234702\t.\t-\t. 
 \tID 
 = 
 grape_1_2234602_2234702 
 ;match 
 = 
 EVM_prediction_supercontig_1.248,EVM_prediction_supercontig_1.248.mRNA
 1\tucb\tgene\t2300292\t2302123\t.\t+\t. 
 \tID=grape_1_2300292_2302123;match=EVM_prediction_supercontig_244.8
 1\tucb\tgene\t2303615\t2303967\t.\t+\t. 
 \tID=grape_1_2303615_2303967;match=EVM_prediction_supercontig_244.8
 1\tucb\tgene\t2303616\t2303966\t.\t+\t. 
 \tParent=grape_1_2303615_2303967
 1\tucb\tgene\t3596400\t3596503\t.\t-\t. 
 \tID=grape_1_3596400_3596503;match=evm.TU.supercontig_167.27
 1\tucb\tgene\t3600651\t3600977\t.\t-\t. 
 \tmatch=evm.model.supercontig_1217.1,evm.model.supercontig_1217.1.mRNA
 

 dtype = {'names' :
  ('seqid', 'source', 'type', 'start', 'end',
'score', 'strand', 'phase', 'attrs') ,
'formats':
  ['S24', 'S16', 'S16', 'i4', 'i4', 'f8',
  'S1', 'i4', 'S128']}

 #OK with S128 for attrs
 print np.genfromtxt(StringIO(gffstr), dtype = dtype)



 def _attr(kvstr):
pairs = [kv.split(=) for kv in kvstr.split(;)]
return dict(pairs)

 # change S128 to object to have col attrs as dictionary
 dtype['formats'][-1] = 'O'
 converters = {8: _attr }
 #NOT OK
 print np.genfromtxt(StringIO(gffstr), dtype = dtype,  
 converters=converters)
 ___
 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] genfromtxt view with object dtype

2009-02-04 Thread Brent Pedersen
On Wed, Feb 4, 2009 at 8:51 PM, Pierre GM pgmdevl...@gmail.com wrote:
 OK, Brent, try r6341.
 I fixed genfromtxt for cases like yours (explicit dtype involving a
 np.object).
 Note that the fix won't work if the dtype is nested and involves
 np.objects (as we would hit the pb of renaming fields we observed...).
 Let me know how it goes.
 P.


that fixes it. thanks again pierre!
-b




 On Feb 4, 2009, at 4:03 PM, Brent Pedersen wrote:

 On Wed, Feb 4, 2009 at 9:36 AM, Pierre GM pgmdevl...@gmail.com
 wrote:

 On Feb 4, 2009, at 12:09 PM, Brent Pedersen wrote:

 hi, i am using genfromtxt, with a dtype like this:
 [('seqid', '|S24'), ('source', '|S16'), ('type', '|S16'), ('start',
 'i4'), ('end', 'i4'), ('score', 'f8'), ('strand', '|S1'),
 ('phase',
 'i4'), ('attrs', '|O4')]

 Brent,
 Please post a simple, self-contained example with a few lines of the
 file you want to load.

 ___
 Numpy-discussion mailing list
 Numpy-discussion@scipy.org
 http://projects.scipy.org/mailman/listinfo/numpy-discussion


 hi pierre, here is an example.
 thanks,
 -brent

 ##

 import numpy as np
 from cStringIO import StringIO

 gffstr = \
 ##gff-version 3
 1\tucb\tgene\t2234602\t2234702\t.\t-\t.
 \tID
 =
 grape_1_2234602_2234702
 ;match
 =
 EVM_prediction_supercontig_1.248,EVM_prediction_supercontig_1.248.mRNA
 1\tucb\tgene\t2300292\t2302123\t.\t+\t.
 \tID=grape_1_2300292_2302123;match=EVM_prediction_supercontig_244.8
 1\tucb\tgene\t2303615\t2303967\t.\t+\t.
 \tID=grape_1_2303615_2303967;match=EVM_prediction_supercontig_244.8
 1\tucb\tgene\t2303616\t2303966\t.\t+\t.
 \tParent=grape_1_2303615_2303967
 1\tucb\tgene\t3596400\t3596503\t.\t-\t.
 \tID=grape_1_3596400_3596503;match=evm.TU.supercontig_167.27
 1\tucb\tgene\t3600651\t3600977\t.\t-\t.
 \tmatch=evm.model.supercontig_1217.1,evm.model.supercontig_1217.1.mRNA
 

 dtype = {'names' :
  ('seqid', 'source', 'type', 'start', 'end',
'score', 'strand', 'phase', 'attrs') ,
'formats':
  ['S24', 'S16', 'S16', 'i4', 'i4', 'f8',
  'S1', 'i4', 'S128']}

 #OK with S128 for attrs
 print np.genfromtxt(StringIO(gffstr), dtype = dtype)



 def _attr(kvstr):
pairs = [kv.split(=) for kv in kvstr.split(;)]
return dict(pairs)

 # change S128 to object to have col attrs as dictionary
 dtype['formats'][-1] = 'O'
 converters = {8: _attr }
 #NOT OK
 print np.genfromtxt(StringIO(gffstr), dtype = dtype,
 converters=converters)
 ___
 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

___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion