Skip to content

Commit

Permalink
Merge pull request #183 from FCS-analysis/develop
Browse files Browse the repository at this point in the history
1.1.1
  • Loading branch information
paulmueller authored May 29, 2018
2 parents 6dd1e42 + 0e22840 commit 67d71e2
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 31 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
1.1.1
- Fix plotting error with LaTeX (thanks @toubol) (#179)
- Update documentation
1.1.0
- BREAKING CHANGE: Move to Python3 (thanks @toubol) (#173)
- GUI:
Expand Down
88 changes: 64 additions & 24 deletions docs/sec_contribute.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,46 +33,86 @@ the PyCorrFit issue page on GitHub such that we may coordinate a pull
request.


For documentation writers
=========================
To build this documentation, fork PyCorrFit, navigate
to the `docs` (not `doc`) directory and run.

- ``pip install -r requirements.txt`` followed by
- ``sphinx-build . _build``.

This will create the html documentation on your computer. Syntax warnings and errors
will be displayed during the build (there should be none). After making your
changes to your forked branch, create a pull request on GitHub.

If you only found a typo or wish to make text-only changes, you can also
use the GitHub interface to edit the files (without testing the build
step on your computer).


For developers
==============
If you would like to know how a contribution to PyCorrFit should look
like, please create an issue on GitHub and I will update this part
of the documentation.


Running from source
-------------------
The easiest way to run PyCorrFit from source is to use
`Anaconda <http://continuum.io/downloads>`_. PyCorrFit requires wxPython which is not
available at the Python package index. Make sure you install a unicode version of wxPython.
Detailed installation instructions are `here <https://github.com/FCS-analysis/PyCorrFit/wiki/Running-from-source>`_.


Contributing
------------
The main branch for developing PyCorrFit is *develop*. Small changes that do not
break anything can be submitted to this branch.
If you want to do big changes, please (fork ShapeOut and) create a separate branch,
e.g. ``my_new_feature_dev``, and create a pull-request to *develop* once you are done making
your changes.
Please make sure to also update the
`changelog <https://github.com/FCS-analysis/PyCorrFit/blob/develop/CHANGELOG>`_.

Tests
-----
It is recommended to work with
`virtual environments <https://docs.python.org/3/tutorial/venv.html>`_.

Windows
~~~~~~~
The easiest way to run PyCorrFit from source on Windows is
`Anaconda <http://continuum.io/downloads>`_.

- ``conda install matplotlib numpy pip scipy wxpython``
- ``pip install cython wheel simplejson sympy lmfit``
- ``pip install -e . # in the root directory of the repository``

Ubuntu 17.10
~~~~~~~~~~~~
PyCorrFit requires wxPython >= 4.0.1 which is not available as a binary
wheel on PyPI and thus must be built from the .tar.gz.
Install all dependencies (https://github.com/wxWidgets/Phoenix/blob/master/README.rst):

- ``pip install cython matplotlib lmfit numpy scipy sympy``
- ``sudo apt-get install -qq libgtk2.0 libgtk2.0-dev libwebkitgtk-dev dpkg-dev build-essential python3.6-dev libjpeg-dev libtiff-dev libsdl1.2-dev libnotify-dev freeglut3 freeglut3-dev libsm-dev libgtk-3-dev libwebkit2gtk-4.0-dev libxtst-dev libgstreamer-plugins-base1.0-dev``
- ``pip install wxPython # this will take some time``
- ``pip install -e . # in the root directory of the repository``

Testing
-------
PyCorrFit is tested using pytest. If you have the time, please write test
methods for your code and put them in the ``tests`` directory. You may
run the tests manually by issuing:
run all tests by issuing:

::

python setup.py test


Pull request guidelines
-----------------------
Please fork PyCorrFit and create a pull request (PR) introducing your changes.

- A new PR should always be made into the `develop` branch.
- If a PR introduces a new functionality or fixes a bug, it should provide
a test case, i.e. a new file or function in the `tests` directory
(see `here <https://github.com/FCS-analysis/PyCorrFit/tree/develop/tests>`_
for examples).
Note that currently there is no recipe for testing the graphical user
interface code.
- New code should follow the
`style guide for Python <https://www.python.org/dev/peps/pep-0008/>`_.
Please use `flake8 <http://flake8.pycqa.org/en/latest/index.html#quickstart>`_
to check the files you changed or created.
- New code should be documented well.
- Make sure to update the `changelog <https://github.com/FCS-analysis/PyCorrFit/blob/develop/CHANGELOG>`_.


Windows test binaries
---------------------
After each commit to the PyCorrFit repository, a binary installer is created
by `Appveyor <https://ci.appveyor.com/project/paulmueller/PyCorrFit>`_. Click
on a build and navigate to ``ARTIFACTS`` (upper right corner right under
the running time of the build). From there you can download the Windows installer of the commit.
the running time of the build). From there you can download the Windows
installer for the commit.

2 changes: 1 addition & 1 deletion pycorrfit/gui/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,6 @@ def getMainIcon(pxlength=32):
image = wx.Bitmap.ConvertToImage(iconBMP)
image = image.Scale(pxlength, pxlength, wx.IMAGE_QUALITY_HIGH)
iconBMP = wx.Bitmap(image)
iconICO = wx.Icon(iconBMP) # wx.Bitmap.ConvertToImage(iconBMP)
iconICO = wx.Icon(iconBMP)
return iconICO

32 changes: 26 additions & 6 deletions pycorrfit/gui/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import matplotlib
import numpy as np
import re

# We do catch warnings about performing this before matplotlib.backends stuff
with warnings.catch_warnings():
Expand Down Expand Up @@ -70,6 +71,7 @@ def latexmath(string):
unicodechars["³"] = r"^3"
unicodechars["₁"] = r"_1"
unicodechars["₂"] = r"_2"
unicodechars["₃"] = r"_3"
unicodechars["₀"] = r"_0"
#unicodechars["α"] = r"\alpha"
# We need lambda in here, because unicode names it lamda sometimes.
Expand Down Expand Up @@ -107,6 +109,26 @@ def latexmath(string):
return anew + r" \hspace{0.3em} \mathrm{"+b+r"}"


def genLatexText(parm, labels):
"""Generate the LaTeX text for the plot with handling multiple underscores
in the labels.
"""
text = r''
for i in np.arange(len(parm)):
line = r' {} &= {:.3g} \\'.format(latexmath(labels[i]), parm[i])
match = re.search(r'\\text\{(.*?)\}', line)
if match:
if '_' in match.groups()[0]:
tmpstr = match.groups()[0].split('_')
if ''.join(tmpstr).isnumeric():
line = line.replace(match.groups()[0], ''.join(tmpstr))
elif len(tmpstr) == 2:
tmpstr = '$_'.join(tmpstr) + '$'
line = line.replace(match.groups()[0], tmpstr)
text += line
return text


def savePlotCorrelation(parent, dirname, Page, uselatex=False,
verbose=False, show_weights=True):
""" Save plot from Page into file
Expand Down Expand Up @@ -215,11 +237,9 @@ def savePlotCorrelation(parent, dirname, Page, uselatex=False,
# Add some nice text:
if uselatex == True and len(parms) != 0:
text = r""
text += r'\[' #every line is a separate raw string...
text += r'\begin{split}' # ...but they are all concatenated
# by the interpreter :-)
for i in np.arange(len(parms)):
text += r' {} &= {:.3g} \\'.format(latexmath(labels[i]), parms[i])
text += r'\['
text += r'\begin{split}'
text += genLatexText(parms, labels)
## According to issue #54, we remove fitting errors from plots
#if errparms is not None:
# keys = errparms.keys()
Expand Down Expand Up @@ -422,4 +442,4 @@ def savePlotTrace(parent, dirname, Page, uselatex=False, verbose=False):
pass

# set dpi to 300
matplotlib.rcParams['savefig.dpi'] = 300
matplotlib.rcParams['savefig.dpi'] = 300

0 comments on commit 67d71e2

Please sign in to comment.