numpy – Python cant multiply sequence by non-int of type float

numpy – Python cant multiply sequence by non-int of type float

Change:

buf=pow(-(alpha*[D/Ds]),beta)

to:

buf=pow(-(alpha*(D/Ds)),beta)

This:

[D/Ds]

gives you list with one element.

But this:

alpha * (D/Ds)

computes the divisions before the multiplication with alpha.

You can multiply a list by an integer:

>>> [1] * 4
[1, 1, 1, 1]

but not by a float:

[1] * 4.0
TypeError: cant multiply sequence by non-int of type float

since you cannot have partial elements in a list.

Parenthesis can be used for grouping in the mathematical calculations:

>>> (1 + 2) * 4
12

numpy – Python cant multiply sequence by non-int of type float

Leave a Reply

Your email address will not be published.