Re: [Numpy-discussion] Array bug with character (regression from 1.4.0)

2010-03-21 Thread Pauli Virtanen
Ryan May wrote:
 The following code, which works with numpy 1.4.0, results in an error:

Python 2.6, I presume?

 In [1]: import numpy as np
 In [2]: v = 'm'
 In [3]: dt = np.dtype('c')
 In [4]: a = np.asarray(v, dt)

 On SVN trunk:
 ValueError: assignment to 0-d array

 In [5]: np.__version__
 Out[5]: '2.0.0.dev8297'

 Thoughts?

Nope, but it's likely my bad. Smells a bit like the dtype 'c' has size 0 that 
doesn't get automatically adjusted in the array constructor, so you end up 
assigning size-1 string to size-0 array element... Which is strange sice I 
don't think this particular code path has been changed at all.

One would have to follow the C execution path with gdb to find out what goes 
wrong.

-- 
Pauli Virtanen
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Array bug with character (regression from 1.4.0)

2010-03-21 Thread Charles R Harris
On Sun, Mar 21, 2010 at 4:08 PM, Pauli Virtanen p...@iki.fi wrote:

 Ryan May wrote:
  The following code, which works with numpy 1.4.0, results in an error:

 Python 2.6, I presume?

  In [1]: import numpy as np
  In [2]: v = 'm'
  In [3]: dt = np.dtype('c')
  In [4]: a = np.asarray(v, dt)
 
  On SVN trunk:
  ValueError: assignment to 0-d array
 
  In [5]: np.__version__
  Out[5]: '2.0.0.dev8297'
 
  Thoughts?

 Nope, but it's likely my bad. Smells a bit like the dtype 'c' has size 0
 that doesn't get automatically adjusted in the array constructor, so you end
 up assigning size-1 string to size-0 array element... Which is strange sice
 I don't think this particular code path has been changed at all.

 One would have to follow the C execution path with gdb to find out what
 goes wrong.


I was wondering if this was related to Michael's fixes for character arrays?
A little bisection might help localize the problem.

Chuck
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Array bug with character (regression from 1.4.0)

2010-03-21 Thread Pauli Virtanen
su, 2010-03-21 kello 16:13 -0600, Charles R Harris kirjoitti:
 I was wondering if this was related to Michael's fixes for
 character arrays? A little bisection might help localize the problem.

It's a bug I introduced in r8144... I forgot one *can* assign strings to
0-d arrays, and strings are indeed one sequence type.

I'm going to back that changeset out, since it was only a cosmetic fix.
That particular part of code needs some cleanup (it's a bit too hairy if
things like this can slip), but I don't have the time at the moment to
come up with a more complete fix.

Cheers,
Pauli

___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Array bug with character (regression from 1.4.0)

2010-03-21 Thread Charles R Harris
On Sun, Mar 21, 2010 at 4:29 PM, Pauli Virtanen p...@iki.fi wrote:

 su, 2010-03-21 kello 16:13 -0600, Charles R Harris kirjoitti:
  I was wondering if this was related to Michael's fixes for
  character arrays? A little bisection might help localize the problem.

 It's a bug I introduced in r8144... I forgot one *can* assign strings to
 0-d arrays, and strings are indeed one sequence type.

 I'm going to back that changeset out, since it was only a cosmetic fix.
 That particular part of code needs some cleanup (it's a bit too hairy if
 things like this can slip), but I don't have the time at the moment to
 come up with a more complete fix.


Lots of the code needs some cleanup ;) The first step was to reformat it --
still ongoing, I've got changes on hold for after the release -- and break
it up into smaller files with some similarity of function. At some point the
code needs to be documented and some macros relaced with inline functions.
All macros that implement jumps should be removed and replaced by something
more transparent. I'd also like to see some of the policy type stuff move
up to cython, which should be easier to document and understand, not to
mention making for a cleaner interface to Python. So on and so on... We
could use a few more developers, especially with David getting a real job.

Chuck
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


Re: [Numpy-discussion] Array bug with character (regression from 1.4.0)

2010-03-21 Thread Ryan May
On Sun, Mar 21, 2010 at 5:29 PM, Pauli Virtanen p...@iki.fi wrote:
 su, 2010-03-21 kello 16:13 -0600, Charles R Harris kirjoitti:
 I was wondering if this was related to Michael's fixes for
 character arrays? A little bisection might help localize the problem.

 It's a bug I introduced in r8144... I forgot one *can* assign strings to
 0-d arrays, and strings are indeed one sequence type.

 I'm going to back that changeset out, since it was only a cosmetic fix.
 That particular part of code needs some cleanup (it's a bit too hairy if
 things like this can slip), but I don't have the time at the moment to
 come up with a more complete fix.

That fixed it for me, thanks for getting done quickly.

What's amusing is that I found it because pupynere was failing to
write files where a variable had an attribute that consisted of a
single letter.

Ryan

-- 
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


[Numpy-discussion] Array bug with character (regression from 1.4.0)

2010-03-20 Thread Ryan May
The following code, which works with numpy 1.4.0, results in an error:

In [1]: import numpy as np
In [2]: v = 'm'
In [3]: dt = np.dtype('c')
In [4]: a = np.asarray(v, dt)

On 1.4.0:

In [5]: a
Out[5]:
array('m',
  dtype='|S1')
In [6]: np.__version__
Out[6]: '1.4.0'

On SVN trunk:

/home/rmay/.local/lib/python2.6/site-packages/numpy/core/numeric.pyc
in asarray(a, dtype, order)
282
283 
-- 284 return array(a, dtype, copy=False, order=order)
285
286 def asanyarray(a, dtype=None, order=None):

ValueError: assignment to 0-d array

In [5]: np.__version__
Out[5]: '2.0.0.dev8297'

Thoughts?
(Filed at: http://projects.scipy.org/numpy/ticket/1436)

Ryan

-- 
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion