Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #100212
| Newsgroups | comp.lang.python |
|---|---|
| Date | 2015-12-09 13:57 -0800 |
| Message-ID | <1628c4a2-c924-4e0c-8baa-322eb5620ff5@googlegroups.com> (permalink) |
| Subject | Is there a data type rule on 'x+=' and 'x0=x+'? |
| From | Robert <rxjwg98@gmail.com> |
Hi,
I have a numpy np.array data x:
x= np.array([[157, 185], [169, 195], [162, 179], [145, 195], [159, 199],
[165, 180], [172, 195], [180, 201], [163, 195], [169, 191]])
Here is the original code snippet:
x+=uniform(-8, 8, x.shape)
x
Out[557]:
array([[163, 192],
[163, 187],
[171, 200],
[165, 186],
[162, 185],
[160, 193],
[156, 194],
[168, 197],
[186, 207],
[184, 208]])
I am curious about the integer data type of result x.
When I use this code:
x0=x+uniform(-8, 8, x.shape)
x0 is a floating format:
x0
Out[555]:
array([[ 150.84633535, 188.93254259],
[ 170.29185044, 197.22753051],
[ 175.65371771, 190.59168953],
[ 159.61401655, 175.06364015],
[ 168.35531363, 180.19243277],
[ 163.79970077, 206.28600694],
[ 157.89342616, 203.39444556],
[ 179.86956647, 192.91265609],
[ 182.48075601, 208.02397713],
[ 187.59332123, 207.41482024]])
I would like to know what rule makes these two different result formats.
Could you help me?
Thanks,
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Is there a data type rule on 'x+=' and 'x0=x+'? Robert <rxjwg98@gmail.com> - 2015-12-09 13:57 -0800 Re: Is there a data type rule on 'x+=' and 'x0=x+'? Steven D'Aprano <steve@pearwood.info> - 2015-12-10 11:25 +1100
csiph-web