[Numpy-tickets] [NumPy] #768: numpy.i suggestion for improvement: require_shape & require_size

NumPy numpy-tickets@scipy....
Wed Apr 30 11:07:19 CDT 2008

#768: numpy.i suggestion for improvement: require_shape & require_size
 Reporter:  tovrstra     |       Owner:  somebody
     Type:  enhancement  |      Status:  new     
 Priority:  normal       |   Milestone:  1.1.0   
Component:  Other        |     Version:  none    
 Severity:  normal       |    Keywords:          
 I would suggest that `require_size` is renamed to `require_shape`. The
 current situation is confusing because one easily thinks that
 `require_size` is similar to `array_size`. It would be nice to have a
 `require_size` that works like this:

 /* Require the given PyArrayObject to have a specified size in dimension
 i. If
  * the array has the specified size in dimension i, return 1.  Otherwise,
  * the python error string and return 0.
 int require_size(PyArrayObject* ary, int i, npy_intp size) {
   int success = 1;
   if (size != -1 &&  size != array_size(ary,i)) {
     success = 0;
   if (!success) {
       "Array must have size of %d in dimension %d.  Given array has size
 %d "
       "in dimension %d.", size, i, array_size(ary,i), i
   return success;

Ticket URL: <http://scipy.org/scipy/numpy/ticket/768>
NumPy <http://projects.scipy.org/scipy/numpy>
The fundamental package needed for scientific computing with Python.

More information about the Numpy-tickets mailing list