[Numpy-discussion] How-to: Uniform vector scale
Christopher Barker
Chris.Barker@noaa....
Wed Sep 5 15:22:29 CDT 2007
Robert Dailey wrote:
> The
> interpreter outputs:
> "ValueError: shape mismatch: objects cannot be broadcast to a single
> shape"
You need to post your actually input and output. The above works fine
for me, just as you'd expect:
>>> A = N.array([2,3,4])
>>> B = N.array([5,6,7])
>>> S = 5
>>> A+B*S
array([27, 33, 39])
# I like to be explicit about order of operations, though:
>>> A+(B*S)
array([27, 33, 39])
-Chris
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker@noaa.gov
More information about the Numpy-discussion
mailing list