Skip to content

Commit

Permalink
Merge pull request #117 from HIIT/optional_imports
Browse files Browse the repository at this point in the history
Optional imports + version numbering + PyPI
  • Loading branch information
vuolleko committed Jan 31, 2017
2 parents a05e9c0 + c02153d commit a827e1c
Show file tree
Hide file tree
Showing 12 changed files with 105 additions and 76 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.ipynb linguist-documentation
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.
59 changes: 22 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,10 @@
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)
[![Gitter chat](https://badges.gitter.im/HIIT/elfi.svg)](https://gitter.im/HIIT/elfi?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)

<img src="https://cloud.githubusercontent.com/assets/1233418/20178983/6e22ee44-a75c-11e6-8345-5934b55b9dc6.png" width="15%" align="right"></img>

Expand All @@ -28,37 +17,33 @@ Currently implemented ABC methods:
- sequential Monte Carlo sampler
- [Bayesian Optimization for Likelihood-Free Inference (BOLFI) framework](http://jmlr.csail.mit.edu/papers/v17/15-017.html)

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.
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.
39 changes: 28 additions & 11 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,43 @@
Installation
============

To install ELFI, run this command in your terminal:

.. Stable release
.. --------------
pip install elfi

.. To install ELFI, run this command in your terminal:
If you don't have `pip`_ installed, this `Python installation guide`_ can guide
you through the process.

.. .. code-block:: console
.. _pip: https://pip.pypa.io
.. _Python installation guide: http://docs.python-guide.org/en/latest/starting/installation/

.. $ pip install elfi

.. This is the preferred method to install ELFI, as it will always install the most recent stable release.
ELFI is currently tested only with Python 3.5. If you are new to Python, perhaps the simplest way to install it is Anaconda_

.. If you don't have `pip`_ installed, this `Python installation guide`_ can guide
.. you through the process.
.. _Anaconda: https://www.continuum.io/downloads

.. .. _pip: https://pip.pypa.io
.. .. _Python installation guide: http://docs.python-guide.org/en/latest/starting/installation/
Currently it is required to use Distributed 1.14.3.


Virtual environment using Anaconda
----------------------------------

If you want to create a virtual environment before installing, you can do so with Anaconda:

conda create -n elfi python=3.5 scipy
source activate elfi
pip install 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.

From sources
------------

Expand All @@ -46,6 +64,5 @@ Once you have a copy of the source, you can install it with:
$ 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.
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__ = 'elfi-support@hiit.fi'
__version__ = '0.3_dev'

# 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
46 changes: 25 additions & 21 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',
packages=['elfi'],
version='0.2.x_dev',
keywords='abc likelihood-free statistics',
packages=packages,
version=__version__,
author='HIIT',
author_email='elfi-support@hiit.fi',
url='https://github.com/HIIT/elfi',
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',
classifiers=['Programming Language :: Python :: 3.5',
'Topic :: Scientific/Engineering',
'Topic :: Scientific/Engineering :: Bio-Informatics',
'Programming Language :: Python :: 3'
'Operating System :: OS Independent',
'Development Status :: 2 - Pre-Alpha',
'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 a827e1c

Please sign in to comment.