Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why was the name "arange" chosen for the numpy function?

Is there a specific reason the numpy function arange was named so?

People habitually make the typo arrange, assuming it is spelled as the English word, so the choice seems like something of an oversight given that other less ambiguously spelled options (range etc) are unused by numpy.

Was it chosen as a portmanteau of array and range?

like image 411
iacob Avatar asked Mar 11 '19 13:03

iacob


2 Answers

NumPy derives from an older python library called Numeric (in fact, the first array object built for python). The arange function dates back to this library, and its etymology is detailed in its manual:

arrayrange()

The arrayrange() function is similar to the range() function in Python, except that it returns an array as opposed to a list.

...

arange() is a shorthand for arrayrange().

  • Numeric Manual
    2001 (p. 18-19), 1999 (p.23)

Tellingly, there is another example with array(range(25)) (p.16), which is functionally the same as arrayrange().

like image 115
iacob Avatar answered Sep 23 '22 00:09

iacob


It is explicitly modelled on the Python range function. The precedent for prefixing a was that in Python 1 there was already a variant of range called xrange.

like image 20
BoarGules Avatar answered Sep 23 '22 00:09

BoarGules