diff --git a/.travis.yml b/.travis.yml index 5bc1e770..826b7531 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ install: - pip install numpy - pip install cython - pip install -r requirements-dev.txt - - pip install -e . + - pip install -e .[nosql] # command to run tests script: - make test diff --git a/CHANGELOG.md b/CHANGELOG.md index 2dff0d06..7f93c3ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,13 @@ # Change Log -## 0.2.2 - 0.3 +0.3.1 (2017-01-31) +------------------ +- Clean up requirements +- Set graphviz and unqlite optional +- PyPI release (pip install elfi) +0.2.2 - 0.3 +----------- - The inference problem is now contained in an Inference Task object. - SMC-ABC has been reimplemented. - Results from inference are now contained in a Result object. diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 00000000..e69de29b diff --git a/README.md b/README.md index 953844b8..4e1f0cc5 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,6 @@ ELFI - Engine for Likelihood-Free Inference =========================================== - - [![Build Status](https://travis-ci.org/HIIT/elfi.svg?branch=master)](https://travis-ci.org/HIIT/elfi) [![Code Health](https://landscape.io/github/HIIT/elfi/master/landscape.svg?style=flat)](https://landscape.io/github/HIIT/elfi/master) [![Documentation Status](https://readthedocs.org/projects/elfi/badge/?version=latest)](http://elfi.readthedocs.io/en/latest/?badge=latest) @@ -32,35 +19,31 @@ Currently implemented ABC methods: See examples under [notebooks](notebooks) to get started. Full documentation can be found at http://elfi.readthedocs.io/. Limited user-support may be asked from elfi-support.at.hiit.fi, but the [Gitter chat](https://gitter.im/HIIT/elfi?utm_source=share-link&utm_medium=link&utm_campaign=share-link) is preferable. - - -Developer installation ----------------------- -ELFI is currently tested only with Python 3.5. If you are new to Python, perhaps the simplest way to install it is [Anaconda](https://www.continuum.io/downloads). -Currently we recommend using Distributed 1.14.3. +Installation +------------ ``` -git clone https://github.com/HIIT/elfi.git -cd elfi -pip install numpy -pip install -r requirements-dev.txt -pip install -e . +pip install elfi ``` -It is recommended to create a virtual environment for development before installing. +ELFI is currently tested only with Python 3.5. If you are new to Python, perhaps the simplest way to install it is [Anaconda](https://www.continuum.io/downloads). + +Currently it is required to use Distributed 1.14.3. Virtual environment using Anaconda ---------------------------------- -Below an example how to create a virtual environment named ``elfi`` using Anaconda: - - conda create -n elfi python=3* scipy +If you want to create a virtual environment before installing, you can do so with Anaconda: -Then activate it: +``` +conda create -n elfi python=3.5 scipy +source activate elfi +pip install elfi +``` - source activate elfi +Potential problems with installation +------------------------------------ +ELFI depends on several other Python packages, which have their own dependencies. Resolving these may sometimes go wrong: +- If you receive an error about missing `numpy`, please install it first. +- If you receive an error about `yaml.load`, install `pyyaml`. +- On OS X with Anaconda virtual environment say `conda install python.app` and then use `pythonw` instead of `python`. +- Note that ELFI currently supports Python 3.5 only, although 3.x may work as well. diff --git a/docs/installation.rst b/docs/installation.rst index 6c64610b..ea9bded2 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -4,24 +4,47 @@ Installation ============ +To install ELFI, run this command in your terminal: -.. Stable release -.. -------------- +.. code-block:: console + + pip install elfi + +If you don't have `pip`_ installed, this `Python installation guide`_ can guide +you through the process. + +.. _pip: https://pip.pypa.io +.. _Python installation guide: http://docs.python-guide.org/en/latest/starting/installation/ + + +ELFI is currently tested only with Python 3.5. If you are new to Python, perhaps the simplest way to install it is Anaconda_ -.. To install ELFI, run this command in your terminal: +.. _Anaconda: https://www.continuum.io/downloads -.. .. code-block:: console +Currently it is required to use Distributed 1.14.3. -.. $ pip install elfi -.. This is the preferred method to install ELFI, as it will always install the most recent stable release. +Virtual environment using Anaconda +---------------------------------- -.. If you don't have `pip`_ installed, this `Python installation guide`_ can guide -.. you through the process. +If you want to create a virtual environment before installing, you can do so with Anaconda: + +.. code-block:: console + + conda create -n elfi python=3.5 scipy + source activate elfi + pip install elfi -.. .. _pip: https://pip.pypa.io -.. .. _Python installation guide: http://docs.python-guide.org/en/latest/starting/installation/ +Potential problems with installation +------------------------------------ + +ELFI depends on several other Python packages, which have their own dependencies. Resolving these may sometimes go wrong: + +* If you receive an error about missing `numpy`, please install it first. +* If you receive an error about `yaml.load`, install `pyyaml`. +* On OS X with Anaconda virtual environment say `conda install python.app` and then use `pythonw` instead of `python`. +* Note that ELFI currently supports Python 3.5 only, although 3.x may work as well. From sources ------------ @@ -32,20 +55,19 @@ You can either clone the public repository: .. code-block:: console - $ git clone https://github.com/HIIT/elfi.git + git clone https://github.com/HIIT/elfi.git Or download the `tarball`_: .. code-block:: console - $ curl -OL https://github.com/HIIT/elfi/tarball/master + curl -OL https://github.com/HIIT/elfi/tarball/master Once you have a copy of the source, you can install it with: .. code-block:: console - $ python setup.py install - + python setup.py install .. _Github repo: https://github.com/HIIT/elfi .. _tarball: https://github.com/HIIT/elfi/tarball/master diff --git a/docs/readme.rst b/docs/readme.rst index 38dd21a7..e210a097 100644 --- a/docs/readme.rst +++ b/docs/readme.rst @@ -19,9 +19,10 @@ Currently implemented ABC methods: GitHub page: https://github.com/HIIT/elfi -See examples under the notebooks_ directory to get started. Limited user-support may be asked from elfi-support.at.hiit.fi, but the [Gitter chat](https://gitter.im/HIIT/elfi?utm_source=share-link&utm_medium=link&utm_campaign=share-link) is preferable. +See examples under the notebooks_ directory to get started. Limited user-support may be asked from elfi-support.at.hiit.fi, but the `Gitter chat`_ is preferable. .. _notebooks: https://github.com/HIIT/elfi/tree/master/notebooks +.. _Gitter chat: https://gitter.im/HIIT/elfi?utm_source=share-link&utm_medium=link&utm_campaign=share-link Licenses: diff --git a/elfi/__init__.py b/elfi/__init__.py index 71cb189a..9a20b10c 100644 --- a/elfi/__init__.py +++ b/elfi/__init__.py @@ -12,4 +12,6 @@ __author__ = 'ELFI authors' __email__ = 'elfi-support@hiit.fi' -__version__ = '0.3' + +# make sure __version_ is on the last non-empty line (read by setup.py) +__version__ = '0.3.1' diff --git a/elfi/storage.py b/elfi/storage.py index 836e3bb5..671f8fde 100644 --- a/elfi/storage.py +++ b/elfi/storage.py @@ -16,7 +16,6 @@ from elfi.utils import to_slice, get_key_slice, get_key_id, get_named_item, make_key import elfi.env as env -from unqlite import UnQLite logger = logging.getLogger(__name__) @@ -545,6 +544,12 @@ class UnQLiteDatabase(): """ def __init__(self, location=None): + + try: + from unqlite import UnQLite + except ImportError: + raise ImportError("The unqlite library is required for this feature.") + self.location = location if type(self.location) == str and len(self.location) > 0: logger.debug("Connecting to database at {}".format(os.path.abspath(location))) diff --git a/elfi/visualization.py b/elfi/visualization.py index 174fdad9..61f45208 100644 --- a/elfi/visualization.py +++ b/elfi/visualization.py @@ -1,4 +1,3 @@ -from graphviz import Digraph import numpy as np import matplotlib.pyplot as plt from collections import OrderedDict @@ -10,6 +9,8 @@ def draw_model(discrepancy_node, draw_constants=False, filename=None): """ Return a GraphViz dot representation of the model. + Requires the optional 'graphviz' library. + Parameters ---------- discrepancy_node : Node @@ -20,6 +21,10 @@ def draw_model(discrepancy_node, draw_constants=False, filename=None): If given, save the dot file into the given filename, trying to guess the type. For example: 'mymodel.png'. """ + try: + from graphviz import Digraph + except ImportError: + raise ImportError("The graphviz library is required for this feature.") # gather the set of nodes, excluding Constants nodes = discrepancy_node.component diff --git a/setup.cfg b/setup.cfg index 449572a0..c629ce25 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [wheel] -universal = 1 +universal = 0 [flake8] exclude = .git, @@ -18,3 +18,6 @@ multi_line_output = 0 [tool:pytest] addopts = --doctest-modules testpaths = elfi tests + +[zest.releaser] +python-file-with-version = elfi/__init__.py diff --git a/setup.py b/setup.py index c6f45fcc..3dd772ca 100644 --- a/setup.py +++ b/setup.py @@ -1,44 +1,47 @@ import os -from setuptools import setup +from setuptools import setup, find_packages from io import open -with open('README.md', 'r', encoding='utf-8') as f: + +with open('docs/readme.rst', 'r', encoding='utf-8') as f: long_description = f.read() +packages = ['elfi'] + ['elfi.' + p for p in find_packages('elfi')] + requirements = [ - 'toolz>=0.8', 'distributed==1.14.3', - 'graphviz>=0.5', - 'cairocffi>=0.7', 'dask>=0.11.1', - 'sobol_seq>=0.1.2', 'numpy>=1.8', 'scipy>=0.16.1', - 'Cython>=0.25.1', 'matplotlib>=1.1', - 'GPy>=1.0.9', - 'unqlite>=0.6.0' + 'GPy>=1.0.9' ] +optionals = { + 'doc': ['Sphinx'], + 'nosql': ['unqlite>=0.6.0'], + 'graphviz': ['graphviz>=0.5'] +} + +# read version number +__version__ = open('elfi/__init__.py').readlines()[-1].split(' ')[-1].strip().strip("'\"") + setup( name='elfi', keywords='abc likelihood-free statistics', - packages=['elfi'], - version='0.3', + packages=packages, + version=__version__, author='HIIT', author_email='elfi-support@hiit.fi', url='http://elfi.readthedocs.io', install_requires=requirements, - - extras_require={ - 'doc': ['Sphinx'], - }, + extras_require=optionals, description='Modular ABC inference framework for python', long_description=long_description, - license='BSD3', + license='BSD', classifiers=['Programming Language :: Python :: 3.5', 'Topic :: Scientific/Engineering', @@ -46,4 +49,5 @@ 'Operating System :: OS Independent', 'Development Status :: 3 - Alpha', 'Intended Audience :: Science/Research', - 'License :: OSI Approved :: BSD3 License']) + 'License :: OSI Approved :: BSD License'], + zip_safe = False)