<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Numpy on Noetic Nought</title>
    <link>https://punchagan.muse-amuse.in/tags/numpy/</link>
    <description>Recent content in Numpy on Noetic Nought</description>
    <generator>Hugo</generator>
    <language>en-US</language>
    <copyright>© 2006-2026 CC-BY-SA-4.0</copyright>
    <lastBuildDate>Tue, 15 Jul 2014 18:25:15 -0400</lastBuildDate>
    <atom:link href="https://punchagan.muse-amuse.in/tags/numpy/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Recurse Center, 2014-07-14</title>
      <link>https://punchagan.muse-amuse.in/recurse-center/recurse-center-2014-07-14/</link>
      <pubDate>Tue, 15 Jul 2014 18:25:15 -0400</pubDate>
      <guid>https://punchagan.muse-amuse.in/recurse-center/recurse-center-2014-07-14/</guid>
      <description>&lt;ul&gt;&#xA;&lt;li&gt;Monday morning checkins for our group had only two people. That was strange!&#xA;Very strange!&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;work-on-cinspect&#34;&gt;Work on cinspect&lt;/h2&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;I wrote up a README since David (an alum at Hacker School) showed interest in&#xA;the project.  But, he probably isn&amp;rsquo;t that interested anymore since the code&#xA;base is Python2.x only.&lt;/li&gt;&#xA;&lt;li&gt;I got rid of assumptions that method names would start with the module name&#xA;or the type name, and actually look up references to the names in the&#xA;definitions of types or objects.&lt;/li&gt;&#xA;&lt;li&gt;I also improved the test-suite to actually download sources of CPython and&#xA;index them.  They take very very long!!&lt;/li&gt;&#xA;&lt;li&gt;I tried to get it working with Numpy, but getting all the headers to include&#xA;wasn&amp;rsquo;t as easy as I assumed it would be!&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;</description>
    </item>
    <item>
      <title>Augmented assignment in Python</title>
      <link>https://punchagan.muse-amuse.in/blog/augmented-assignment-in-python/</link>
      <pubDate>Mon, 04 Oct 2010 00:00:00 +0530</pubDate>
      <guid>https://punchagan.muse-amuse.in/blog/augmented-assignment-in-python/</guid>
      <description>&lt;p&gt;If you are new to &lt;code&gt;Python&lt;/code&gt;, you should probably stop reading here.&#xA;But, if you have used &lt;code&gt;Python&lt;/code&gt; and &lt;code&gt;numpy&lt;/code&gt;, then read on. Before, that&#xA;try these bits of code.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kn&#34;&gt;import&lt;/span&gt; &lt;span class=&#34;nn&#34;&gt;numpy&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;a&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;numpy&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;array&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;([&lt;/span&gt;&lt;span class=&#34;mi&#34;&gt;1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;mi&#34;&gt;2&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;])&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;a&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;a&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;+&lt;/span&gt; &lt;span class=&#34;mf&#34;&gt;0.5&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;j&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nb&#34;&gt;print&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;a&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The &amp;ldquo;same thing&amp;rdquo;, in a slightly different way.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kn&#34;&gt;import&lt;/span&gt; &lt;span class=&#34;nn&#34;&gt;numpy&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;a&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;numpy&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;array&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;([&lt;/span&gt;&lt;span class=&#34;mi&#34;&gt;1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;mi&#34;&gt;2&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;])&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;a&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;+=&lt;/span&gt; &lt;span class=&#34;mf&#34;&gt;0.5&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;j&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nb&#34;&gt;print&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;a&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Both the code blocks, look really the same, until you look carefully.&#xA;Under normal circumstances &lt;kbd&gt;a = a + b&lt;/kbd&gt; and &lt;kbd&gt;a += b&lt;/kbd&gt; behave exactly&#xA;similarly, and we really don&amp;rsquo;t need to bother about the differences&#xA;between them.&lt;/p&gt;&#xA;&lt;p&gt;But, &lt;kbd&gt;+=&lt;/kbd&gt;, which is an augmented assignment operator, actually tries&#xA;to perform the operation in-place, unlike the other statement where&#xA;&lt;code&gt;+&lt;/code&gt; actually returns a new object which is again being referenced by&#xA;the name &lt;code&gt;a&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;But, when dealing with &lt;code&gt;numpy&lt;/code&gt; arrays, this will lead to trouble.&#xA;When assigning to an array, it&amp;rsquo;s &lt;code&gt;dtype&lt;/code&gt; is not changed and hence the&#xA;trouble.&lt;/p&gt;&#xA;&lt;p&gt;The right way to use the augmented assignment operator, would be:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kn&#34;&gt;import&lt;/span&gt; &lt;span class=&#34;nn&#34;&gt;numpy&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;a&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;numpy&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;array&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;([&lt;/span&gt;&lt;span class=&#34;mi&#34;&gt;1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt;&lt;span class=&#34;mi&#34;&gt;2&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;],&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;dtype&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;nb&#34;&gt;complex&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;a&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;+=&lt;/span&gt; &lt;span class=&#34;mf&#34;&gt;0.5&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;j&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nb&#34;&gt;print&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;a&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The same thing is explained in this thread.  Also, Thanks to&#xA;Bhanukiran for asking me this.&lt;/p&gt;&#xA;</description>
    </item>
    <item>
      <title>numpy, pacman and me</title>
      <link>https://punchagan.muse-amuse.in/blog/numpy-pacman-and-me/</link>
      <pubDate>Sun, 31 Jan 2010 00:00:00 +0530</pubDate>
      <guid>https://punchagan.muse-amuse.in/blog/numpy-pacman-and-me/</guid>
      <description>&lt;p&gt;I&amp;rsquo;m now officially a part of the Arch Linux community! Arch Linux&#xA;is a lightweight and flexible Linux® distribution that tries to&#xA;Keep It Simple.&lt;/p&gt;&#xA;&lt;p&gt;I have started using arch from less than a week or so. It took me&#xA;a while, not too long, to realize the beauty of this distro. I was&#xA;trying to tweak the settings of my org-mode&amp;rsquo;s remember (on&#xA;Karmic), trying to make it work the way I liked it. After breaking&#xA;my head with .emacs and lisp for a while, I realized the version&#xA;of my org-mode was way different from the version of the docs, I&#xA;was reading. It didn&amp;rsquo;t take long to figure out, which version of&#xA;org-mode to get. As a matter of curiosity, I checked AUR for the&#xA;version, and true to Arch&amp;rsquo;s reputation it was bleeding edge! I was&#xA;still using Karmic, since I hadn&amp;rsquo;t got my Arch installation&#xA;working the way I like it, yet. Out of laziness. sudo reboot; to&#xA;hell with laziness!&lt;/p&gt;&#xA;&lt;p&gt;I was setting up things I regularly use, tweaking my way&#xA;around. After a day or so, I find python-numpy is out of date. And&#xA;to top it, an orphaned package! I didn&amp;rsquo;t feel one bit good about&#xA;this. After some futile attempts to suppress my discomfort, I sat&#xA;down to work.&lt;/p&gt;&#xA;&lt;p&gt;After an afternoon of effort, I created my first PKGBUILD. :) I&#xA;now have python-numpy installed using pacman! Pleasure to join the&#xA;Arch User Community! Also, thanks to lifeeth and Lynus Vaz, for&#xA;the sparks.&lt;/p&gt;&#xA;&lt;p&gt;PS: I&amp;rsquo;m using Arch with Openbox. It&amp;rsquo;s neat! PPS: org-mode is&#xA;really awesome! It&amp;rsquo;s a world in itself. life in plain text,&#xA;truly!]&lt;/p&gt;&#xA;</description>
    </item>
  </channel>
</rss>
