<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by fatal error on Medium]]></title>
        <description><![CDATA[Stories by fatal error on Medium]]></description>
        <link>https://medium.com/@tuguldur.s_38650?source=rss-5aa43fb24d13------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*dmbNkD5D-u45r44go_cf0g.png</url>
            <title>Stories by fatal error on Medium</title>
            <link>https://medium.com/@tuguldur.s_38650?source=rss-5aa43fb24d13------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 19 May 2026 13:10:40 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@tuguldur.s_38650/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com" rel="hub"/>
        <item>
            <title><![CDATA[Pandas profiler]]></title>
            <link>https://medium.com/@tuguldur.s_38650/pandas-profiler-90e5509bda9?source=rss-5aa43fb24d13------2</link>
            <guid isPermaLink="false">https://medium.com/p/90e5509bda9</guid>
            <category><![CDATA[profiler]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[pandas]]></category>
            <dc:creator><![CDATA[fatal error]]></dc:creator>
            <pubDate>Tue, 07 Sep 2021 02:13:56 GMT</pubDate>
            <atom:updated>2021-09-07T02:13:56.739Z</atom:updated>
            <content:encoded><![CDATA[<iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0c03fe3da087c97777bd69424e76c2fa/href">https://medium.com/media/0c03fe3da087c97777bd69424e76c2fa/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=90e5509bda9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Connected Component Labelling]]></title>
            <link>https://medium.com/@tuguldur.s_38650/connected-component-labelling-606a53b3d474?source=rss-5aa43fb24d13------2</link>
            <guid isPermaLink="false">https://medium.com/p/606a53b3d474</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[image-processing]]></category>
            <category><![CDATA[connected-components]]></category>
            <dc:creator><![CDATA[fatal error]]></dc:creator>
            <pubDate>Sun, 05 Sep 2021 00:19:49 GMT</pubDate>
            <atom:updated>2021-09-05T00:19:49.813Z</atom:updated>
            <content:encoded><![CDATA[<p>Create sequential labels in connected components of an input binary image:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*6FlkzRc6rKktbZHu4oUSkQ.png" /></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7148cb37f3d075fd0c568398d60a6dff/href">https://medium.com/media/7148cb37f3d075fd0c568398d60a6dff/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=606a53b3d474" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[truncated file with pydicom]]></title>
            <link>https://medium.com/@tuguldur.s_38650/truncated-file-with-pydicom-8dbe9ef7a473?source=rss-5aa43fb24d13------2</link>
            <guid isPermaLink="false">https://medium.com/p/8dbe9ef7a473</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[pydicom]]></category>
            <dc:creator><![CDATA[fatal error]]></dc:creator>
            <pubDate>Sun, 29 Aug 2021 21:51:39 GMT</pubDate>
            <atom:updated>2021-09-05T00:21:25.604Z</atom:updated>
            <content:encoded><![CDATA[<p>Sometimes the Pillow handler in pydicom willl complain about not being able to read the pixel_array in DICOM images; typically reporting something like:</p><p>OSError: broken data stream when reading image file</p><p>the remedy is to manually change the handler to be able to read truncated files; inside the file pydicom/pixel_data_handlers/pillow_handler.py explicitly set ImageFile to be able to read truncated images, i.e. change from:</p><pre>try:<br>    import PIL<br>    from PIL import Image, features</pre><p>to</p><pre>try:<br>    import PIL<br>    from PIL import Image, features, ImageFile<br>    ImageFile.LOAD_TRUNCATED_IMAGES = True</pre><p>then you’ll get to read the pixel array no matter what, but you’re still fucked if your actual image is corrupt like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*9DQhFIahnxB-alAW-0VWPA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8dbe9ef7a473" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[lru_cache]]></title>
            <link>https://medium.com/@tuguldur.s_38650/lru-cache-73f7ec33965d?source=rss-5aa43fb24d13------2</link>
            <guid isPermaLink="false">https://medium.com/p/73f7ec33965d</guid>
            <category><![CDATA[lru-cache]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[functools]]></category>
            <dc:creator><![CDATA[fatal error]]></dc:creator>
            <pubDate>Sun, 29 Aug 2021 03:49:39 GMT</pubDate>
            <atom:updated>2021-08-29T03:49:39.082Z</atom:updated>
            <content:encoded><![CDATA[<iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d4aecb89b63caa00840a81158f886930/href">https://medium.com/media/d4aecb89b63caa00840a81158f886930/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=73f7ec33965d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CuPy]]></title>
            <link>https://medium.com/@tuguldur.s_38650/cupy-62081e8bcab1?source=rss-5aa43fb24d13------2</link>
            <guid isPermaLink="false">https://medium.com/p/62081e8bcab1</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[numpy]]></category>
            <category><![CDATA[cupy]]></category>
            <category><![CDATA[gpu]]></category>
            <dc:creator><![CDATA[fatal error]]></dc:creator>
            <pubDate>Mon, 23 Aug 2021 03:08:27 GMT</pubDate>
            <atom:updated>2021-08-23T03:08:27.642Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://docs.cupy.dev/en/stable/index.html">CuPy</a> is a GPU array backend that includes some of the most commonly used NumPy (and some SciPy) <a href="https://docs.cupy.dev/en/stable/reference/index.html">functions</a>. Following plot illustrates CuPy acceleration on the creation, and creation plus inversion of symmetric arrays of different sizes:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*Z6Z6VvrORiwjYthE.png" /></figure><p>CuPy has a builtin <a href="https://docs.cupy.dev/en/stable/reference/generated/cupyx.time.repeat.html">experimental profiler</a> (cupyx.time) that can accurately assess the GPU runtime. But for simplicity the benchmark here only measures the elapsed time, and represented by the mean value based on multiple iterations. The overhead of the first invocation is excluded but the transfer to the host is not.</p><p>While this is all impressive, it is worth noting that NumPy inversions can be made faster (a factor of few) by skipping identity matrix recreation (directly call np.linalg.solve) or by directly calling the barebone lapack routine.</p><p>All calculations were performed on a Google Colab instance with:</p><pre>CPU: Intel(R) Xeon(R) @ 2.00GHz<br>GPU_0: Tesla T4<br><br>numpy == 1.19.5<br>cupy == 9.1.0<br>cuda == 11.0.221</pre><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e14e8fabd7c6a2af6240c1699a34a56a/href">https://medium.com/media/e14e8fabd7c6a2af6240c1699a34a56a/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=62081e8bcab1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[gmail through python]]></title>
            <link>https://medium.com/@tuguldur.s_38650/gmail-through-python-ccb0b9a1c2cd?source=rss-5aa43fb24d13------2</link>
            <guid isPermaLink="false">https://medium.com/p/ccb0b9a1c2cd</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[smtp]]></category>
            <category><![CDATA[email]]></category>
            <dc:creator><![CDATA[fatal error]]></dc:creator>
            <pubDate>Mon, 23 Aug 2021 03:04:23 GMT</pubDate>
            <atom:updated>2021-08-23T03:04:23.604Z</atom:updated>
            <content:encoded><![CDATA[<p>Using only <a href="https://docs.python.org/3/library/smtplib.html">smtplib</a> and <a href="https://docs.python.org/3/library/getpass.html">getpass</a> you can send your email from the terminal. Note that your message needs to have a header with at least From/To fields, otherwise the message body alone won’t be recognized as valid. For gmail users you may need to turn on the access for “Less secure app” in your account settings. Since we are using TLS the gmail port should be 587, <a href="https://support.google.com/a/answer/176600?hl=en#zippy=%2Cuse-the-gmail-smtp-server">see here</a>. Finally, note the receiving address(to) is passed as a list in serv.sendmail(); this is in case you have multiple recipients.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/60cce4fd3340710f0e1ceadcf65a0b68/href">https://medium.com/media/60cce4fd3340710f0e1ceadcf65a0b68/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ccb0b9a1c2cd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Shoelace]]></title>
            <link>https://medium.com/@tuguldur.s_38650/shoelace-5d60afcf183f?source=rss-5aa43fb24d13------2</link>
            <guid isPermaLink="false">https://medium.com/p/5d60afcf183f</guid>
            <category><![CDATA[numpy]]></category>
            <category><![CDATA[polygon]]></category>
            <dc:creator><![CDATA[fatal error]]></dc:creator>
            <pubDate>Mon, 23 Aug 2021 03:00:06 GMT</pubDate>
            <atom:updated>2021-08-23T03:00:06.373Z</atom:updated>
            <content:encoded><![CDATA[<p>Say you have a hole-less non intersecting “simple” type polygon with <em>n</em> sides and you want to find its area. There are many ways to do this, typically dividing the polygon into shapes with small number of vertices. But the most elegant solution was proposed centuries ago and now known as the <a href="https://en.wikipedia.org/wiki/Shoelace_formula">Shoelace method</a>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/511/1*BMIC8BgN3F9Q72FQKHR4vw.png" /></figure><p>with <em>x</em> and <em>y</em> being the coordinates of <em>n</em> vertices. If you have the coordinates as one-dimensional arrays x and y, using the numpy.roll() function this can be implemented as a beautiful one-liner:</p><pre>np.abs(np.dot(x, np.roll(y, 1)) - np.dot(y, np.roll(x, 1))) / 2.</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5d60afcf183f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Antipode]]></title>
            <link>https://medium.com/@tuguldur.s_38650/antipode-f9dab7f181af?source=rss-5aa43fb24d13------2</link>
            <guid isPermaLink="false">https://medium.com/p/f9dab7f181af</guid>
            <category><![CDATA[shapely]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[geopandas]]></category>
            <dc:creator><![CDATA[fatal error]]></dc:creator>
            <pubDate>Mon, 23 Aug 2021 02:55:31 GMT</pubDate>
            <atom:updated>2021-08-23T02:55:31.185Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://en.wikipedia.org/wiki/Antipodal_point">Antipodes of a sphere</a> are pairs of points separated by the diameter, i.e. for the Earth, you can reach the antipode of your location by drilling through the center all the way. Suppose you’re standing somewhere on land (about 30% of the Earth surface area) and you wanna know the probability for you to end up on land on the other side? Following script approximates this using maps generated through geopandas package.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*A7ri3SFSbHKBUpZP.png" /></figure><p>The plain map depicting just land and water is obtained through the ‘naturalearth_lowres’ dataset (don’t think I saw one for coastline). It returns boundaries for each country, but it can be suppressed by assigning the same color to both color and edgecolor for each polygon. Since it would be easiest to get the final fraction by counting pixel intensities in a 2/3D image array, we would need to produce the image arrays based on an equal-area projection (like Mollweide).</p><p>While creating different projections is easy in geopandas, I couldn’t find a reliable way of shifting the center of a projection only except in Mercator. And so my work-around was to shift the projection first in Mercator for a given angle, and then re-project in Mollweide. Here I note that when assembling a dataframe from scratch its coordinate reference system (crs) has to be explicitly assigned, especially if you later wish to re-project in a different system (Mercator=’EPSG:4326’, Mollweide=’ESRI:54009’).</p><p>Also I couldn’t find a way to directly export plotted geopandas objects into a 2/3D array. My workaround was to literally save the plot without any padding and re-read the image as numpy array. We lose the native coordinates, but it doesn’t matter for our case since we will be just counting pixels by their intensities.</p><p>Overall, the script creates two Mollweide projections where one of them is shifted by 180 degrees and co-axially flipped. Each projection is ultimately represented as a grayscale 2D array with land and water having uniform intensities of 0.5 and 0 respectively. When these are added together, the combined image will have pixel values of 1 wherever antipodal points both occur on land. Running the script gives:</p><p>probability of antipode being on land: 0.150</p><p>and according to <a href="https://en.wikipedia.org/wiki/Antipodes">wiki</a> it is indeed 15%; in short, it is the consequence of most of the land mass being clumped in one hemisphere.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7d4dd0a6e0b8b4e5561b6e694c625e36/href">https://medium.com/media/7d4dd0a6e0b8b4e5561b6e694c625e36/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f9dab7f181af" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Simple Function Fitting With Keras]]></title>
            <link>https://medium.com/@tuguldur.s_38650/simple-function-fitting-with-keras-b1bfee829cb4?source=rss-5aa43fb24d13------2</link>
            <guid isPermaLink="false">https://medium.com/p/b1bfee829cb4</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[keras]]></category>
            <dc:creator><![CDATA[fatal error]]></dc:creator>
            <pubDate>Sun, 22 Aug 2021 21:51:58 GMT</pubDate>
            <atom:updated>2021-08-22T21:51:58.552Z</atom:updated>
            <content:encoded><![CDATA[<iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3307e0f4e1c9d923d7fe5970cab4bf04/href">https://medium.com/media/3307e0f4e1c9d923d7fe5970cab4bf04/href</a></iframe><p>MSE = 0.00010</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/398/1*OIObXNQSkgAsYEfPOE3iHg.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b1bfee829cb4" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>