diff --git a/.travis.yml b/.travis.yml index 5cbe7c00..35d31f2b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -65,8 +65,8 @@ deploy: password: secure: "vMEOlP7DQhFJ7hQAKtKC5hrJXFl5BkUt4nXdosWWiw//Kg8E+PPLg88XPI2gqIosir9wwgtbSBBbbwCxkM6uxRNMpoNR8Ixyv9fmSXp4rLl7bbBY768W7IRXKIBjpuEy2brQjoT+CwDDSzUkckHvuUjJDNRvUv8ab4P/qYO1LG4=" on: - tags: true + #tags: true branch: plot_density - server: https://testpypi.python.org/pypi + #server: https://testpypi.python.org/pypi distributions: "bdist_wheel sdist" skip_cleanup: true diff --git a/GPy/__version__.py b/GPy/__version__.py index 64b3f18e..21311fc4 100644 --- a/GPy/__version__.py +++ b/GPy/__version__.py @@ -1 +1 @@ -__version__ = "0.8.8dev1" +__version__ = "0.8.8dev0" diff --git a/README.md b/README.md index f8ef8961..15c405c4 100644 --- a/README.md +++ b/README.md @@ -9,21 +9,26 @@ The Gaussian processes framework in Python. * [Unit tests (Travis-CI)](https://travis-ci.org/SheffieldML/GPy) * [![licence](https://img.shields.io/badge/licence-BSD-blue.svg)](http://opensource.org/licenses/BSD-3-Clause) -#### Continuous integration +## Continuous integration + | | Travis-CI | Codecov | -| ---: | :--: | :---: | -| **master:** | [![master](https://travis-ci.org/SheffieldML/GPy.svg?branch=master)](https://travis-ci.org/SheffieldML/GPy) | [![codecov.io](http://codecov.io/github/SheffieldML/GPy/coverage.svg?branch=master)](http://codecov.io/github/SheffieldML/GPy?branch=master) | -| **devel:** | [![devel](https://travis-ci.org/SheffieldML/GPy.svg?branch=devel)](https://travis-ci.org/SheffieldML/GPy) | [![codecov.io](http://codecov.io/github/SheffieldML/GPy/coverage.svg?branch=devel)](http://codecov.io/github/SheffieldML/GPy?branch=devel) | +| ---: | :--: | :---: | +| **master:** | [![master](https://travis-ci.org/SheffieldML/GPy.svg?branch=master)](https://travis-ci.org/SheffieldML/GPy) | [![codecov.io master](http://codecov.io/github/SheffieldML/GPy/coverage.svg?branch=master)](http://codecov.io/github/SheffieldML/GPy?branch=master) | +| **devel:** | [![devel](https://travis-ci.org/SheffieldML/GPy.svg?branch=devel)](https://travis-ci.org/SheffieldML/GPy) | [![codecov.io devel](http://codecov.io/github/SheffieldML/GPy/coverage.svg?branch=devel)](http://codecov.io/github/SheffieldML/GPy?branch=devel) | -### Supported Platforms: +## Supported Platforms: + +[](https://www.python.org/) +[](http://www.microsoft.com/en-gb/windows) +[](http://www.apple.com/osx/) +[](https://en.wikipedia.org/wiki/List_of_Linux_distributions) -[](https://www.python.org/) [](http://www.microsoft.com/en-gb/windows) [](http://www.apple.com/osx/) [](https://en.wikipedia.org/wiki/List_of_Linux_distributions) ---- Python 2.7, 3.3 and higher -### Citation +## Citation @Misc{gpy2014, author = {{The GPy authors}}, @@ -36,7 +41,7 @@ Python 2.7, 3.3 and higher We like to pronounce it 'g-pie'. -### Getting started: installing with pip +## Getting started: installing with pip We are now requiring the newest version (0.16) of [scipy](http://www.scipy.org/) and thus, we strongly recommend using @@ -87,7 +92,7 @@ or using setuptools python setup.py test -### Ubuntu hackers +## Ubuntu hackers > Note: Right now the Ubuntu package index does not include scipy 0.16.0, and thus, cannot > be used for GPy. We hope this gets fixed soon. @@ -102,20 +107,20 @@ clone this git repository and add it to your path: echo 'PYTHONPATH=$PYTHONPATH:~/SheffieldML' >> ~/.bashrc -### Compiling documentation: +## Compiling documentation: The documentation is stored in doc/ and is compiled with the Sphinx Python documentation generator, and is written in the reStructuredText format. The Sphinx documentation is available here: http://sphinx-doc.org/latest/contents.html -##### Installing dependencies: +**Installing dependencies:** To compile the documentation, first ensure that Sphinx is installed. On Debian-based systems, this can be achieved as follows: sudo apt-get install python-pip sudo pip install sphinx -##### Compiling documentation: +**Compiling documentation:** The documentation can be compiled as follows: @@ -127,7 +132,6 @@ The HTML files are then stored in doc/build/html ## Funding Acknowledgements - Current support for the GPy software is coming through the following projects. * [EU FP7-HEALTH Project Ref 305626](http://radiant-project.eu) "RADIANT: Rapid Development and Distribution of Statistical Tools for High-Throughput Sequencing Data" @@ -139,7 +143,8 @@ Current support for the GPy software is coming through the following projects. * [EU FP7-ICT Project Ref 612139](http://staffwww.dcs.shef.ac.uk/people/N.Lawrence/projects/wysiwyd/) "WYSIWYD: What You Say is What You Did" Previous support for the GPy software came from the following projects: -* [BBSRC Project No BB/K011197/1](http://staffwww.dcs.shef.ac.uk/people/N.Lawrence/projects/recombinant/) "Linking recombinant gene sequence to protein product manufacturability using CHO cell genomic resources" -* [EU FP7-KBBE Project Ref 289434](http://staffwww.dcs.shef.ac.uk/people/N.Lawrence/projects/biopredyn/) "From Data to Models: New Bioinformatics Methods and Tools for Data-Driven Predictive Dynamic Modelling in Biotechnological Applications" -* [BBSRC Project No BB/H018123/2](http://staffwww.dcs.shef.ac.uk/people/N.Lawrence/projects/iterative/) "An iterative pipeline of computational modelling and experimental design for uncovering gene regulatory networks in vertebrates" -* [Erasysbio](http://staffwww.dcs.shef.ac.uk/people/N.Lawrence/projects/synergy/) "SYNERGY: Systems approach to gene regulation biology through nuclear receptors" + +- [BBSRC Project No BB/K011197/1](http://staffwww.dcs.shef.ac.uk/people/N.Lawrence/projects/recombinant/) "Linking recombinant gene sequence to protein product manufacturability using CHO cell genomic resources" +- [EU FP7-KBBE Project Ref 289434](http://staffwww.dcs.shef.ac.uk/people/N.Lawrence/projects/biopredyn/) "From Data to Models: New Bioinformatics Methods and Tools for Data-Driven Predictive Dynamic Modelling in Biotechnological Applications" +- [BBSRC Project No BB/H018123/2](http://staffwww.dcs.shef.ac.uk/people/N.Lawrence/projects/iterative/) "An iterative pipeline of computational modelling and experimental design for uncovering gene regulatory networks in vertebrates" +- [Erasysbio](http://staffwww.dcs.shef.ac.uk/people/N.Lawrence/projects/synergy/) "SYNERGY: Systems approach to gene regulation biology through nuclear receptors" diff --git a/doc/source/tuto_plotting.rst b/doc/source/tuto_plotting.rst new file mode 100644 index 00000000..adf00b66 --- /dev/null +++ b/doc/source/tuto_plotting.rst @@ -0,0 +1,91 @@ +******************** +Defining a new plotting function in GPy +******************** + +GPy has a wrapper for different plotting backends. +There are some functions you can use for standard plotting. +Anything going beyond the scope of the +:py:class:`~GPy.plotting.abstract_plotting_library.AbstractPlottingLibrary` classes plot definitions +should be considered carefully and maybe is a special case for your plotting library only. + +All plotting related code lives in :py:mod:`GPy.plotting` and beneath. No plotting related code needs to be +anywhere else in GPy. + +As examples are always the easiest way to learn how to, we +will implement an example of a plotting function, which plots the covariance of a kernel. + +Write your plotting function into a module under :py:mod:`GPy.plotting.gpy_plot` ``.`` +using the plotting routines provided in :py:func:`GPy.plotting.plotting_library`. +I like to ``from . import plotting_library as pl`` and the allways use ``pl().`` to access functionality of +the plotting library. + +For the covariance plot we define the function in :py:mod:`GPy.plotting.kernel_plots`. + +The first thing is to define the function parameters *and write the documentation for them*! +The first argument of the plotting function is always ``self`` for the class this plotting function +will be attached to (we will get to attaching the function to a class that in detail later on):: + + def plot_covariance(kernel, x=None, label=None, + plot_limits=None, visible_dims=None, resolution=None, + projection=None, levels=20, **kwargs): + """ + Plot a kernel covariance w.r.t. another x. + + :param array-like x: the value to use for the other kernel argument (kernels are a function of two variables!) + :param plot_limits: the range over which to plot the kernel + :type plot_limits: Either (xmin, xmax) for 1D or (xmin, xmax, ymin, ymax) / ((xmin, xmax), (ymin, ymax)) for 2D + :param array-like visible_dims: input dimensions (!) to use for x. Make sure to select 2 or less dimensions to plot. + :resolution: the resolution of the lines used in plotting. for 2D this defines the grid for kernel evaluation. + :param {2d|3d} projection: What projection shall we use to plot the kernel? + :param int levels: for 2D projection, how many levels for the contour plot to use? + :param kwargs: valid kwargs for your specific plotting library + """ + +Having defined the outline of the function we can start implementing +the real plotting. + +First, we will write the necessary logic behind getting the covariance function. +This involves getting an Xgrid to plot with and the second x to compare the covariance to:: + + from .plot_util import helper_for_plot_data + X = np.ones((2, kernel.input_dim)) * [-4, 4] + _, free_dims, Xgrid, xx, yy, _, _, resolution = helper_for_plot_data(kernel, X, plot_limits, visible_dims, None, resolution) + from numbers import Number + if x is None: + x = np.zeros((1, kernel.input_dim)) + elif isinstance(x, Number): + x = np.ones((1, kernel.input_dim))*x + K = kernel.K(Xgrid, x) + +``free_dims`` holds the free dimensions after selecting +from the visible_dims, ``Xgrid`` is the grid for the covariance, +``xx, yy`` are the grid positions for 2D plotting and ``x`` is the +``X2`` for the kernel and ``K`` holds the kernel covariance for +all positions between ``Xgrid`` and ``x``. + +Then we need a canvas to plot on. Always push the keyword arguments +of the specifig library through :py:func:`GPy.plotting.abstract_plotting_library.AbstractPlottingLibrary.new_canvas`:: + + if projection == '3d': + zlabel = "k(X, {!s})" % (np.asanyarray(x).tolist()) + xlabel = 'X[:,0]' + ylabel = 'X[:,1]' + else: + xlabel = 'X' + ylabel = "k(X, {!s})" % (np.asanyarray(x).tolist()) + + canvas, kwargs = pl().new_canvas(projection=projection, xlabel=xlabel, ylabel=ylabel, zlabel=zlabel, **kwargs) + +Also very important is to use the defaults, which are defined for all plotting libraries implemented. +This is done by updating the ``kwargs`` from the defaults. There is a helper function +which takes care for existing keyword arguments. In this case we will just use the default for +plotting a mean function for the covariance plot as well. If you want to define your own defaults +add them to the defaults for each library and add it in here. See for example the defaults for +matplotlib in :py:mod:`GPy.plotting.matplot_dep.defaults`. There is also the default for the +meanplot_1d, which we are for the 1d plot:: + + from .plot_util import update_not_existing_kwargs + update_not_existing_kwargs(kwargs, pl().defaults.meanplot_1d) # @UndefinedVariable + +The full definition of the plotting then looks like this:: + diff --git a/setup.cfg b/setup.cfg index 59497875..d79d8bbd 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.8.8dev1 +current_version = 0.8.8dev0 tag = True commit = True diff --git a/setup.py b/setup.py index dfab2663..ed7e8296 100644 --- a/setup.py +++ b/setup.py @@ -42,7 +42,7 @@ import numpy as np import codecs def read(fname): - with codecs.open(fname, 'r', 'utf-8') as f: + with codecs.open(fname, 'r', 'latin') as f: return f.read() def read_to_rst(fname):