<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
 
 <title>Juan Reyero</title>
 <link href="http://juanreyero.com/blog/atom.xml" rel="self"/>
 <link href="http://juanreyero.com/blog/"/>
 <updated>2013-10-27T19:24:25+01:00</updated>
 <author>
   <name>Juan Reyero</name>
   <email>juan@juanreyero.com</email>
 </author>
 
 
 <entry>
   <title>Side effects in Python</title>
   <link href="http://juanreyero.com/blog/2011/12/14/side-effects-in-python"/>
   <updated>2011-12-14T00:00:00+01:00</updated>
   <id>id:/blog/2011/12/14/side-effects-in-python</id>
   <content type="html">&lt;p&gt;
On side effects in Python, and how easy it is to get off the right track.  Full article, &lt;a href=&quot;http://juanreyero.com/article/python/side-effects.html&quot;&gt;Side effects in Python&lt;/a&gt;.
&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;
I've just spent way too much time hunting down a bug that was hiding in a function very much like this one. It was part of a class that generated binary files to be read and processed from a C program, and I was naturally inclined to search for the cause of the problems in the C code.  Wrong.
&lt;/p&gt;
&lt;/blockquote&gt;
</content>
 </entry>
 
 <entry>
   <title>New article --- The wasted talent in the meeting room</title>
   <link href="http://juanreyero.com/blog/2011/12/10/new-article-----the-wasted-talent-in-the-meeting-room"/>
   <updated>2011-12-10T00:00:00+01:00</updated>
   <id>id:/blog/2011/12/10/new-article-----the-wasted-talent-in-the-meeting-room</id>
   <content type="html">&lt;p&gt;
How learning about how the brain works would improve the way meetings are held.  The full article: &lt;a href=&quot;http://juanreyero.com/article/technology/meetings.html&quot;&gt;The wasted talent in the meeting room&lt;/a&gt;.
&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;
Meetings are a topic close to my heart. I have spent a large part of my professional career in them, and I must acknowledge that not all this time has been all that productive.
&lt;/p&gt;

&lt;p&gt;
I started to keep an eye on other ways to merge people's ideas ever since I realized the inescapable fact that a large part of my corporate life would be spent sitting in meeting rooms listening to people talk to each other.
&lt;/p&gt;
&lt;/blockquote&gt;
</content>
 </entry>
 
 <entry>
   <title>Dates in Python are what they were meant to be</title>
   <link href="http://juanreyero.com/blog/2011/12/06/dates-in-python-are-what-they-were-meant-to-be"/>
   <updated>2011-12-06T00:00:00+01:00</updated>
   <id>id:/blog/2011/12/06/dates-in-python-are-what-they-were-meant-to-be</id>
   <content type="html">&lt;p&gt;
Full article: &lt;a href=&quot;http://juanreyero.com/article/python/python-dates.html&quot;&gt;Dates in Python are what dates were meant to be&lt;/a&gt;.
&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;
I shouldn't find it surprising by now, but I do.  Every time I have to do something potentially non-trivial with Python I have this wornderful feeling that this is how things were meant to be.
&lt;/p&gt;

&lt;p&gt;
This afternoon I was trying to figure out where my money goes.  I use Python to do that, of course.  I wrote a short program that parses the data coming from the bank in CSV format, bins the expenses in categories, and outputs average values separating core and non-essential expenses.
&lt;/p&gt;

&lt;p&gt;
I had a date string field in the data, but up to now I had not bothered to parse it.  Today, however, I wanted to filter out entries older than given a number of months.  It turned out to be reassuringly simple.
&lt;/p&gt;
&lt;/blockquote&gt;
</content>
 </entry>
 
 <entry>
   <title>Playing with convolutions in Python</title>
   <link href="http://juanreyero.com/blog/2011/12/04/playing-with-convolutions-in-python"/>
   <updated>2011-12-04T00:00:00+01:00</updated>
   <id>id:/blog/2011/12/04/playing-with-convolutions-in-python</id>
   <content type="html">&lt;p&gt;
Read the full article, &lt;a href=&quot;http://juanreyero.com/article/python/python-convolution.html&quot;&gt;Playing with convolutions in Python&lt;/a&gt;.  It includes a short introduction to convolutions, and fully worked out examples of how to use Python to play with convolutions.  The code, for those of you in a hurry, looks like this:
&lt;/p&gt;

&lt;div class=&quot;org-src-container&quot;&gt;

&lt;pre class=&quot;src src-python&quot;&gt;&lt;span class=&quot;org-keyword&quot;&gt;from&lt;/span&gt; PIL &lt;span class=&quot;org-keyword&quot;&gt;import&lt;/span&gt; Image
&lt;span class=&quot;org-keyword&quot;&gt;import&lt;/span&gt; numpy &lt;span class=&quot;org-keyword&quot;&gt;as&lt;/span&gt; np
&lt;span class=&quot;org-keyword&quot;&gt;from&lt;/span&gt; scipy &lt;span class=&quot;org-keyword&quot;&gt;import&lt;/span&gt; signal &lt;span class=&quot;org-keyword&quot;&gt;as&lt;/span&gt; sg

&lt;span class=&quot;org-keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;org-function-name&quot;&gt;np_from_img&lt;/span&gt;(fname):
    &lt;span class=&quot;org-keyword&quot;&gt;return&lt;/span&gt; np.asarray(Image.open(fname), dtype=np.float32)

&lt;span class=&quot;org-keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;org-function-name&quot;&gt;save_as_img&lt;/span&gt;(ar, fname):
    Image.fromarray(ar.round().astype(np.uint8)).save(fname)

&lt;span class=&quot;org-keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;org-function-name&quot;&gt;norm&lt;/span&gt;(ar):
    &lt;span class=&quot;org-keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;org-py-number&quot;&gt;255&lt;/span&gt;.*np.absolute(ar)/np.max(ar)

save_as_img(norm(sg.convolve(img, [[&lt;span class=&quot;org-py-number&quot;&gt;1&lt;/span&gt;.],
                                   [-&lt;span class=&quot;org-py-number&quot;&gt;1&lt;/span&gt;.]])),
            &lt;span class=&quot;org-string&quot;&gt;'img/portal-h.png'&lt;/span&gt;)
save_as_img(norm(sg.convolve(img, [[&lt;span class=&quot;org-py-number&quot;&gt;1&lt;/span&gt;., -&lt;span class=&quot;org-py-number&quot;&gt;1&lt;/span&gt;.]])),
            &lt;span class=&quot;org-string&quot;&gt;'img/portal-v.png'&lt;/span&gt;)

&lt;span class=&quot;org-keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;org-function-name&quot;&gt;common_size&lt;/span&gt;(&lt;span class=&quot;org-py-number&quot;&gt;a1&lt;/span&gt;, &lt;span class=&quot;org-py-number&quot;&gt;a2&lt;/span&gt;):
    &lt;span class=&quot;org-string&quot;&gt;&quot;&quot;&quot;Chop-off the first rows and cols from the two numpy arrays a1&lt;/span&gt;
&lt;span class=&quot;org-string&quot;&gt;    and a2 so that they end up having the same size.&lt;/span&gt;
&lt;span class=&quot;org-string&quot;&gt;    &amp;gt;&amp;gt;&amp;gt; print common_size(np.array([[0, 0],&lt;/span&gt;
&lt;span class=&quot;org-string&quot;&gt;    ...                             [1, 2],&lt;/span&gt;
&lt;span class=&quot;org-string&quot;&gt;    ...                             [3, 4]]),&lt;/span&gt;
&lt;span class=&quot;org-string&quot;&gt;    ...                   np.array([[0, 5, 6],&lt;/span&gt;
&lt;span class=&quot;org-string&quot;&gt;    ...                             [0, 7, 8]]))&lt;/span&gt;
&lt;span class=&quot;org-string&quot;&gt;    (array([[1, 2],&lt;/span&gt;
&lt;span class=&quot;org-string&quot;&gt;           [3, 4]]), array([[5, 6],&lt;/span&gt;
&lt;span class=&quot;org-string&quot;&gt;           [7, 8]]))&lt;/span&gt;
&lt;span class=&quot;org-string&quot;&gt;    &quot;&quot;&quot;&lt;/span&gt;
    (r1, &lt;span class=&quot;org-py-number&quot;&gt;c1&lt;/span&gt;) = &lt;span class=&quot;org-py-number&quot;&gt;a1&lt;/span&gt;.shape
    (r2, &lt;span class=&quot;org-py-number&quot;&gt;c2&lt;/span&gt;) = &lt;span class=&quot;org-py-number&quot;&gt;a2&lt;/span&gt;.shape
    &lt;span class=&quot;org-keyword&quot;&gt;return&lt;/span&gt; (&lt;span class=&quot;org-py-number&quot;&gt;a1&lt;/span&gt;[r1-r2 &lt;span class=&quot;org-keyword&quot;&gt;if&lt;/span&gt; r1&amp;gt;r2 &lt;span class=&quot;org-keyword&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;org-py-number&quot;&gt;0&lt;/span&gt;:,
               &lt;span class=&quot;org-py-number&quot;&gt;c1&lt;/span&gt;-&lt;span class=&quot;org-py-number&quot;&gt;c2&lt;/span&gt; &lt;span class=&quot;org-keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;org-py-number&quot;&gt;c1&lt;/span&gt;&amp;gt;&lt;span class=&quot;org-py-number&quot;&gt;c2&lt;/span&gt; &lt;span class=&quot;org-keyword&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;org-py-number&quot;&gt;0&lt;/span&gt;:],
            &lt;span class=&quot;org-py-number&quot;&gt;a2&lt;/span&gt;[r2-r1 &lt;span class=&quot;org-keyword&quot;&gt;if&lt;/span&gt; r2&amp;gt;r1 &lt;span class=&quot;org-keyword&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;org-py-number&quot;&gt;0&lt;/span&gt;::,
               &lt;span class=&quot;org-py-number&quot;&gt;c2&lt;/span&gt;-&lt;span class=&quot;org-py-number&quot;&gt;c1&lt;/span&gt; &lt;span class=&quot;org-keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;org-py-number&quot;&gt;c2&lt;/span&gt;&amp;gt;&lt;span class=&quot;org-py-number&quot;&gt;c1&lt;/span&gt; &lt;span class=&quot;org-keyword&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;org-py-number&quot;&gt;0&lt;/span&gt;:])

&lt;span class=&quot;org-keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;org-function-name&quot;&gt;gradient&lt;/span&gt;(im):
    &lt;span class=&quot;org-py-variable-name&quot;&gt;imv&lt;/span&gt;, &lt;span class=&quot;org-py-variable-name&quot;&gt;imh&lt;/span&gt; = common_size(sg.convolve(im, [[&lt;span class=&quot;org-py-number&quot;&gt;1&lt;/span&gt;., -&lt;span class=&quot;org-py-number&quot;&gt;1&lt;/span&gt;.]]),
                           sg.convolve(im, [[&lt;span class=&quot;org-py-number&quot;&gt;1&lt;/span&gt;.], [-&lt;span class=&quot;org-py-number&quot;&gt;1&lt;/span&gt;.]]))
    &lt;span class=&quot;org-keyword&quot;&gt;return&lt;/span&gt; np.sqrt(np.power(imv, &lt;span class=&quot;org-py-number&quot;&gt;2&lt;/span&gt;)+np.power(imh, &lt;span class=&quot;org-py-number&quot;&gt;2&lt;/span&gt;))
&lt;/pre&gt;
&lt;/div&gt;
</content>
 </entry>
 
 <entry>
   <title>Why you should be hacking your work environment</title>
   <link href="http://juanreyero.com/blog/2011/11/30/why-you-should-be-hacking-your-work-environment"/>
   <updated>2011-11-30T00:00:00+01:00</updated>
   <id>id:/blog/2011/11/30/why-you-should-be-hacking-your-work-environment</id>
   <content type="html">&lt;p&gt;
The full article, &lt;a href=&quot;http://juanreyero.com/article/technology/talisman.html&quot;&gt;ideas on hacking your work environment&lt;/a&gt;.
&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;
It works in two directions: what you perceive influences how you act, and what you do changes how you see and feel. Both happen in ways that are not obvious, unconscious, repeatable and —once you've figured them out— predictable.
&lt;/p&gt;

&lt;p&gt;
And, as I am the kind of animal to which the above happens, I have a strong interest in learning how my environment might be shaping my actions. My hypothesis is that my working environment impacts in the quality of my work and my well-being in non-obvious ways, and that I can improve both by changing my surroundings.
&lt;/p&gt;
&lt;/blockquote&gt;
</content>
 </entry>
 
 
</feed>
