{ "info": { "author": "", "author_email": "", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Console", "Intended Audience :: Developers", "Natural Language :: English", "Operating System :: Unix", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7" ], "description": "# ftoolz\n[![Build Status](https://travis-ci.com/blindspot-ai/ftoolz.svg?branch=master)](https://travis-ci.com/blindspot-ai/ftoolz) [![Coverage Status](https://coveralls.io/repos/github/blindspot-ai/ftoolz/badge.svg?branch=master)](https://coveralls.io/github/blindspot-ai/ftoolz?branch=master) [![PyPI version](https://badge.fury.io/py/ftoolz.svg)](https://badge.fury.io/py/ftoolz) [![PyPI status](https://img.shields.io/pypi/status/ftoolz.svg)](https://pypi.python.org/pypi/ftoolz/) [![PyPI pyversions](https://img.shields.io/pypi/pyversions/ftoolz.svg)](https://pypi.python.org/pypi/ftoolz/)\n\nCollection of higher-order and utility functions built on top of `cytoolz`.\n\n## Module overview\nFtoolz are split into few generic modules.\n\n### adt package\nPackage that provides implementation for various Abstract Data Types (ADTs).\n\n| ADT | Description |\n|----------|-------------|\n| `MutIter(s0)` | mutable iterator that can be both consumed and appended to, optionally initialized with init state `s0` |\n\n### functoolz package\nPackage that provides higher-order functions commonly associated with Functor, Applicative and Monad. \n\nMoreover, there are general package-level functions implemented in `__init__.py`.\n \n| Function | Description |\n|----------|-------------|\n| `attempt(ex, f, args, kwargs)` | equivalent to `try_except` with `g = lambda _: None` |\n| `chain(*fs)` | reversed function composition `chain(f, g) = g o f` |\n| `silence(errors)` | decorator that silences (selected/all) errors raised by decorated function |\n| `try_apply(f, args, kwargs)` | equivalent to `attempt` with `ex = Exception` |\n| `try_except(ex, f, g, args, kwargs)` | `f(args, kwargs)` and on exception(s) `ex` fallback to `g(args, kwargs)` |\n\nThe package content is organized into modules by individual type class:\n1. `iter.py` for class `Iterable`. **Warn** some functions might not be pure because input iterable is consumed.\n1. `opt.py` for class `Optional` \n1. `seq.py` for class `Seq` (`Sequece`). Methods typically return `tuple` instances to preserve immutability.\n\n#### Module function overview\n| def / .py | iter | opt | seq |\n|-----------|------|-----|-----|\n|`apply`| x | x | x |\n|`apply2`| - | x | - |\n|`applyN`| - | + | - |\n|`flatmap`| x | x | x |\n|`flatten`| x | x | x |\n|`fmap`| x | x | x |\n|`fmap2`| x | x | x |\n|`fmap3`| - | x | - |\n|`fmapN`| - | + | - |\n|`fproduct`| x | x | x |\n|`generate`| x | - | x |\n|`lift`| x | x | x |\n|`product`| x | x | x |\n|`unit`| x | * | x |\n|`zip_map`| + | - | + |\n\n* `x` - implemented, statically type checked\n* `+` - implemented, possible runtime type errors\n* `*` - not implemented, supported natively\n* `-` - not implemented \n\n#### traverse package\nEach module contains traversable-related functions for traversables `Iterable` and `Seq`. \nIndividual modules are named and reserved for single functor that wraps elements of the traversable sequence.\n\nList of currently implemented functions in modules (functors): \n\n| def / .py | opt |\n|-----------|-----|\n|`sequence_iter`| x |\n|`sequence_seq`| x |\n|`traverse_iter`| x |\n|`traverse_iter`| x |\n\n### unsafe package\nPackage `unsafe` is dedicated to all *impure* functions that are prone to or \nwill directly use side-effects.\n\n#### reflection\nThis module contains functions for class discovery, inspection and \nmodifications.\n\nTable of contents\n\n| Function | Description |\n|----------|-------------|\n| `abstract(type)` | `True` iff `type` has abstract methods |\n| `implementations(type, package)` | discover all non-protected implementations of `type` under `package` |\n| `import_all(package)` | recursively import everything under `package` |\n| `protected(type)` | `True` iff `type` defines attribute `__protected__ = True` |\n| `subclasses(type, package)` | discover all subclasses of `type` under `package` |\n\n### dicttoolz\nThis module contains functions that work with `Map` (`Mapping`) instances.\n\nTable of contents\n\n| Function | Description |\n|----------|-------------|\n| `map_val(dict, key, f)` | apply value transformation `f` on value in `dict` under `key` |\n| `swap(dict, key1, key2)` | swap arbitrary values for `key1` and `key2` in given mapping |\n| `swap_values(dict, key1, key2)` | same as `swap` but preserving concrete value type `V` |\n\n### itertoolz\nThis module contains functions that work with `Iterable` instances.\n\nTable of contents\n\n| Function | Description |\n|----------|-------------|\n| `associate(key_fn, iterable)` | associate elements of iterable to keys selected by `key_fn` |\n| `associate_to(key_fn, value_fn, iterable)` | associate values obtained from iterable by `value_fn` to keys \nselected by `key_fn` |\n| `collect(iterable)` | materialize iterable into a sequence if it's not one already |\n| `empty(iterable)` | check if iterable is empty, returns flag and unchanged iterable |\n| `enumerate_with_final(iterable)` | same as `iter_with_final` but adds index as third part |\n| `filter_not_none(iterable)` | filter out `None` elements from iterable |\n| `find(predicate, iterable)` | find first element of iterable satisfying predicate |\n| `first(sequence)` | return first element of a sequence or `None` |\n| `fold_right(op, iterable, z)` | fold iterable by applying binary operator `op` from the *right* |\n| `head_tail(iterable)` | split iterable into head element and tail iterable |\n| `head_tail_list(iterable)` | same as `head_tail` but materialized tail into list |\n| `iter_with_final(iterable)` | creates iterable of tuples of original element and final flag |\n| `last(sequence)` | return last element of a sequence or `None` |\n| `make_str(iterable, key_fn, separator)` | create string of tokens from iterable selected by `key_fn` with separator |\n| `order_by(iterable, by, key_fn)` | order `iterable` w.r.t. order given by keys sequence `by` (given key-getter `key_fn`) and fill in missing values as `None` |\n| `positions(sequence)` | collect positions of non-unique items in original sequence |\n| `split_by(predicate, iterable)` | split elements of iterable by predicate to positives and negatives |\n| `take(n, iterable)` | take first n elements of an iterable |\n| `take_first(iterable)` | take first element of an iterable or fail |\n| `try_take_first(iterable)` | same as `take_first` but returns `None` |\n| `try_take_last(iterable)` | take last element of an iterable or `None` |\n| `unique_list(iterable)` | return distinct elements of an iterable as `Seq` |\n| `unique_sorted(iterable)` | return distinct elements of an iterable in natural order as `Seq` |\n\n### predicates\nThis module contains common `Predicate`s, i.e. functions from generic or concrete `A` to `bool`.\n\nTable of contents\n\n| Predicate | Description |\n|-----------|-------------|\n| `some(optional)` | `True` iff optional *is not* `None` |\n| `none(optional)` | `True` iff optional *is* `None` |\n| `even(integer)` | `True` iff integer is even |\n| `odd(integer)` | `True` iff integer is odd |\n\n### typing\nTyping contains helpful type aliases and other type-related definitions.\n\n## cytoolz\nCytoolz is a cython implementation of a python library supporting functional style called \n[toolz](https://toolz.readthedocs.io).\n\nWe highly recommend reading the API docs and using it in your project.\n\nFtoolz does not fork but rather extends cytoolz and provides typed stubs for it's API. \nPlease note that the typed stubs do not cover all the functions from cytoolz. \n\nAlso some valid cases might not be covered due to Python's restricted typing capabilities.\n\n## Setup development environment\nIt is highly recommended to use virtual environment to develop and test `ftoolz`. For making things easy there are \ntwo make targets to setup `ftoolz`:\n* `make setup` which creates new virtual environment managed by `pipenv` with both dev and `ftoolz` dependencies.\n* `make install` same as `make setup` but installs `ftoolz` dependencies only.\n\nTo python console in [pipenv](https://pipenv.readthedocs.io/en/latest/) environment, run:\n```bash\npipenv shell\n```\nand for running specific command:\n```bash\npipenv run \n```\n\n## Running checks and tests\n\n### Type checking\nType checking is done using `mypy` (for configuration see `mypy.ini`) and can be executed by:\n```bash\nmake type-check\n```\n\n### Code style checking\nFtoolz uses [Flake8](http://flake8.pycqa.org/en/latest/index.html) for enforcing PEP 8 and other code smells.\n```bash\nmake flake8-check\n``` \n\n### Linting\nLinting is configured in `.pylintrc` and can be run via:\n```bash\nmake lint\n```\n\n### Tests\nUnit and doc tests with coverage can be run by\n```bash\nmake tests\n```\n\nOne can also run all checks and tests at once via\n```bash\nmake release-check\n```\n\n*Note*: All these commands run on python managed by `pipenv`.\n\n## Distribution\nProject uses `setuptools` for distribution. Check settings in `setup.py`.", "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/blindspot-ai/ftoolz", "keywords": "functional utility cytoolz itertools functools", "license": "MIT", "maintainer": "Martin Matyasek", "maintainer_email": "martin.matyasek@blindspot.ai", "name": "ftoolz", "package_url": "https://pypi.org/project/ftoolz/", "platform": "", "project_url": "https://pypi.org/project/ftoolz/", "project_urls": { "Homepage": "https://github.com/blindspot-ai/ftoolz" }, "release_url": "https://pypi.org/project/ftoolz/0.3.3/", "requires_dist": null, "requires_python": ">=3.6", "summary": "Collection of higher-order and utility functions", "version": "0.3.3" }, "last_serial": 5719569, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "26d4db16c24f6747143c781bf594c574", "sha256": "2332acb0e2ce3744843632e73fb4a571d89b2bcf09c510afc92e5fea6ec544b5" }, "downloads": -1, "filename": "ftoolz-0.0.1.tar.gz", "has_sig": false, "md5_digest": "26d4db16c24f6747143c781bf594c574", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 7915, "upload_time": "2019-04-11T14:40:39", "url": "https://files.pythonhosted.org/packages/ec/d6/526f83dbcac3615ddcdab747b1a4e5f6410deabe3787ca04c728323abff7/ftoolz-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "92c069bffa58d9cbdcbbd73397f7222a", "sha256": "1e2fa69e33fd2d88a8748b5dc79a87f6fbb1d32a1d0e975816624b956eb9404e" }, "downloads": -1, "filename": "ftoolz-0.0.2-py3.6-linux-x86_64.egg", "has_sig": false, "md5_digest": "92c069bffa58d9cbdcbbd73397f7222a", "packagetype": "bdist_egg", "python_version": "3.6", "requires_python": ">=3.6", "size": 15213, "upload_time": "2019-04-13T10:35:49", "url": "https://files.pythonhosted.org/packages/0f/e2/a747af0681c7b8b2df62f6576350cf2caa4a37cbd73dd95f54002646a332/ftoolz-0.0.2-py3.6-linux-x86_64.egg" }, { "comment_text": "", "digests": { "md5": "6beabf3d813be295c95d48f2519d87f6", "sha256": "be06a5ce9c7e06916db49fe3d4cfae80e1388ab44b744100237acfd2d7f3df4a" }, "downloads": -1, "filename": "ftoolz-0.0.2.tar.gz", "has_sig": false, "md5_digest": "6beabf3d813be295c95d48f2519d87f6", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 8880, "upload_time": "2019-04-13T10:35:50", "url": "https://files.pythonhosted.org/packages/7d/f6/fe32263fcb8d3f459abd4125b19cf6b6ff1a68f12b379d5a6acbe09cb06e/ftoolz-0.0.2.tar.gz" } ], "0.1.0": [ { "comment_text": "", "digests": { "md5": "bbc5c75c047d90bef9456e9e7fb699a3", "sha256": "a7042abe3dbfb71c2f07e9ff628def060b13ae65f5a266f9eb6ded12b7cc0598" }, "downloads": -1, "filename": "ftoolz-0.1.0.tar.gz", "has_sig": false, "md5_digest": "bbc5c75c047d90bef9456e9e7fb699a3", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 8969, "upload_time": "2019-04-15T10:45:13", "url": "https://files.pythonhosted.org/packages/d2/39/3645168b74e76da6b84adcb829f37fd01eb07c02daca5ad2a7237be27633/ftoolz-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "294fe76a78e0c086e3ffd79b5d1e33d8", "sha256": "a15fec2bcf20802b3eee3624a722a580b1b47fae85f4e8cbd285ab25e3335ed9" }, "downloads": -1, "filename": "ftoolz-0.1.1.tar.gz", "has_sig": false, "md5_digest": "294fe76a78e0c086e3ffd79b5d1e33d8", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 14768, "upload_time": "2019-04-16T09:29:30", "url": "https://files.pythonhosted.org/packages/8b/8e/671a6d6ac2a4064bdb10802c64d365c5109d83e792650b8413e9a0ffa88a/ftoolz-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "4d10336d85b6ed0f1b729dc8101b7567", "sha256": "3300b8077faa0e09cad37addd2d4cc1259c55103078d6f1865d458e8e93fb291" }, "downloads": -1, "filename": "ftoolz-0.1.2.tar.gz", "has_sig": false, "md5_digest": "4d10336d85b6ed0f1b729dc8101b7567", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 20477, "upload_time": "2019-04-16T15:05:39", "url": "https://files.pythonhosted.org/packages/9a/34/d7108c718924e628af8536b465df28133051d4bac3e713543ac53583ac8d/ftoolz-0.1.2.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "069cd4e0235eec0ee4ac7705d3459435", "sha256": "ca2d4a2152beac9017e9781c16c7eb2b3a74b86c20c4ff5a90fd3d785efbdee7" }, "downloads": -1, "filename": "ftoolz-0.2.0.tar.gz", "has_sig": false, "md5_digest": "069cd4e0235eec0ee4ac7705d3459435", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 15154, "upload_time": "2019-04-17T15:24:12", "url": "https://files.pythonhosted.org/packages/4a/93/58a2bf08f5bed5dca19356998349a85a4f49aeb5846974f33e8544dc4280/ftoolz-0.2.0.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "f2a018e94954ea1d4dbeadec8d84beb6", "sha256": "01e6fb5d5048a626c1c5df0d329f707e7cde1c67b63b186b7b0cb647e8ae0c5f" }, "downloads": -1, "filename": "ftoolz-0.2.1.tar.gz", "has_sig": false, "md5_digest": "f2a018e94954ea1d4dbeadec8d84beb6", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 15752, "upload_time": "2019-04-30T09:47:25", "url": "https://files.pythonhosted.org/packages/93/6b/fbb38c632fc27e81f634bce0a6a886e44e1dca90a95373f63ede0c16e30e/ftoolz-0.2.1.tar.gz" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "22df7eb73e91b088060e4681a2678f13", "sha256": "3285ff3fc559628e256ed1c0d97dc539e35e9bea6a49e00ec02946f083d09b97" }, "downloads": -1, "filename": "ftoolz-0.3.0.tar.gz", "has_sig": false, "md5_digest": "22df7eb73e91b088060e4681a2678f13", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 17550, "upload_time": "2019-05-23T09:07:37", "url": "https://files.pythonhosted.org/packages/28/9c/4500cfd4e5361899026d488ccc506f15e842bed33f7b82165cc8d96659c6/ftoolz-0.3.0.tar.gz" } ], "0.3.1": [ { "comment_text": "", "digests": { "md5": "91ee8024cb4be634a9485bd4287a679b", "sha256": "ade699f5eff56688cb72737307098a32dd01be452d2416057c52215e9c80a5b6" }, "downloads": -1, "filename": "ftoolz-0.3.1.tar.gz", "has_sig": false, "md5_digest": "91ee8024cb4be634a9485bd4287a679b", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 24821, "upload_time": "2019-05-29T07:38:20", "url": "https://files.pythonhosted.org/packages/0b/31/861da9a16dba5ab42128436d90d86db5f5ef776df46e724310a03cc0704f/ftoolz-0.3.1.tar.gz" } ], "0.3.2": [ { "comment_text": "", "digests": { "md5": "e7203cca359098812731778240b02a39", "sha256": "fdfec4b24e3728046e82e14256b5d1c9ca6fbdf88586e7f16ec262f0ff83a59c" }, "downloads": -1, "filename": "ftoolz-0.3.2.tar.gz", "has_sig": false, "md5_digest": "e7203cca359098812731778240b02a39", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 25485, "upload_time": "2019-07-04T10:09:38", "url": "https://files.pythonhosted.org/packages/04/30/fac172a3944803ae2b91517d61c0bb9d2034099d0ec82cd6e9d2bbdd40a2/ftoolz-0.3.2.tar.gz" } ], "0.3.3": [ { "comment_text": "", "digests": { "md5": "062d8717932b9bd116c707ceced02ca1", "sha256": "a7fc57867c27ea57241ce17f4a95d3a92efab0a1d0680ee1b4f094e7ffddf10c" }, "downloads": -1, "filename": "ftoolz-0.3.3.tar.gz", "has_sig": false, "md5_digest": "062d8717932b9bd116c707ceced02ca1", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 27344, "upload_time": "2019-08-23T08:48:26", "url": "https://files.pythonhosted.org/packages/8e/d0/631cd8e4819cc6ca301efe6805e18cbdf77052a625ff0e40076e6c919b5d/ftoolz-0.3.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "062d8717932b9bd116c707ceced02ca1", "sha256": "a7fc57867c27ea57241ce17f4a95d3a92efab0a1d0680ee1b4f094e7ffddf10c" }, "downloads": -1, "filename": "ftoolz-0.3.3.tar.gz", "has_sig": false, "md5_digest": "062d8717932b9bd116c707ceced02ca1", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.6", "size": 27344, "upload_time": "2019-08-23T08:48:26", "url": "https://files.pythonhosted.org/packages/8e/d0/631cd8e4819cc6ca301efe6805e18cbdf77052a625ff0e40076e6c919b5d/ftoolz-0.3.3.tar.gz" } ] }