Skip to content

Commit

Permalink
v0.1.0 (#9)
Browse files Browse the repository at this point in the history
* Set version to 0.0.1

* Integrate class docstrings for BDM variants

* Add some defensing programming and tests for BDM initialization

* Start documentation process

* Add tests for probability normalization in D1 and commented in D2 (D2 does not pass probably since the 2D ruleset is much bigger and is not entirely covered with small dataset parts)

* Add docstrings to theory tests

* Minor fix

* Remove nbdm and nent methods; use normalize flag in the main bdm and ent methods instead

* Add better data checks to bdm and ent methods (controlled by 'normalize' flag)

* Implement functions for iterating over slices and datasets parts in an easy manner

* Reimplement normalized bdm/ent so it has lower memory footprint and is slightly faster (no need for calling partition method on artifical datasets)

* Raise NotImplementedError in normalized bdm/ent for BDMBase with positive shift

* Add preliminary version of documentation

* Use version 0.1.0

* Implement partition algorithm classes + simplify slicing utils

* BDM class reimplemented

* Rename boundary attribute in the BDM class to partition and rename partition method to decompose (both in BDM and Partition classes)

* Start rewriting the docs

* Add global package options

* Rename the package to pybdm

* Fix docs

* Add docs + minor changes in perturbation experiment

* Main docs finish / module docs are yet to be done

* Fix BDM docs + add slight API changes

* Finish docs

* Change history and minor fixes in the docs

* Add separate requirements for sphinx builds

* Add docs status badges

* Minor changes to the docs

* Add tests for multiplt OS on Travis CI

* Run Travis tests only agains linux and osx

* Remove tox-conda from requirements.txt

* Simplify travis config

* Minor fixes

* Remove tests for OSX
  • Loading branch information
sztal authored Sep 22, 2019
1 parent 19d9ccf commit 4bedea1
Show file tree
Hide file tree
Showing 58 changed files with 2,353 additions and 1,194 deletions.
32 changes: 26 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,40 @@
# Config file for automatic testing at travis-ci.org
dist: bionic
language: python

dist: bionic
python:
- "3.7"
- "3.6"
# - "3.5"
- 3.5
- 3.6
- 3.7

# command to install dependencies, e.g. pip install -r requirements.txt --use-mirrors
install:
- pip install -r requirements.txt
- pip install .

# matrix:
# include:
# - os: osx
# language: minimal
# python: 3.7
# install:
# - pip3 install -r requirements.txt
# - pip3 install -e .[tests]
# script:
# - pytest --slow
# - os: windows
# language: minimal
# python:
# - "3.5"
# - "3.6"
# - "3.7"
# before_install:
# - choco install python3
# - export PATH="/c/Python37:/c/Python37/Scripts:$PATH"

# command to run tests, e.g. python setup.py test
script:
- pytest --slow --cov-report term --cov=bdm/ --cov=test/
- pytest --slow --cov-report term --cov=pybdm/ --cov=tests/
- pytest --pylint -m pylint

after_success:
- codecov
9 changes: 7 additions & 2 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@
Authors
=======

Core Team
---------
Core Team (AlgoDyn Development Team)
------------------------------------

* Szymon Talaga <[email protected]>
* Kostas Tsampourakis <[email protected]>

Maintainer
----------

* Szymon Talaga <[email protected]>

Contributors
------------

Expand Down
2 changes: 1 addition & 1 deletion HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
History
-------

0.0.0 (2019-01-01)
0.1.0 (2019-09-22)
++++++++++++++++++

* First release on PyPI.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2018 Szymon Talaga
Copyright (c) 2019 Szymon Talaga

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
Expand Down
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ include CONTRIBUTING.rst
include HISTORY.rst
include LICENSE
include README.rst
recursive-include bdm/ctmdata *
recursive-include pybdm/ctmdata *
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ clean-pyc:
clean-misc:
find . -name '.benchmarks' -exec rm -rf {} +
find . -name '.pytest-cache' -exec rm -rf {} +
rm .coverage*
rm -f .coverage*

lint:
py.test --pylint -m pylint
Expand All @@ -38,16 +38,16 @@ test-all:
tox

coverage:
coverage run --source bdm setup.py test
coverage run --source pybdm setup.py test
coverage report -m
coverage html
xdg-open htmlcov/index.html
# open htmlcov/index.html

docs:
rm -f docs/bdm.rst
rm -f docs/pybdm.rst
rm -f docs/modules.rst
sphinx-apidoc -o docs/ bdm
sphinx-apidoc -o docs/ pybdm
$(MAKE) -C docs clean
$(MAKE) -C docs html
xdg-open docs/_build/html/index.html
Expand Down
79 changes: 62 additions & 17 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
=============================================================
PyBDM: Python interface to the *Block Deincomposition Method*
PyBDM: Python interface to the *Block Decomposition Method*
=============================================================

.. image:: https://badge.fury.io/py/pybdm.png
Expand All @@ -11,6 +11,10 @@ PyBDM: Python interface to the *Block Deincomposition Method*
.. image:: https://codecov.io/gh/sztal/pybdm/branch/master/graph/badge.svg?branch=master
:target: https://codecov.io/gh/sztal/pybdm

.. image:: https://readthedocs.org/projects/pybdm-docs/badge/?version=latest
:target: https://pybdm-docs.readthedocs.io/en/latest/?badge=latest
:alt: Documentation Status

The Block Decomposition Method (BDM) approximates algorithmic complexity
of a dataset of arbitrary size, that is, the length of the shortest computer
program that generates it. This is not trivial as algorithmic complexity
Expand All @@ -20,28 +24,38 @@ mechanistic connections between elements of a system, even such that
do not yield any regular statistical patterns that can be captured with
more traditional tools based on probability theory and information theory.

Currently 1D and 2D binary arrays are supported, but this may be extended to higher dimensionalities and more complex alphabets in the future.
Currently 1D and 2D binary arrays are supported, as well as 1D arrays
with 4, 5, 6 and 9 discrete symbols.

BDM and the necessary parts of the algorithmic information theory
it is based on are described in `this paper <https://www.mdpi.com/1099-4300/20/8/605>`__.
it is based on are described in `this article <https://www.mdpi.com/1099-4300/20/8/605>`_.

See the official documentation_ for more information.


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

Standard installation (stable)::

pip install pybdm

Development version installation::

pip install git+https://github.com/sztal/pybdm.git

Local development::

git clone https://github.com/sztal/pybdm
cd pybdm
pip install --editable .

Development version installation::

pip install git+https://github.com/sztal/pybdm.git

Standard installation (not yet on *PyPI*)::
Supported versions
------------------

pip install bdm
Python3.5+ is supported. Tests are run against Linux, but
Windows and OSX should work as well.


Usage
Expand All @@ -56,14 +70,16 @@ input represented as `Numpy <http://www.numpy.org/>`__ arrays of integer type.
Hence, any alphabet must be first mapped to a set of integers ranging
from ``0`` to ``k``.

Detailed usage examples can be found in the official documentation_.


Binary sequences (1D)
---------------------

.. code-block:: python
import numpy as np
from bdm import BDM
from pybdm import BDM
# Create a dataset (must be of integer type)
X = np.ones((100,), dtype=int)
Expand All @@ -85,7 +101,7 @@ Binary matrices (2D)
.. code-block:: python
import numpy as np
from bdm import BDM
from pybdm import BDM
# Create a dataset (must be of integer type)
X = np.ones((100, 100), dtype=int)
Expand All @@ -99,6 +115,25 @@ Binary matrices (2D)
# BDM objects may also compute standard Shannon entropy in base 2
bdm.ent(X)
Non-binary sequences (1D)
-------------------------

.. code-block:: python
import numpy as np
from pybdm import BDM
# Create a dataset (4 discrete symbols)
np.random.seed(303)
X = np.random.randint(0, 4, (100,))
# Initialize BDM object with 4-symbols alphabet
bdm = BDM(ndim=1, nsymbols=4)
# Compute BDM
bdm.bdm(X)
Parallel processing
-------------------
Expand All @@ -113,22 +148,29 @@ compute so-called counter objects (final BDM computation operates on such object
in parallel in 4 independent processes, and aggregate the results
into a single BDM approximation of the algorithmic complexity of the dataset.

.. highlights::

Remember that data has to be sliced correctly during parallelization
in order to ensure fully correct BDM computations. That is, all slices
except lower and right boundaries have to be decomposable without
any boundary leftovers by the selected decomposition algorithm.

.. code-block:: python
import numpy as np
from joblib import Parallel, delayed
from bdm import BDM
from bdm.utils import slice_dataset
from pybdm import BDM
from pybdm.utils import decompose_dataset
# Create a dataset (must be of integer type)
X = np.ones((1000, 1000), dtype=int)
# Initialize BDM object
BDM = bdm(ndim=2)
bdm = BDM(ndim=2)
# Compute counter objects in parallel
counters = Parallel(n_jobs=4) \
(delayed(bdm.lookup_and_count)(d) for d in slice_dataset(X, (200, 200)))
(delayed(bdm.decompose_and_count)(d) for d in decompose_dataset(X, (200, 200)))
# Compute BDM
bdm.compute_bdm(*counters)
Expand All @@ -155,14 +197,14 @@ to be noise since they extend the system's description length.
.. code-block:: python
import numpy as np
from bdm import BDM
from bdm.algorithms import PerturbationExperiment
from pybdm import BDM
from pybdm.algorithms import PerturbationExperiment
# Create a dataset (must be of integer type)
X = np.ones((100, 100), dtype=int)
# Initialize BDM object
BDM = bdm(ndim=2)
bdm = BDM(ndim=2)
# Initialize perturbation experiment object
# (may be run for both bdm or entropy)
Expand All @@ -186,3 +228,6 @@ Authors & Contact

* Szymon Talaga <[email protected]>
* Kostas Tsampourakis <[email protected]>


.. _documentation: http://pybdm-docs.rtfd.org
14 changes: 0 additions & 14 deletions bdm/__init__.py

This file was deleted.

Loading

0 comments on commit 4bedea1

Please sign in to comment.