# [Numpy-discussion] round_() problems and arange incompatibility

Colin J. Williams cjw at sympatico.ca
Wed Mar 29 06:49:10 CST 2006

```Pierre GM wrote:

>> File "/var/www/localhost/htdocs/larry/LcUtil.py", line 120, in mat2table
>>    outStr += '' + str(N.round_(item,prec)) + ''
>>
>>
>
>
>Have you tried to use around instead of round ? That way, I think you wouldn't
>be using oldnumeric and stick to ndarrays...
>
>
>
"round" seems a better word to use than "around".  Would it not be
better to have some sort of compatibility switch for those who wish to
use names with their old meanings, rather than prepending "a" to
indicate the new way?

Incidentally, particularly for testing, I found the shape parameter in
arange to be useful:

[Dbg]>>> import numarray as _na
[Dbg]>>> help(_na.arange)
Help on function arange in module numarray.numarraycore:

arange(a1, a2=None, stride=1, type=None, shape=None, typecode=None,
dtype=None)
Returns an array of numbers in sequence over the specified range.

With numpy, we have:
[Dbg]>>> a= _n.arange(6, shape=(3, 2), dtype= _n.ArrayType)
Traceback (most recent call last):
File "<interactive input>", line 1, in ?
TypeError: 'shape' is an invalid keyword argument for this function
[Dbg]>>> help(_n.arange)
Help on built-in function arange in module numpy.core.multiarray:

arange(...)
arange([start,] stop[, step,], dtype=None)

For integer arguments, just like range() except it returns an array
whose type can
be specified by the keyword argument dtype.

If dtype is not specified, the type of the result is deduced from
the type of the
arguments.

For floating point arguments, the length of the result is ceil((stop
- start)/step).
This rule may result in the last element of the result be greater
than stop.

Colin W.

```