Re: [Numpy-discussion] Distance Matrix speed
Hi, def d4(): d = zeros([4, 1000], dtype=float) for i in range(4): xy = A[i] - B d[i] = sqrt( sum(xy**2, axis=1) ) return d Maybe there's another alternative to d4? Thanks again, I think this is the fastest you can get. Maybe it would be nicer to use the .sum() method instead of sum function, but that is just my personal opinion. I am curious how this compares to the matlab version. :) Johannes ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
[Numpy-discussion] Recarray attributes writeable
Hi everyone - Recarrays have convenience attributes such that fields may be accessed through . in additioin to the field() method. These attributes are designed for read only; one cannot alter the data through them. Yet they are writeable: tr=numpy.recarray(10, formats='i4,f8,f8', names='id,ra,dec') tr.field('ra')[:] = 0.0 tr.ra array([ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]) tr.ra = 3 tr.ra 3 tr.field('ra') array([ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]) I feel this should raise an exception, just as with trying to write to the size attribute. Any thoughts? Erin ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
[Numpy-discussion] Recarray attributes writable
Hi everyone - Recarrays have convenience attributes such that fields may be accessed through . in additioin to the field() method. These attributes are designed for read only; one cannot alter the data through them. Yet they are writeable: tr=numpy.recarray(10, formats='i4,f8,f8', names='id,ra,dec') tr.field('ra')[:] = 0.0 tr.ra array([ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]) tr.ra = 3 tr.ra 3 tr.field('ra') array([ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]) I feel this should raise an exception, just as with trying to write to the size attribute. Any thoughts? Erin ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Re: [Numpy-discussion] Recarray attributes writeable
El dv 16 de 06 del 2006 a les 14:46 -0700, en/na Andrew Straw va escriure: Erin Sheldon wrote: Anyway - Recarrays have convenience attributes such that fields may be accessed through . in additioin to the field() method. These attributes are designed for read only; one cannot alter the data through them. Yet they are writeable: tr=numpy.recarray(10, formats='i4,f8,f8', names='id,ra,dec') tr.field('ra')[:] = 0.0 tr.ra array([ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]) tr.ra = 3 tr.ra 3 tr.field('ra') array([ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]) I feel this should raise an exception, just as with trying to write to the size attribute. Any thoughts? I have not used recarrays much, so take this with the appropriate measure of salt. I'd prefer to drop the entire pseudo-attribute thing completely before it gets entrenched. (Perhaps it's too late.) However, I think that this has its utility, specially when accessing to nested fields (see later). In addition, I'd suggest introducing a special accessor called, say, 'fields' in order to access the fields themselves and not the attributes. For example, if you want to access the 'strides' attribute, you can do it in the usual way: import numpy tr=numpy.recarray(10, formats='i4,f8,f8', names='id,ra,strides') tr.strides (20,) but, if you want to access *field* 'strides' you could do it by issuing: tr.fields.strides repr of field accessor object (shape, type...) tr.fields.strides[:] array([ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]) We have several advantages in adopting the previous approach: 1. You don't mix (nor pollute) the namespaces for attributes and fields. 2. You have a clear idea when you are accessing a variable or a field. 3. Accessing nested columns would still be very easy: tr.field('nested1').field('nested2').field('nested3') vs tr.fields.nested1.nested2.nested3 4. You can also define a proper __getitem__ for accessing fields: tr.fields['nested1']['nested2']['nested3']. In the same way, elements of 'nested2' field could be accessed by: tr.fields['nested1']['nested2'][2:10:2]. 5. Finally, you can even prevent setting or deleting columns by disabling the __setattr__ and __delattr__. PyTables has adopted a similar schema for accessing nested columns, except for 4, where we decided not to accept both strings and slices for the __getitem__() method (you know the mantra: there should preferably be just one way of doing things, although maybe we've been a bit too much strict in this case), and I think it works reasonably well. In any case, the idea is to decouple the attributes and fields so that they doesn't get mixed. Implementing this shouldn't be complicated at all, but I'm afraid that I can't do this right now :-( -- 0,0 Francesc Altet http://www.carabos.com/ V V Cárabos Coop. V. Enjoy Data - ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Re: [Numpy-discussion] Recarray attributes writeable
On 6/17/06, Francesc Altet [EMAIL PROTECTED] wrote: However, I think that this has its utility, specially when accessing to nested fields (see later). In addition, I'd suggest introducing a special accessor called, say, 'fields' in order to access the fields themselves and not the attributes. For example, if you want to access the 'strides' attribute, you can do it in the usual way: import numpy tr=numpy.recarray(10, formats='i4,f8,f8', names='id,ra,strides') tr.strides (20,) but, if you want to access *field* 'strides' you could do it by issuing: tr.fields.strides repr of field accessor object (shape, type...) tr.fields.strides[:] array([ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]) [...] +1 I meant to write exactly the same thing, but was too lazy to do it :) Cheers, f ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Re: [Numpy-discussion] Distance Matrix speed
How about this? def d5(): return add.outer(sum(A*A, axis=1), sum(B*B, axis=1)) - \ 2.*dot(A, transpose(B)) ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Re: [Numpy-discussion] Distance Matrix speed
Alex Cannon wrote: How about this? def d5(): return add.outer(sum(A*A, axis=1), sum(B*B, axis=1)) - \ 2.*dot(A, transpose(B)) You might lose some precision with that approach, so the OP should compare results and timings to look at the tradeoffs. -- Robert Kern I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth. -- Umberto Eco ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Re: [Numpy-discussion] Recarray attributes writeable
This reply sent 9:36 AM, Jun 17 (because it may not show up for a day or so from my gmail account, if it shows up at all) On 6/17/06, Francesc Altet [EMAIL PROTECTED] wrote: El dv 16 de 06 del 2006 a les 14:46 -0700, en/na Andrew Straw va escriure: Erin Sheldon wrote: Anyway - Recarrays have convenience attributes such that fields may be accessed through . in additioin to the field() method. These attributes are designed for read only; one cannot alter the data through them. Yet they are writeable: tr=numpy.recarray(10, formats='i4,f8,f8', names='id,ra,dec') tr.field('ra')[:] = 0.0 tr.ra array([ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]) tr.ra = 3 tr.ra 3 tr.field('ra') array([ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]) I feel this should raise an exception, just as with trying to write to the size attribute. Any thoughts? I have not used recarrays much, so take this with the appropriate measure of salt. I'd prefer to drop the entire pseudo-attribute thing completely before it gets entrenched. (Perhaps it's too late.) I think that initially I would concur to drop them. I am new to numpy, however, so they are not entrenched for me. Anyway, see below. However, I think that this has its utility, specially when accessing to nested fields (see later). In addition, I'd suggest introducing a special accessor called, say, 'fields' in order to access the fields themselves and not the attributes. For example, if you want to access the 'strides' attribute, you can do it in the usual way: import numpy tr=numpy.recarray(10, formats='i4,f8,f8', names='id,ra,strides') tr.strides (20,) but, if you want to access *field* 'strides' you could do it by issuing: tr.fields.strides repr of field accessor object (shape, type...) tr.fields.strides[:] array([ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]) We have several advantages in adopting the previous approach: 1. You don't mix (nor pollute) the namespaces for attributes and fields. 2. You have a clear idea when you are accessing a variable or a field. 3. Accessing nested columns would still be very easy: tr.field('nested1').field('nested2').field('nested3') vs tr.fields.nested1.nested2.nested3 4. You can also define a proper __getitem__ for accessing fields: tr.fields['nested1']['nested2']['nested3']. In the same way, elements of 'nested2' field could be accessed by: tr.fields['nested1']['nested2'][2:10:2]. 5. Finally, you can even prevent setting or deleting columns by disabling the __setattr__ and __delattr__. This is interesting, and I would add a 6th to this: 6. The .fields by itself could return the names of the fields, which are currently not accessible in any simple way. I always think that these should be methods (.fields(),.size(), etc) but if we are going down the attribute route, this might be a simple fix. PyTables has adopted a similar schema for accessing nested columns, except for 4, where we decided not to accept both strings and slices for the __getitem__() method (you know the mantra: there should preferably be just one way of doing things, although maybe we've been a bit too much strict in this case), and I think it works reasonably well. In any case, the idea is to decouple the attributes and fields so that they doesn't get mixed. Strings or fieldnum access greatly improves the scriptability, but this can always be done through the .field() access. Erin ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Re: [Numpy-discussion] (no subject)
やっぱり出会うならエッチな人の方がいいよね♪沢山の女の子とハメて気持ちよく春を過ごそう♪ http://love-match.bz/pc/?07 出会いの定番! 無料で女性をご紹介!安心して出会えるチャンス到来!とりあえず出会ってみて下さい♪ http://love-match.bz/pc/?07 広東省茂名市人民大街3-6-4-533 友誼網絡公司 139-3668-7892 ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Re: [Numpy-discussion] (no subject)
:―― INFORMATION ―: 不正・悪質なサイトを一切排除しておりますので 安心してご利用ください。 http://love-match.bz/pc/?09 :――: *・゜゜・*:.。. .。.:*・゜゜・*:.。..。:*・゜゜・*:.。..。:**・゜゜・* お金と時間を持て余している人妻の間で、噂になってるあのサイト [登録・利用料全て無料] http://love-match.bz/pc/?09 ━━━ □■ 不倫・ワリキリ専門の無料出会いサイト『Love☆Match』 - 登録料・利用料 ・【無料】 メールの送受信 ・【無料】 ユーザーの検索 ・【無料】 掲示板の閲覧・書込み ・・【無料】 画像交換・アップロード ・【無料】 アドレス交換・電話番号交換 ・・・【無料】 - どれだけ使っても全て無料! http://love-match.bz/pc/?09 ━━━ □■ いつでも女性ユーザーがいっぱい。その理由は? - PC&モバイルに対応!いつでもどこでも気軽に楽しめる! - 仕事中は携帯電話から、プライベートは自宅からのんびりと。 気になる相手といつでも繋がっているから、新密度も急速にUP。 http://love-match.bz/pc/?09 - PCから簡単プロフィール作成。ネット初心者でもラクラク参加OK - 面倒な登録は一切不要。パソコンから簡単なプロフィールを作成して 初心者の方や女性でもすぐに参加できます。 http://love-match.bz/pc/?09 - 自由恋愛対応!直電・直メ交換支援ツール - 基本的にメールアドレスや電話番号は非公開ですが 仲良くなった人だけにメールアドレスや電話番号を教える事ができます。 http://love-match.bz/pc/?09 - 写真アップロードに対応!好みの相手を素早くCHECK! - 待ち合わせ場所にイメージとまったく違う人が来たら…。 ピュアックスなら会う前に写真交換ができるから、そんな不安も解消。 http://love-match.bz/pc/?09 - スレッド掲示板で秘密のパートナー検索も効率UP! - メインの掲示板のほかにスレッド型の掲示板を設置。 メル友から秘密のパートナーまで目的別のユーザーが集う掲示板です。 http://love-match.bz/pc/?09 ━━━ □■ 毎日500人近くのユーザーが続々参加中!! □- リエ(21歳/会社員) いつも1人でエッチなことを考えてます。 メールだといろいろ話せるんだけど、実際に会うとあまりしゃべれなく なっちゃうので、盛り上げてくれるような楽しい男の人いないかな? 引っ込み思案のせいか、男性経験はあまり無いんです。 優しく&楽しくリードしてくれる男性からのメール待ってます。 [写真有り] http://love-match.bz/pc/?09 □- 真菜(24歳/フリーター) 彼氏が浮気してて超アタマきたっ!まなだって遊びたい盛りだし、ずっと ガマンしてたのにさ!かっこいい人見つけて思いっきりふってやるつもりで 登録してみた(笑) [写真有り] http://love-match.bz/pc/?09 □- みさ(34歳/専業主婦) 殆ど家に帰ってこない仕事人間のだんなさまと二人きりの毎日で、ほんと 寂しい思いをしています。年下の男の子がいれば仲良くなりたいな。 年下の人とは付き合ったことがないので興味津々です(^^) [写真無し] http://love-match.bz/pc/?09 □- 恭子(28歳/会社員) 彼氏とはいつも同じようなセックスばかりでかなり冷め気味です。 誰かあたしと熱いセックスを楽しみませんか?めんどくさい事は 言いません。ただ、いつもと違うドキドキするような事がしたい だけなんです。 [写真無し] http://love-match.bz/pc/?09 □- ななこ(28歳/主婦) 半年前にだんなと別れて今は×1です。 夜のお仕事なので、昼間まったりと過ごしませんか? 心身ともに疲れ気味で、今、激しく癒されたいです。 [写真有り] http://love-match.bz/pc/?09 □- 祥子(31歳/クリエイター) 平日は18時くらいまでは大体仕事してるので、その後に食事したり 楽しく飲んだりできるパートナー希望です。年上でも年下でも かまいませんので気軽にメールを送って頂けると嬉しいです。 [写真有り] http://love-match.bz/pc/?09 □- ゅヵ`(20歳/学生) まずゎ会ってみないとはじまらなぃょね?! 横浜近辺の人で、いろんな意味でオトナな人は プロフ付きでめぇる送って☆ [写真有り] http://love-match.bz/pc/?09 □- 出会いサイトのサクラに騙されないように↓ ┏━━━┓ 【裏】無料の出会い情報 - お金と時間を持て余している人妻の間で、噂になってるあのサイト [登録・利用料全て無料] http://love-match.bz/pc/?09 - 彼女達が求めているのはこんな男性です。 ?年上女性にリードしてもらいたい、経験少なめの男性 ?体力・テクニックに自信が有る男性 男性会員が不足しています。我こそは、と思う方は今すぐ参加! [登録・利用料全て無料] http://love-match.bz/pc/?09 ┗━━━┛ 広東省茂名市人民大街3-6-4-533 友誼網絡公司 139-3668-7892 ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion