{ "info": { "author": "Juan Pablo Isaza", "author_email": "biosolardecolombia@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\n\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\n\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\nDescription: Shatter\n =============\n \n Data driven programming; input data and output nice functional code ;)\n \n \n Introduction\n =============\n \n This is a [python 3.6+ project](https://pypi.python.org/pypi/shatter) that uses algorithms to transform a set of\n conditions into functional python code. See some [examples](https://github.com/jisazaTappsi/shatter/tree/master/examples).\n \n \n Package Setup\n -------------\n \n Install:\n \n $ pip install shatter\n \n \n Dependencies\n ------------\n \n pyeda==0.28.0\n pandas==0.19.1\n sympy==1.1\n Keras==2.0.6\n numpy==1.13.1\n pip==9.0.1\n scikit_learn==0.19.0\n \n \n Examples\n =============\n \n \n Get Started\n -------------\n Copy paste this snippet:\n \n from shatter.solver import Rules\n \n \n def my_func(a, b):\n pass\n \n r = Rules(a=True, b=True, output=True)\n r.solve(my_func)\n \n Run it and see how `my_func` code changes from `pass` to `return a and b`. We just\n specified that when `a` and `b` are true then the output should be `True`, that is equivalent to the\n logical `and` operator.\n \n We can add further conditions and `shatter` will compute the optimal function to get there.\n \n \n Adding more conditions\n -------------\n \n Now we add 2 additional conditions with `r.add()`:\n \n from shatter.solver import Rules\n \n \n def my_func(a, b):\n pass\n \n \n r = Rules(a=True, b=True, output=True)\n r.add(a=False, b=True, output=True)\n r.add(a=True, b=False, output=True)\n r.solve(my_func)\n \n In this case the solution is `a or b`.\n \n \n If conditionals\n -------------\n \n What if the output for a given logical condition is not a boolean? In that case a programmer would use an if.\n In the next example this package solves this case:\n \n Change output to `1`:\n \n from shatter.solver import Rules\n \n \n def my_func(a, b):\n pass\n \n r = Rules(a=True, b=True, output=1)\n r.solve(my_func)\n \n \n The solution will be:\n \n def my_func(a, b):\n \n if a and b:\n return 1\n \n return False\n \n Returns `1` or `False` otherwise.\n \n \n Adding pieces of code\n -------------\n \n Say you want to add a arbitrary piece of code that evaluates to boolean, then:\n \n from shatter.solver import Rules, Code\n \n \n def any_code(a):\n pass\n \n r = Rules(condition=Code(code_str='isinstance(a, str)'), output=2)\n r.solve(any_code)\n \n The result should be:\n \n def internal_code(a):\n \n if isinstance(a, str):\n return 2\n \n return False\n \n Here the piece of code `isinstance(a, str)` was added as the if condition to output `2`\n \n \n Iteration\n -------------\n \n Run this code:\n \n from shatter.solver import Rules, Code, Output\n \n \n def recursive(a):\n pass\n \n a = Code()\n args = {'a': a + 1}\n out = Output(function=recursive, arguments=args)\n \n r = Rules(stopping_condition= a > 2, output=a, default=out)\n solution = r.solve(recursive)\n \n The result this time will be a recursive counting function :)\n \n def recursive(a):\n \n if a > 2:\n return a\n \n return recursive(a + 1)\n \n With `a = Code()` variable `a` is initialized as a code piece. Then with\n \n args = {'a': a + 1}\n \n A dictionary for the inputs of the `recursive` function is declared. Those inputs are fed into a `Output` object:\n \n out = Output(function=recursive, arguments=args)\n \n After `out` is passed via `default` keyword when initializing the `Rules` object. This `default` keyword \n is used to override the last return statement of the `recursive` function.\n \n \n Solve Small ML problem\n ----------------------\n \n Copy paste this snippet:\n \n import pandas as pd\n from sklearn import datasets\n from shatter.solver import Rules, solve\n \n \n @solve()\n def solve_iris(x1, x2, x3, x4):\n pass\n \n \n iris = datasets.load_iris()\n \n x = iris.data\n y = iris.target\n \n data_frame = pd.DataFrame(x, columns=['x1', 'x2', 'x3', 'x4'])\n \n # Make binary and add to df\n data_frame['output'] = [int(bool(e)) for e in y]\n \n \n print(data_frame)\n \n r = Rules(data_frame)\n \n solution = r.solve(solve_iris)\n \n \n Outputs:\n \n def solve_iris():\n return x3 >= 2.45\n \n \n Going deeper\n =============\n \n Setup\n -------------\n \n Clone repository:\n \n `git clone git@github.com:jisazaTappsi/shatter.git`\n \n More examples\n -------------\n \n See [examples](https://github.com/jisazaTappsi/shatter/tree/master/examples).\n \n \n How does shatter work?\n -------------\n \n Takes a function and a truth table which is processed using the\n [Quine-McCluskey Algorithm](https://en.wikipedia.org/wiki/Quine%E2%80%93McCluskey_algorithm).\n Then finds an optimal boolean expression. This expression is inserted in the method definition.\n \n \n Rules Class\n =============\n \n Is initialized with one rule. Other rules can be added with `Rules.add()` method. To generate\n the solution call `Rules.solve()` method.\n \n Each rule\n -------------\n \n The arguments of each rule are specified as optional arguments inside a `Rules` constructor or inside a\n `Rules.add()` call. There are reserved keywords:\n \n `output`: Determines the value to be returned when the given condition is True.\n \n `output_args`: Dictionary with the values for the arguments when output is a function.\n \n `default`: Value returned when non of the rules are True.\n \n \n Arguments of `Rules.solve()`\n -------------\n \n - `function`: passed as a callable. This function is going to be filled with the solution to the present task.\n \n - `unittest=None`: Test Case to be able to run and test the code generated each time the test runs.\n See [example](https://github.com/jisazaTappsi/shatter/tree/master/examples/with_tests) for a deeper understanding.\n \n \n Output Class\n -------------\n \n `solver.Output`: Class that helps define a function with arguments as an output. Has fields:\n \n - `function`: A callable object.\n - `arguments` Dictionary with the function inputs.\n \n Code class\n -------------\n \n `solver.Code`: Class that helps represent pieces of code. The code is fed as a string (with optional argument `str_code`)\n or it can be declared as variables. eg:\n \n from shatter.solver import Code\n \n a = Code()\n b = Code()\n print(a > b)\n \n This will literally print the code `a > b` rather than the objects or any result.\n \n \n Solution class\n -------------\n \n `solver.Solution`: Class that contains the solution of the problem it includes:\n \n - `rules`: The information given by the user.\n - `implementation`: Plain code.\n - `ast`: Abstract syntax tree\n \nKeywords: Quine McCluskey,Machine Learning,code,automatic code generation,expression\nPlatform: UNKNOWN\nClassifier: Development Status :: 3 - Alpha\nClassifier: License :: OSI Approved :: MIT License\nClassifier: Programming Language :: Python :: 3.6\nClassifier: Intended Audience :: Developers\nClassifier: Topic :: Software Development :: Build Tools\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/jisazaTappsi/shatter", "keywords": "", "license": "Copyright (c) 2017 Juan Pablo Isaza", "maintainer": "", "maintainer_email": "", "name": "shatter", "package_url": "https://pypi.org/project/shatter/", "platform": "", "project_url": "https://pypi.org/project/shatter/", "project_urls": { "Homepage": "https://github.com/jisazaTappsi/shatter" }, "release_url": "https://pypi.org/project/shatter/0.6.2.1/", "requires_dist": [ "Keras (==2.0.6)", "numpy (==1.13.1)", "pandas (==0.19.1)", "pip (==9.0.1)", "pyeda (==0.28.0)", "pypandoc (==1.2.0)", "scikit-learn (==0.19.0)", "setuptools (==36.0.1)", "sympy (==1.1)" ], "requires_python": "", "summary": "Data Driven Programming", "version": "0.6.2.1" }, "last_serial": 3679593, "releases": { "0.5.3": [ { "comment_text": "", "digests": { "md5": "eedef73ac5745c51b9f631fb6409e707", "sha256": "34decea2d930ac4304d2de307091989043f3edd64208e9449146b6f032b283fb" }, "downloads": -1, "filename": "shatter-0.5.3-py2-none-any.whl", "has_sig": false, "md5_digest": "eedef73ac5745c51b9f631fb6409e707", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 60046, "upload_time": "2017-02-10T05:10:35", "url": "https://files.pythonhosted.org/packages/83/13/a55abb600b4990bda4051c3c6111945affd0bb6651e50fae59e820bd4026/shatter-0.5.3-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "cc284ef4b4469a931160d45b6101e4ac", "sha256": "4d0ef43721319761816dc9058e6872141e22022e7ac832cb9b3c883c517dd028" }, "downloads": -1, "filename": "shatter-0.5.3.tar.gz", "has_sig": false, "md5_digest": "cc284ef4b4469a931160d45b6101e4ac", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 42301, "upload_time": "2017-02-10T05:10:37", "url": "https://files.pythonhosted.org/packages/9a/04/a812bfb72b2b6281b0c30aa1e039f1d35d135cad7c9e71b3746fa827f9e8/shatter-0.5.3.tar.gz" } ], "0.6.0": [ { "comment_text": "", "digests": { "md5": "9efbfd725e2f15cb9bae96eb9f948b9e", "sha256": "ba7aa444895002621752b45119e9a97297aa82ed61a9174ecf9acc145077d7be" }, "downloads": -1, "filename": "shatter-0.6.0-py2-none-any.whl", "has_sig": false, "md5_digest": "9efbfd725e2f15cb9bae96eb9f948b9e", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 76316, "upload_time": "2017-09-26T03:19:41", "url": "https://files.pythonhosted.org/packages/d9/01/6056ceec359f1970958cc14d107dfafc6b945f343896fd76e3b85e5b17b8/shatter-0.6.0-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "f0a1d25ab41570f38265761ff77c4b8e", "sha256": "35b25792c1a086634050074258e0e83892afb365054bf939fadb089353bbdb55" }, "downloads": -1, "filename": "shatter-0.6.0.tar.gz", "has_sig": false, "md5_digest": "f0a1d25ab41570f38265761ff77c4b8e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 54139, "upload_time": "2017-09-26T03:19:43", "url": "https://files.pythonhosted.org/packages/d3/d4/e3aa31be822a54a20493b6447609ff5f953f9b506ff0cdf303f031545dbe/shatter-0.6.0.tar.gz" } ], "0.6.1": [ { "comment_text": "", "digests": { "md5": "97606604bd8fbf79a19077022e069134", "sha256": "0ecd6729616a9d15ca2cfdf320d77cb8aca362f9531768bcf3a915b59ba31b9a" }, "downloads": -1, "filename": "shatter-0.6.1-py2-none-any.whl", "has_sig": false, "md5_digest": "97606604bd8fbf79a19077022e069134", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 76835, "upload_time": "2017-09-27T01:18:27", "url": "https://files.pythonhosted.org/packages/4e/13/c48e69bc0c2d1410ea51e9de7f31595b6e6afba36ffdca40f6dcd5640d9d/shatter-0.6.1-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "6cb15bd76daf32c4475f02af38c646c6", "sha256": "65057d0b36c0826bb84a6cfad2d0a51a8e14f51449399153b4c95577c4703365" }, "downloads": -1, "filename": "shatter-0.6.1.tar.gz", "has_sig": false, "md5_digest": "6cb15bd76daf32c4475f02af38c646c6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 54626, "upload_time": "2017-09-27T01:18:29", "url": "https://files.pythonhosted.org/packages/9b/2c/1d95ca0610632cc414a71a4d8e5a94ee97292ba00a451bc3f53debc7210c/shatter-0.6.1.tar.gz" } ], "0.6.2": [ { "comment_text": "", "digests": { "md5": "b04bceadaeeffeea9e0a9354a93874ac", "sha256": "29d8cca7c75dcca39521a826631692bbe7691c39ae37ec375a139f3db5048574" }, "downloads": -1, "filename": "shatter-0.6.2-py2-none-any.whl", "has_sig": false, "md5_digest": "b04bceadaeeffeea9e0a9354a93874ac", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 77373, "upload_time": "2017-09-27T04:11:05", "url": "https://files.pythonhosted.org/packages/3e/83/af3b4bb5ab04fad6c704d4470c05db89cfb625b5e63888c589f2e8e723b7/shatter-0.6.2-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a77a9dd4299550bfb35ab1a6d521e9ad", "sha256": "b181257e9eb17f40e32f67fad88602ad4774e3d76d1272f16adb2a0018873dd1" }, "downloads": -1, "filename": "shatter-0.6.2.tar.gz", "has_sig": false, "md5_digest": "a77a9dd4299550bfb35ab1a6d521e9ad", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 54845, "upload_time": "2017-09-27T04:11:09", "url": "https://files.pythonhosted.org/packages/91/0c/f7e40fbdb5982f156c7f96a0e5e17739d62c07dc89aa831457be16288496/shatter-0.6.2.tar.gz" } ], "0.6.2.1": [ { "comment_text": "", "digests": { "md5": "81250821b249d28b29022c5bea6525c3", "sha256": "5be0fe379949f017045acfb1d5f3617b7d723f2a6a175662f3ccca524e6604f3" }, "downloads": -1, "filename": "shatter-0.6.2.1-py2-none-any.whl", "has_sig": false, "md5_digest": "81250821b249d28b29022c5bea6525c3", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 77231, "upload_time": "2018-03-17T20:43:14", "url": "https://files.pythonhosted.org/packages/09/78/5e8170b36ff41b307dd9022e224f33f22bc7c763c0a1080000c584f88839/shatter-0.6.2.1-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "fb30aa8dabdb1a4c35df22605eecc5d5", "sha256": "847db50753966510e1dcc7af469e76fd2611778aaf6c98dba976385d3fb4c8d1" }, "downloads": -1, "filename": "shatter-0.6.2.1.tar.gz", "has_sig": false, "md5_digest": "fb30aa8dabdb1a4c35df22605eecc5d5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 55407, "upload_time": "2018-03-17T20:43:16", "url": "https://files.pythonhosted.org/packages/59/ad/a4a658f14ae3cd11e359ce6419efdbb938caa689aaf9c7729222195add3b/shatter-0.6.2.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "81250821b249d28b29022c5bea6525c3", "sha256": "5be0fe379949f017045acfb1d5f3617b7d723f2a6a175662f3ccca524e6604f3" }, "downloads": -1, "filename": "shatter-0.6.2.1-py2-none-any.whl", "has_sig": false, "md5_digest": "81250821b249d28b29022c5bea6525c3", "packagetype": "bdist_wheel", "python_version": "py2", "requires_python": null, "size": 77231, "upload_time": "2018-03-17T20:43:14", "url": "https://files.pythonhosted.org/packages/09/78/5e8170b36ff41b307dd9022e224f33f22bc7c763c0a1080000c584f88839/shatter-0.6.2.1-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "fb30aa8dabdb1a4c35df22605eecc5d5", "sha256": "847db50753966510e1dcc7af469e76fd2611778aaf6c98dba976385d3fb4c8d1" }, "downloads": -1, "filename": "shatter-0.6.2.1.tar.gz", "has_sig": false, "md5_digest": "fb30aa8dabdb1a4c35df22605eecc5d5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 55407, "upload_time": "2018-03-17T20:43:16", "url": "https://files.pythonhosted.org/packages/59/ad/a4a658f14ae3cd11e359ce6419efdbb938caa689aaf9c7729222195add3b/shatter-0.6.2.1.tar.gz" } ] }