{"id":102670,"date":"2021-04-09T00:55:09","date_gmt":"2021-04-09T00:55:09","guid":{"rendered":"https:\/\/ahay.org\/blog\/?p=102670"},"modified":"2021-04-09T00:55:18","modified_gmt":"2021-04-09T00:55:18","slug":"enhancements-to-python-interface","status":"publish","type":"post","link":"https:\/\/ahay.org\/blog\/2021\/04\/09\/enhancements-to-python-interface\/","title":{"rendered":"Enhancements to Python interface"},"content":{"rendered":"<p>Several enhancements have been added to Madagascar&#8217;s Python interface.<\/p>\n<ul>\n<li>It is now possible to run Madagascar programs directly on <a href=\"https:\/\/numpy.org\">NumPy<\/a> arrays, analogously to how the <a href=\"\/blog\/2013\/06\/13\/extending-matlab-interface\/\">Matlab interface<\/a> works on Matlab objects. See <a href=\"https:\/\/github.com\/sfomel\/ipython\/blob\/master\/Interface.ipynb\">an example<\/a>.<\/li>\n<\/ul>\n<p><img decoding=\"async\" src=\"\/blog\/wp-content\/uploads\/2021\/04\/interface.png\" alt=\"\" title=\"\" \/><\/p>\n<p>Behind the scene, temporary files are created, and Madgascar programs run in the usual way, but, for the user, they appears like native Python functions. This way, the full power of Madagascar becomes available to people who prefer to work on data analysis projects in a Python environment.<\/p>\n<ul>\n<li>However, there is no good reason to abandon Madagascar&#8217;s <a href=\"https:\/\/www.ahay.org\/wiki\/SCons\">use of SCons<\/a> for managing data analysis workflows even when working in a Python framework. Because <code>SConstruct<\/code> scripts are written in Python, they are easy to adapt for including Python functions in place of command-line instructions. See <a href=\"https:\/\/github.com\/sfomel\/ipython\/blob\/master\/Keras.ipynb\">an example<\/a> of using <a href=\"https:\/\/keras.io\">Keras<\/a> with SCons or <a href=\"https:\/\/github.com\/sfomel\/ipython\/blob\/master\/Torch.ipynb\">an example<\/a> of using <a href=\"https:\/\/pytorch.org\">PyTorch<\/a> with SCons.<\/li>\n<\/ul>\n<p><img decoding=\"async\" src=\"\/blog\/wp-content\/uploads\/2021\/04\/keras.png\" alt=\"\" title=\"\" \/><\/p>\n<p>In deep learning projects, the training data, the neural-network model, and the testing data can be treated as files and handled effectively through SCons workflows while mixing with Madagascar commands and workflows.<\/p>\n<ul>\n<li>Plotting with <a href=\"https:\/\/matplotlib.org\">Matplotlib<\/a> may offer some advanced functionality in comparison with Vplot, such as the possibility of using $\\LaTeX$ code in figure labels. It is now possible to use Matplotlib plots in papers reproducible with Madagascar through an application of <a href=\"https:\/\/ahay.org\/blog\/2019\/09\/12\/plotting-with-matplotlib\/\">sfmatplotlib<\/a>. The figures will be saved in the PDF format and included in reproducible papers in the usual way. See <a href=\"https:\/\/github.com\/sfomel\/ipython\/blob\/master\/Matplotlib.ipynb\">an example<\/a>.<\/li>\n<\/ul>\n<p><img decoding=\"async\" src=\"\/blog\/wp-content\/uploads\/2021\/04\/matplotlib.png\" alt=\"\" title=\"\" \/><\/p>\n<p>The main advantage of continuing to use Vplot is the availability of <a href=\"https:\/\/www.ahay.org\/RSF\/sfvplotdiff.html\">sfvplotdiff<\/a>, a key tool for <a href=\"\/blog\/2012\/09\/22\/how-is-regression-testing-done-in-madagascar\/\">reproducibility testing<\/a> and <a href=\"\/blog\/2016\/02\/20\/continuous-reproducibility-using-circleci\/\">continuous integration<\/a>.<\/p>\n<p>Madagascar users are invited to try the new functionality and contribute to its further development.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Several enhancements have been added to Madagascar&#8217;s Python interface. It is now possible to run Madagascar programs directly on NumPy arrays, analogously to how the Matlab interface works on Matlab objects. See an example. Behind the scene, temporary files are created, and Madgascar programs run in the usual way, but, for the user, they appears [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_import_markdown_pro_load_document_selector":0,"_import_markdown_pro_submit_text_textarea":"","activitypub_content_warning":"","activitypub_content_visibility":"local","activitypub_max_image_attachments":4,"activitypub_interaction_policy_quote":"","footnotes":""},"categories":[6],"tags":[],"class_list":["post-102670","post","type-post","status-publish","format-standard","hentry","category-systems"],"_links":{"self":[{"href":"https:\/\/ahay.org\/blog\/wp-json\/wp\/v2\/posts\/102670","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ahay.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ahay.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ahay.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ahay.org\/blog\/wp-json\/wp\/v2\/comments?post=102670"}],"version-history":[{"count":11,"href":"https:\/\/ahay.org\/blog\/wp-json\/wp\/v2\/posts\/102670\/revisions"}],"predecessor-version":[{"id":104428,"href":"https:\/\/ahay.org\/blog\/wp-json\/wp\/v2\/posts\/102670\/revisions\/104428"}],"wp:attachment":[{"href":"https:\/\/ahay.org\/blog\/wp-json\/wp\/v2\/media?parent=102670"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ahay.org\/blog\/wp-json\/wp\/v2\/categories?post=102670"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ahay.org\/blog\/wp-json\/wp\/v2\/tags?post=102670"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}