{ "info": { "author": "Sam Lau", "author_email": "samlau95@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Framework :: Jupyter", "Intended Audience :: Developers", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Topic :: Software Development :: Build Tools" ], "description": "# `expylain`\n\n`expylain` is a Python package for Jupyter notebooks that enables rapid\ninteractive exploration of random processes. It is designed for ease-of-use in\nlearning contexts.\n\n## Example\n\n`expylain` works by taking `Data` and defining `Step`s that work on the data.\nEach `Step` is just a Python function that takes in data from the previous\n`Data` or `Step`. `Data` and its `Steps` are grouped in a `Process`.\n\nFor example, to flip a coin that lands heads with probability `p`:\n\n```python\nfrom random import random\n\ndef flip(coin, p=0.5):\n return coin[0] if random() < p else coin[1]\n\nProcess([\n Data(['H', 'T']),\n Step(flip),\n])\n```\n\n**Output:**\n\n```\nData: ['H', 'T']\n |\n flip |\n v\n 'H'\n\n [Rerun]\n```\n\nThe real power of `expylain` results when using its built-in support for\ninteractive functions:\n\n```python\nProcess([\n Data(['H', 'T']),\n # Specify a (start, end, step) for the arg p\n Step(flip, p=(0, 1, 0.1)),\n])\n```\n\n**Output:**\n\n```\nData: ['H', 'T']\n |\n flip | p: 0 --- | ---- 1 [0.5]\n |\n v\n 'H'\n\n [Rerun]\n```\n\nThis allows you to interact and visualize random processes:\n\n```python\nfrom random import choices\nfrom bqplot import pyplot as plt\n\ndef flip_n(coin, p=0.5, n=100):\n return choices(coin, weights=[p, 1-p], k=n)\n\ndef plot_flips(flips):\n heads, tails = flips.count('H'), flips.count('T')\n plt.bar(['H', 'T'], [heads, tails])\n\nProcess([\n Data(['H', 'T']),\n Step(flip_n, p=(0, 1, 0.1), n=(50, 500, 50)),\n Step(plot_flips),\n])\n```\n\n**Output:**\n\n```\nData: ['H', 'T']\n |\n flip_n | p: 0 --- | --- 1 [0.5]\n | n: 50 --- | --- 500 [100]\n |\n v\n ['H', 'T', ..., 'H']\n |\nplot_flips|\n v\n\n \n\n [Rerun]\n```\n\nProcesses can be composed, giving high expressivity. The `Repeat` constructor\nallows the output of multiple runs of a process to become an input to a next\nstep:\n\n```python\ndef count_heads(flips):\n return flips.count('H')\n\nheads_in_n_flips = Process([\n Data(['H', 'T']),\n Step(flip_n, p=(0, 1, 0.1), n=(50, 500, 50))\n Step(count_heads)\n ],\n name='heads_in_n_flips',\n)\n\ndistribution_of_heads = Process([\n Repeat(heads_in_n_flips, times=1000),\n Step(plt.hist),\n])\n```\n\n**Output:**\n\n```\n+-------------------------------------------+\n| Data: ['H', 'T'] |\n| | |\n| flip_n | p: 0 --- | --- 1 [0.5] |\n| | n: 50 --- | --- 500 [100] |\n| | |\n| v | heads_in_n_flips\n| ['H', 'T', ..., 'H'] |\n| | |\n| count_heads | |\n| v |\n| 48 |\n+-------------------------------------------+\n |\n Repeat(1000) |\n v\n [48, 49, ..., 50]\n |\n |\n v\n \n\n [Rerun]\n```\n\n## Getting Started\n\nRun these commands in your terminal to install `expylain` and its Jupyter\nextension:\n\n```\npip install expylain\njupyter nbextension enable --py --sys-prefix expylain\n```\n\n\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/SamLau95/expylain", "keywords": "jupyter expylain visualization random", "license": "BSD 3-Clause", "maintainer": "", "maintainer_email": "", "name": "expylain", "package_url": "https://pypi.org/project/expylain/", "platform": "", "project_url": "https://pypi.org/project/expylain/", "project_urls": { "Homepage": "https://github.com/SamLau95/expylain" }, "release_url": "https://pypi.org/project/expylain/0.0.1/", "requires_dist": [ "check-manifest; extra == 'dev'", "coverage; extra == 'test'" ], "requires_python": "", "summary": " expylain is a Python package for Jupyter notebooks that enables rapid interactive exploration of random processes. It is designed for ease-of-use in learning contexts.", "version": "0.0.1" }, "last_serial": 3441636, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "35bea01c964d3b46e43f039c56471083", "sha256": "21184c3f48f8e0bdc745f2e95b140c792763c540a33c5a4a89c0da6b029b3c33" }, "downloads": -1, "filename": "expylain-0.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "35bea01c964d3b46e43f039c56471083", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 4748, "upload_time": "2017-12-25T09:14:35", "url": "https://files.pythonhosted.org/packages/65/f1/1a80af397bb6084938633adc7ef77dbc54d938c343a89256e9f3a65d345f/expylain-0.0.1-py3-none-any.whl" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "35bea01c964d3b46e43f039c56471083", "sha256": "21184c3f48f8e0bdc745f2e95b140c792763c540a33c5a4a89c0da6b029b3c33" }, "downloads": -1, "filename": "expylain-0.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "35bea01c964d3b46e43f039c56471083", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 4748, "upload_time": "2017-12-25T09:14:35", "url": "https://files.pythonhosted.org/packages/65/f1/1a80af397bb6084938633adc7ef77dbc54d938c343a89256e9f3a65d345f/expylain-0.0.1-py3-none-any.whl" } ] }