{ "info": { "author": "Idin", "author_email": "py@idin.ca", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3 :: Only", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "# *Pensieve 2.1*\n\n\"*One simply siphons the excess thoughts from one's mind, pours them into the basin, and examines them at one's leisure. It becomes easier to spot patterns and links, you understand, when they are in this form.*\"
\n—**Albus Dumbledore** (Harry Potter and the Goblet of Fire by J. K. Rowling)\n\n![Picture of Pensieve](https://raw.githubusercontent.com/idin/pensieve/master/pictures/pensieve.jpg)\n\n### Pensieve for Data\n\nIn [J. K. Rowling](https://en.wikipedia.org/wiki/J._K._Rowling)'s amazing world of magic, \n\"*a witch or wizard can **extract** their own or another's memories, **store** them in the [Pensieve](https://en.wikipedia.org/wiki/Magical_objects_in_Harry_Potter#Pensieve), \nand **review** them later. It also **relieves the mind** when it becomes cluttered with information. \nAnyone can **examine** the memories in the Pensieve, which also allows viewers to fully immerse \nthemselves in the memories*\" [1](https://en.wikipedia.org/wiki/Magical_objects_in_Harry_Potter#Pensieve). \n\nDealing with data during data wrangling and model generation in data science is like dealing with memories \nexcept that there is a lot more of back and forth and iteration when dealing with data. \nYou constantly update parameters of your models, improve your data wrangling, \nand make changes to the ways you visualize or store data. \nAs with most processes in data science, each step along the way may take a long time to finish\nwhich forces you to avoid rerunning everything from scratch; this approach is very error-prone as some \nof the processes depend on others. To solve this problem I came up with the idea of a *Computation Graph* \nwhere the nodes represent data objects and the direction of edges indicate the dependency between them. \n\nAfter using Pensieve for some time myself, I have found it to be beneficial in several ways:\n* error reduction, especially for data wrangling and model creation\n* data object organization\n* easy transfer of data\n* coherent data processing and data pipelines\n* data and model reproducibility\n* most importantly **relieving the mind**\n\n\n## Installation\n```bash\npip install pensieve\n```\n\n## Usage\nPensieve stores *memories* and *functions* that define the relationship between memories.\n\n```python\nfrom pensieve import Pensieve\n\n# initiate a pensieve\npensieve = Pensieve()\n\n# store a \"memory\" (with 1 as its content) \npensieve.store(key='one', content=1)\n\n# create a new memory made up of a precursor memory\npensieve.store(key='two', precursors=['one'], function=lambda x: x + x)\n```\n\nThere are two types of memories:\n- *independent* memories (without precursors)\n- *dependent* memories (with precursors)\n\n### Independent Memories\nAn independent memory does not have any precursors and instead of a function, \nwhich would define the relationship with the precursors, has *content*.\n\n```python\nfrom pensieve import Pensieve\npensieve = Pensieve()\npensieve.store(key='integers', content=list(range(10)))\n```\n\n### Dependent Memories\nA dependent memory is created from running a *function* on the contents of \nits *precursors*. When there is only one precursor to a memory, the function can be\ndefined as a lambda with one input which is accessed directly within the function, \n*e.g.*, *lambda x: x + 1*.\n\n```python\n# the precursor, 'integer' is accessed within the lambda under the label: numbers\npensieve.store(\n key='odd_integers', precursors=['integers'],\n function=lambda numbers: [x for x in numbers if x%2==1]\n)\n```\n\n### Memory with Two or More *Precursors*\nIf a memory has multiple precursors, its function should still have one input but \nthe precursors should be accessed as items in the input, as if the input is a dictionary\nof precursors.\n\nFor example, if a function adds two precursors *x* and *y*, it should be defined as:\n*lambda x: x['x'] + x['y']*. In the following example, the function gets a set of integers and \nodd integers and by filtering out the odd integers from integers, it finds all even integers\nin the set. This function has only one input, which is called *precursors* for clarity \n(but can be called anything) and the precursors are accessed within the function as \nitems *'integers'* and *'odd_integers'* like a dictionary.\n\n```python\npensieve.store(\n key='even_integers', \n precursors=['integers', 'odd_integers'],\n function=lambda precursors: [\n x for x in precursors['integers'] \n if x not in precursors['odd_integers']\n ]\n)\n```\n\n\n### Retrieving a Memory\nRetrieving the content of a memory is like getting an item from a dictionary as shown below.\n\n```python\npensieve['integers']\n# output: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]\n\npensieve['even_integers']\n# output: [0, 2, 4, 6, 8]\n\n```\n\n\n### Changing a Memory\nWhen you change a memory in pensieve, all **successors** get notified and marked as *stale* but not updated immediately.\nAs soon as a successor of a changed memory is needed it will be updated based on its relationship with its \nprecursor memories.\n\n```python\n# changing one memory affects all successors\npensieve.store(key='integers', content=list(range(16)))\npensieve['integers']\n# output: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]\n\npensieve['even_integers']\n# output: [0, 2, 4, 6, 8, 10, 12, 14]\n```\n\n### Save and Load\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/idin/pensieve", "keywords": "graph computation", "license": "GNU AGPLv3", "maintainer": "", "maintainer_email": "", "name": "pensieve", "package_url": "https://pypi.org/project/pensieve/", "platform": "", "project_url": "https://pypi.org/project/pensieve/", "project_urls": { "Homepage": "https://github.com/idin/pensieve" }, "release_url": "https://pypi.org/project/pensieve/2.1.1/", "requires_dist": [ "dill", "toposort", "riddle", "slytherin" ], "requires_python": "~=3.6", "summary": "Implementation of a computation graph", "version": "2.1.1" }, "last_serial": 5171676, "releases": { "2.0.0": [ { "comment_text": "", "digests": { "md5": "14c1db619cdafd9e43c21218989d0124", "sha256": "ac25748c589787a56d36dac033517983789000651dae92ba736e2a0ba25f34e4" }, "downloads": -1, "filename": "pensieve-2.0.0-py3-none-any.whl", "has_sig": false, "md5_digest": "14c1db619cdafd9e43c21218989d0124", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": "~=3.6", "size": 11853, "upload_time": "2019-02-28T01:04:37", "url": "https://files.pythonhosted.org/packages/e8/44/0626389936d11d2fcecc792dc642be52bfb181e4a20765d37b2aa6d9b4ee/pensieve-2.0.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "9874507c672893c37f24af8f7110846f", "sha256": "c3e98130c1fc1f554b07139f71f9f2d853d300b0b01a40724d909bd578eebb86" }, "downloads": -1, "filename": "pensieve-2.0.0.tar.gz", "has_sig": false, "md5_digest": "9874507c672893c37f24af8f7110846f", "packagetype": "sdist", "python_version": "source", "requires_python": "~=3.6", "size": 7927, "upload_time": "2019-02-28T01:04:39", "url": "https://files.pythonhosted.org/packages/fa/57/946444b508fbe67b3a2c3e39f6ef13e2f9b144a6ea5cb44a640072272a2f/pensieve-2.0.0.tar.gz" } ], "2.0.1": [ { "comment_text": "", "digests": { "md5": "fb40d4f95cbdc2c346f1724957dbaf1e", "sha256": "99047419b61eb24b112e116cac2e890ec7eb46fac83cbdacd2d33527eb3879fa" }, "downloads": -1, "filename": "pensieve-2.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "fb40d4f95cbdc2c346f1724957dbaf1e", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": "~=3.6", "size": 11831, "upload_time": "2019-03-01T19:21:06", "url": "https://files.pythonhosted.org/packages/4d/cc/4bb9fb19856ca2927ae937151a254116faee792ce9972c4ee8d5d8ab0027/pensieve-2.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5dd2800ec0cc221e87f513b014995329", "sha256": "e1e41a1e6d8951141de1e0e671829d239e1632e42584a82957f72ba11516c5d6" }, "downloads": -1, "filename": "pensieve-2.0.1.tar.gz", "has_sig": false, "md5_digest": "5dd2800ec0cc221e87f513b014995329", "packagetype": "sdist", "python_version": "source", "requires_python": "~=3.6", "size": 7923, "upload_time": "2019-03-01T19:21:08", "url": "https://files.pythonhosted.org/packages/ed/15/14d1494595cd8925f8afa8afea7abc1be559da68866dba5a228e817da0f1/pensieve-2.0.1.tar.gz" } ], "2.0.2": [ { "comment_text": "", "digests": { "md5": "3bfebdd999842e84e7cd6251798a15ea", "sha256": "ab15bf97c62347aedb0f7da72e8ee007574459d3f5c5def5df5df8bc3bb91953" }, "downloads": -1, "filename": "pensieve-2.0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "3bfebdd999842e84e7cd6251798a15ea", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": "~=3.6", "size": 10624, "upload_time": "2019-03-22T00:17:14", "url": "https://files.pythonhosted.org/packages/77/30/866c86841b9f165c56f251935eeb824764a3cd2528be3654fa8bda586d42/pensieve-2.0.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "dcea4bf2b4197ace5fe41314558c8a29", "sha256": "ae7a6bba6e6b86b6b95550d680a8cdb477033d7432de140096dd3109680c7208" }, "downloads": -1, "filename": "pensieve-2.0.2.tar.gz", "has_sig": false, "md5_digest": "dcea4bf2b4197ace5fe41314558c8a29", "packagetype": "sdist", "python_version": "source", "requires_python": "~=3.6", "size": 8840, "upload_time": "2019-03-22T00:17:15", "url": "https://files.pythonhosted.org/packages/1d/50/837f35b68a6b6d9430480fce7cf22f6ea0f194d39a74d956501f5d485d83/pensieve-2.0.2.tar.gz" } ], "2.0.3": [ { "comment_text": "", "digests": { "md5": "d686b055e45ac0a68536636a8dc71c68", "sha256": "4153c0e6cb8c6a28195b100bef3f8b076c9523d8c408e883b58dd8965ab147ed" }, "downloads": -1, "filename": "pensieve-2.0.3-py3-none-any.whl", "has_sig": false, "md5_digest": "d686b055e45ac0a68536636a8dc71c68", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": "~=3.6", "size": 10615, "upload_time": "2019-03-22T00:18:17", "url": "https://files.pythonhosted.org/packages/56/71/17d2fca10afe66a743c30206b57cdb98fa22b35cfecd764603b929d01e1c/pensieve-2.0.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "b6d7524bd6575bf295e3f59cc8619119", "sha256": "9fd4af006dfcef08c495fe748e76e64ee4bb77a610f91ee60dd002d8402ced2f" }, "downloads": -1, "filename": "pensieve-2.0.3.tar.gz", "has_sig": false, "md5_digest": "b6d7524bd6575bf295e3f59cc8619119", "packagetype": "sdist", "python_version": "source", "requires_python": "~=3.6", "size": 8822, "upload_time": "2019-03-22T00:18:19", "url": "https://files.pythonhosted.org/packages/57/74/fcca109d2c2b33c8918e379e25705a3cb690e23bcf95a76d651ff5fcebaf/pensieve-2.0.3.tar.gz" } ], "2.0.5": [ { "comment_text": "", "digests": { "md5": "2883c5370907c24c4bc4a45df756de7e", "sha256": "e82caee2fa3fba9c9811912389352dbf76b95742b15901b9f1ed24801f4aabad" }, "downloads": -1, "filename": "pensieve-2.0.5-py3-none-any.whl", "has_sig": false, "md5_digest": "2883c5370907c24c4bc4a45df756de7e", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": "~=3.6", "size": 10617, "upload_time": "2019-03-22T00:54:21", "url": "https://files.pythonhosted.org/packages/5f/93/eac112ec195d7dc062240a30afd334bfeab4a7a68e1880d3ee7e67cc8950/pensieve-2.0.5-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "0df61f0854e5c8b6d77368fe951986ab", "sha256": "3bfacf858f498d01c2bdfbec88a5a010043ba5c4a1bacfb3044a5d55a7796d3f" }, "downloads": -1, "filename": "pensieve-2.0.5.tar.gz", "has_sig": false, "md5_digest": "0df61f0854e5c8b6d77368fe951986ab", "packagetype": "sdist", "python_version": "source", "requires_python": "~=3.6", "size": 8837, "upload_time": "2019-03-22T00:54:22", "url": "https://files.pythonhosted.org/packages/dc/e6/d29798cfa65bf8fe1b93722a85bbd6dd6781e90dd6cd33d3b7a454f3cf45/pensieve-2.0.5.tar.gz" } ], "2.1.1": [ { "comment_text": "", "digests": { "md5": "4d2bdc4c20436bdd1f11389fef79a030", "sha256": "e01ed1f0fa53c317fa520c666dd14af60ff865fbe5ddc5fed7551bb02c92712d" }, "downloads": -1, "filename": "pensieve-2.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "4d2bdc4c20436bdd1f11389fef79a030", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": "~=3.6", "size": 11784, "upload_time": "2019-04-22T06:12:20", "url": "https://files.pythonhosted.org/packages/a0/35/3263786d0755bc1fa5b95c9f3022fcd813492f016184c92f58b2ad56a487/pensieve-2.1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d41d8995dc2ae068b41b1e9428f33a7e", "sha256": "41354d263ff48b237c2e8afedac1986194d5437deeba7e31f036004293ee0a8d" }, "downloads": -1, "filename": "pensieve-2.1.1.tar.gz", "has_sig": false, "md5_digest": "d41d8995dc2ae068b41b1e9428f33a7e", "packagetype": "sdist", "python_version": "source", "requires_python": "~=3.6", "size": 12435, "upload_time": "2019-04-22T06:12:21", "url": "https://files.pythonhosted.org/packages/b5/1c/6014a85cb8171fb25337356d3001710d52e5e1a5eb80dde2f091dbd01d62/pensieve-2.1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "4d2bdc4c20436bdd1f11389fef79a030", "sha256": "e01ed1f0fa53c317fa520c666dd14af60ff865fbe5ddc5fed7551bb02c92712d" }, "downloads": -1, "filename": "pensieve-2.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "4d2bdc4c20436bdd1f11389fef79a030", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": "~=3.6", "size": 11784, "upload_time": "2019-04-22T06:12:20", "url": "https://files.pythonhosted.org/packages/a0/35/3263786d0755bc1fa5b95c9f3022fcd813492f016184c92f58b2ad56a487/pensieve-2.1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d41d8995dc2ae068b41b1e9428f33a7e", "sha256": "41354d263ff48b237c2e8afedac1986194d5437deeba7e31f036004293ee0a8d" }, "downloads": -1, "filename": "pensieve-2.1.1.tar.gz", "has_sig": false, "md5_digest": "d41d8995dc2ae068b41b1e9428f33a7e", "packagetype": "sdist", "python_version": "source", "requires_python": "~=3.6", "size": 12435, "upload_time": "2019-04-22T06:12:21", "url": "https://files.pythonhosted.org/packages/b5/1c/6014a85cb8171fb25337356d3001710d52e5e1a5eb80dde2f091dbd01d62/pensieve-2.1.1.tar.gz" } ] }