Peter Stewart
Peter Stewart

Reputation: 3017

Passing numpy.arange() an argument

I'm trying to pass the values that I want numpy.arange to use.

The code is:

for x in numpy.arange(argument)

where argument is:

argument = (.1,6.3,.1) (tuple)

TypeError: arange: scaler arguements expected instead of a tuple

arguement = [.1,6.3,.1] (list)

TypeError: unsupported operand type(s) for -: 'str' and 'int'

arguement = '.1,6.3,.1' (string)

TypeError: unsupported operand type(s) for -: 'str' and 'int'

and I've tried putting the tuple and list in a string. None of these have worked.

I've searched the literature and can find no reference to this.

Any insights would be appreciated.

Upvotes: 0

Views: 4792

Answers (1)

kenm
kenm

Reputation: 23975

arange is like python's range function.

Perhaps you were looking for numpy.array?

Or maybe you really did want the range to be from 0.1 to 6.3 in steps of 0.1. In that case, use Python's argument unpacking syntax:

arguments = (.1, 6.3, .1)
numpy.arange(*arguments)

Upvotes: 3

Related Questions