Skip to content

Commit

Permalink
Merge pull request #118 from HIIT/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
vuolleko authored Jan 31, 2017
2 parents ceb81a0 + c9ecfe4 commit 3cc054f
Show file tree
Hide file tree
Showing 11 changed files with 105 additions and 74 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
Empty file added MANIFEST.in
Empty file.
55 changes: 19 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,6 @@
ELFI - Engine for Likelihood-Free Inference
===========================================

<!-- .. image:: https://img.shields.io/pypi/v/elfi.svg
:target: https://pypi.python.org/pypi/elfi
.. image:: https://img.shields.io/travis/HIIT/elfi.svg
:target: https://travis-ci.com/HIIT/elfi
.. image:: https://readthedocs.org/projects/elfi/badge/?version=latest
:target: https://elfi.readthedocs.io/en/latest/?badge=latest
:alt: Documentation Status
https://github.com/dwyl/repo-badges
-->

[![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)
Expand All @@ -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.

<!-- ..
Installation
-------------
::
pip install elfi
-->

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.
50 changes: 36 additions & 14 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
------------
Expand All @@ -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
3 changes: 2 additions & 1 deletion docs/readme.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
4 changes: 3 additions & 1 deletion elfi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@

__author__ = 'ELFI authors'
__email__ = '[email protected]'
__version__ = '0.3'

# make sure __version_ is on the last non-empty line (read by setup.py)
__version__ = '0.3.1'
7 changes: 6 additions & 1 deletion elfi/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand Down Expand Up @@ -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)))
Expand Down
7 changes: 6 additions & 1 deletion elfi/visualization.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from graphviz import Digraph
import numpy as np
import matplotlib.pyplot as plt
from collections import OrderedDict
Expand All @@ -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
Expand All @@ -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
Expand Down
5 changes: 4 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[wheel]
universal = 1
universal = 0

[flake8]
exclude = .git,
Expand All @@ -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
38 changes: 21 additions & 17 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,49 +1,53 @@
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='[email protected]',
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',
'Topic :: Scientific/Engineering :: Bio-Informatics',
'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)

0 comments on commit 3cc054f

Please sign in to comment.