{"id":817,"date":"2018-06-30T21:17:14","date_gmt":"2018-06-30T19:17:14","guid":{"rendered":"https:\/\/aerospaceresearch.net\/?p=817"},"modified":"2018-07-04T20:10:03","modified_gmt":"2018-07-04T18:10:03","slug":"gsoc18vismashantanu-week-06-07-finding-the-unknown","status":"publish","type":"post","link":"https:\/\/aerospaceresearch.net\/?p=817","title":{"rendered":"[GSoC&#8217;18|VisMa|Shantanu] Week #06-07: Finding the Unknown"},"content":{"rendered":"<p>This is GSoC&#8217;18 log#03. Here I will cover on what I have done in week#06-07. Link to the <a href=\"https:\/\/aerospaceresearch.net\/?p=766\">previous log<\/a>.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-706\" src=\"https:\/\/aerospaceresearch.net\/wp-content\/uploads\/2018\/05\/vismabanner.jpg\" alt=\"\" width=\"1280\" height=\"800\" \/><\/p>\n<h2>Done so far&#8230;<\/h2>\n<p>I have implemented a simple solver which is capable of solving a given variable in terms of other variables and numbers. Below is a simple example of how the solver works.<\/p>\n<p><!--more--><\/p>\n<pre>x^2*y - z = 1            # solving for x\r\nx^2y - z - 1 = 0         # simplified and moved to LHS\r\nx^2y = z + 1             # all functions not containing x moved to RHS\r\nx^2 = (z + 1)\/y          # inverse method is called\r\nx = ((z + 1)\/y)^0.5      # final result<\/pre>\n<p>To make the solver some features like expression operations were required.<br \/>\nAlso, support for nested expressions has been added. So when operating with expressions the operations will be worked out from inside-out.<\/p>\n<p>While I was working on expressions, I missed a few trivial test cases. Since the number of functions\/operations are increasing the number of test cases is increasing.<\/p>\n<p>Hence I decided to automate testing using unit-test. Since this topic was new to me, I tried using various tests available to find which was best suited for <strong>visma<\/strong>. I started using <strong>doctest<\/strong> but later moved on to <strong>pytest<\/strong>\u00a0for its number of features. Writing a test through pytest is as simple as:-<\/p>\n<pre>from visma.utils.integers import gcd\r\n\r\ndef test_gcd(): # simple test for gcd\r\n    assert gcd([1]) == 1\r\n    assert gcd([3, 6, 12, 24]) == 3\r\n<\/pre>\n<p>While working on these I learned a lot about unit-tests and code-coverage. I used <strong>coverage.py<\/strong> through <strong>pytest<\/strong>\u00a0to measure code-coverage. It helps to know which part of the code is being neglected and helps find missing test cases.<\/p>\n<p>I fiddled a little with the stylesheets in PyQt4 and made the GUI a little cleaner. Below is the solver in action.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-821\" src=\"https:\/\/aerospaceresearch.net\/wp-content\/uploads\/2018\/06\/vismademo3.gif\" alt=\"\" width=\"1199\" height=\"825\" \/><\/p>\n<h2>What I will be doing next&#8230;<\/h2>\n<p>Since the solver for single equation has been implemented, the next thing will be to extend it to solve multiple equations at once. A variable substitution method will be written which will substitute a variable from one equation to the other equation.<\/p>\n<p>Also for multi-variable linear equations, matrix modules will be created and <em>Gauss-Jordan elimination<\/em> will be used for solving these. The solver will also be modified to support inequality solving.<\/p>\n<p>Since I have just initialized testing using pytest, there are many test cases left to be written. Tests for specifically each module will be created.<\/p>\n<p>Link to <a href=\"https:\/\/github.com\/8hantanu\/VisMa\">project source<\/a> and <a href=\"https:\/\/github.com\/aerospaceresearch\/visma\/projects\/1\">to-do board<\/a>. Read on <a href=\"https:\/\/8hantanu.github.io\/gsoc\/2018\/06\/30\/gsoc-log03-finding-the-unknown.html\">my blog<\/a>.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is GSoC&#8217;18 log#03. Here I will cover on what I have done in week#06-07. Link to the previous log. Done so far&#8230; I have implemented a simple solver which is capable of solving a given variable in terms of other variables and numbers. Below is a simple example of how the solver works.<\/p>\n","protected":false},"author":14,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/aerospaceresearch.net\/index.php?rest_route=\/wp\/v2\/posts\/817"}],"collection":[{"href":"https:\/\/aerospaceresearch.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/aerospaceresearch.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/aerospaceresearch.net\/index.php?rest_route=\/wp\/v2\/users\/14"}],"replies":[{"embeddable":true,"href":"https:\/\/aerospaceresearch.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=817"}],"version-history":[{"count":6,"href":"https:\/\/aerospaceresearch.net\/index.php?rest_route=\/wp\/v2\/posts\/817\/revisions"}],"predecessor-version":[{"id":841,"href":"https:\/\/aerospaceresearch.net\/index.php?rest_route=\/wp\/v2\/posts\/817\/revisions\/841"}],"wp:attachment":[{"href":"https:\/\/aerospaceresearch.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=817"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/aerospaceresearch.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=817"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/aerospaceresearch.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=817"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}