Metadata-Version: 2.1
Name: covertable
Version: 2.0.1
Summary: It makes combinations covering pairs for pairwise testing.
Home-page: https://github.com/walkframe/covertable/
Author: righ
Author-email: righ.m9@gmail.com
License: Apache Software License
Keywords: allpair,all-pair,allpairs,all-pairs,pairwise,N-wise,2-wise,3-wise,two-wise,three-wise,N-term,2-term,3-term,two-term,three-term,pairs,pair,combinatorial,covering-array,covering-arrays,pict
Platform: UNKNOWN
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Information Technology
Classifier: Intended Audience :: Manufacturing
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python
Classifier: Topic :: Software Development

.. image:: https://badge.fury.io/py/covertable.svg
  :target: https://badge.fury.io/py/covertable

.. image:: https://circleci.com/gh/walkframe/covertable.svg?style=shield
  :target: https://circleci.com/gh/walkframe/covertable

.. image:: https://codecov.io/gh/walkframe/covertable/branch/master/graph/badge.svg
  :target: https://codecov.io/gh/walkframe/covertable

.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
  :target: https://github.com/python/black

.. image:: https://img.shields.io/badge/License-Apache%202.0-blue.svg
  :target: https://opensource.org/licenses/Apache-2.0

Requirements
============
- Python: 3.3 or later.

  - Tested with 3.7


Installation
============

.. code:: bash

  $ pip install covertable

Usage
=====
Just import ``covertable`` and call ``make`` function.

.. code-block:: python3

  >>> from covertable import make, sorters, criteria

  >>> machine_list = ['iphone', 'pixel']
  >>> os_list = ['ios', 'android']
  >>> browser_list = ['FireFox', 'Chrome', 'Safari']
  >>> # list input and output
  >>> make(
  ...     [machine_list, os_list, browser_list],  # list factors
  ...     length=2,  # default: 2
  ...     sorter=sorters.random,  # default: sorters.hash
  ...     criterion=criteria.simple,  # default: criteria.greedy
  ...     seed=100,  # default: ''
  ...     pre_filter=lambda row: not(row[1] == 'android' and row[0] != 'pixel') and not(row[1] == 'ios' and row[0] != 'iphone'),  # default: None
  ... )
  [
    ['pixel', 'android', 'Safari'], 
    ['iphone', 'ios', 'Chrome'], 
    ['iphone', 'ios', 'Safari'], 
    ['pixel', 'android', 'Chrome'], 
    ['pixel', 'android', 'FireFox'], 
    ['iphone', 'ios', 'FireFox']
  ]


  >>> # dict input and output
  >>> make(
  ...     {'machine': machine_list, 'os': os_list, 'browser': browser_list},  # dict factors
  ...     length=2,  # default: 2
  ...     tolerance=3,  # default: 0
  ...     post_filter=lambda row: not(row['os'] == 'android' and row['machine'] != 'pixel') and not(row['os'] == 'ios' and row['machine'] != 'iphone'),  # default: None
  ... )
  [
    {'machine': 'pixel', 'browser': 'Chrome', 'os': 'android'}, 
    {'machine': 'pixel', 'browser': 'FireFox', 'os': 'android'}, 
    {'machine': 'iphone', 'os': 'ios', 'browser': 'Chrome'}, 
    {'os': 'ios', 'browser': 'FireFox', 'machine': 'iphone'}
  ]


Options
---------------

``covertable.make`` function has options as keyword argument.

All options are omittable.

length
~~~~~~~~~~~~~~~~
It means length of pair to meet. (default: 2)

The more it increases, the more number of combinations increases.

sorter
~~~~~~~~~~~~~~~~
Combinations depend on the order of spreading all over the rows.

You can choice a sorter from the following:

:sorters.random: 

  This makes different combinations everytime. (fastest)

:sorters.hash: 

  This makes combinations depending on hash of the pair and seed. (default)

  - It receives `seed` and `useCache` options.

    - `seed` option decides the order of storing from unstored pairs, therefore it outputs the same result every time when number of factors and seed are the same.
    - `useCache` option decide if using cache of hash or not. (default: `true`)

      - It is around 10% faster than setting `useCache` **off**.


criterion
~~~~~~~~~~~~~~~~~

:criteria.simple:

  This extracts any pairs that can be stored into the processing row.

:criteria.greedy: 

  This attempts to make most efficient combinations. (default)

  - These combinations are not always shorter than `simple` criterion.
  - It receives `tolerance <https://github.com/walkframe/covertable#tolerance>`__ option.

.. note::

  Not relevant options will be ignored.


pre_filter
~~~~~~~~~~~~~~~~
This means a function to filter beforehand.

It receives an argument `row` as `object` type.

When the function returns `false`, the row combination will not registered.

- If factors type is `Array`, you should specify an index at the subscript like ``row => row[1] < 6``.
- If factors type is `Object`, you should specify a key at the subscript like ``row => row['month'] < 6``

post_filter
~~~~~~~~~~~~~~~~

This means a function to filter later.

Usage is the same as `preFilter`, only the difference is the timing that it is called.
It will delete rows not matched this function at the last.

Development
===============

.. code-block:: sh

  # preparation
  $ python3 -m venv venv
  $ source venv/bin/activate
  (venv) $ pip install -r dev_requirements.txt

  # testing
  (venv) $ tox # -e py37 -e cov -e black


Publish
----------------

.. code-block:: sh

  (venv) $ python setup.py sdist bdist_wheel
  (venv) $ twine upload --repository pypi dist/*


More info
===================

- `walkframe/covertable - GitHub <https://github.com/walkframe/covertable>`__


