Package: products
Simple function for building ensembles of iterables that are disjoint partitions of an overall Cartesian product.PurposeOnce theitertools.producthas been used to build an iterable representing aCartesian product, it is already too late to partition that iterable into multiple iterables where each one represents a subset of the product set. Iterables representing disjoint subsets can, for example, make it easier to employ parallelization when processing the product set.Theproductsfunction in this package constructs a list of independentiteratorsfor a specified number of disjoint subsets of a product set (in the manner of thepartslibrary), exploiting as much information as is available about the constituent factor sets of the overall product set in order to do so.Installation and UsageThis library is available as apackage on PyPI:python-mpipinstallproductsThe library can be imported in the usual ways:importproductsfromproductsimportproductsExamplesThis library provides an alternative to the built-in Cartesian product functionproductfound initertools, making it possible to iterate over multiple disjoint subsets of a Cartesian product (even in parallel). Consider the Cartesian product below:>>>fromitertoolsimportproduct>>>p=product([1,2],{'a','b'},(False,True))>>>fortinp:...print(t)(1,'a',False)(1,'a',True)(1,'b',False)(1,'b',True)(2,'a',False)(2,'a',True)(2,'b',False)(2,'b',True)This library makes it possible to create a number of iterators such that each iterator represents a disjoint subset of the overall Cartesian product. The example below does so for the Cartesian product introduced above, creating four disjoint subsets (rather than one overall set):>>>fromproductsimportproducts>>>ss=products([1,2],{'a','b'},(True,False),number=4)>>>forsinss:...print(list(s))[(1,'a',True),(1,'a',False)][(1,'b',True),(1,'b',False)][(2,'a',True),(2,'a',False)][(2,'b',True),(2,'b',False)]Theiterablecorresponding to each subset isindependentfrom the others, making it possible to employ techniques such parallelization (e.g., using the built-inmultiprocessinglibrary) when operating on the elements of the overall Cartesian product.DevelopmentAll installation and development dependencies are fully specified inpyproject.toml. Theproject.optional-dependenciesobject is used tospecify optional requirementsfor various development tasks. This makes it possible to specify additional options (such asdocs,lint, and so on) when performing installation usingpip:python-mpipinstall.[docs,lint]DocumentationThe documentation can be generated automatically from the source files usingSphinx:python-mpipinstall.[docs]cddocssphinx-apidoc-f-E--templatedir=_templates-o_source..&&makehtmlTesting and ConventionsAll unit tests are executed and their coverage is measured when usingpytest(see thepyproject.tomlfile for configuration details):python-mpipinstall.[test]python-mpytestAlternatively, all unit tests are included in the module itself and can be executed usingdoctest:pythonsrc/products/products.py-vStyle conventions are enforced usingPylint:python-mpipinstall.[lint]python-mpylintsrc/productsContributionsIn order to contribute to the source code, open an issue or submit a pull request on theGitHub pagefor this library.VersioningThe version number format for this library and the changes to the library associated with version number increments conform withSemantic Versioning 2.0.0.PublishingThis library can be published as apackage on PyPIby a package maintainer. First, install the dependencies required for packaging and publishing:python-mpipinstall.[publish]Ensure that the correct version number appears inpyproject.toml, and that any links in this README document to the Read the Docs documentation of this package (or its dependencies) have appropriate version numbers. Also ensure that the Read the Docs project for this library has anautomation rulethat activates and sets as the default all tagged versions. Create and push a tag for this version (replacing?.?.?with the version number):gittag?.?.?gitpushorigin?.?.?Remove any old build/distribution files. Then, package the source into a distribution archive:rm-rfbuilddistsrc/*.egg-infopython-mbuild--sdist--wheel.Finally, upload the package distribution archive toPyPI:python-mtwineuploaddist/*