Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# http://editorconfig.org

root = true

[*]
indent_style = space
indent_size = 4
trim_trailing_whitespace = true
insert_final_newline = true
charset = utf-8
end_of_line = lf

[*.bat]
indent_style = tab
end_of_line = crlf

[LICENSE]
insert_final_newline = false

[Makefile]
indent_style = tab
17 changes: 17 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
* Python version:
* numpy version:
* matplotlib version:
* mpl-probscale version:
* Operating System:

### Description

Describe what you were trying to get done.
Tell us what happened, what went wrong, and what you expected to happen.

### What I Did

```
Paste the command(s) you ran and the output.
If there was a crash, please include the traceback here.
```
12 changes: 6 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@ matrix:
- python: 2.7
env:
- COVERAGE=false
- TESTERS="conda-forge pytest mock pytest-mpl coverage"
- EXTRATESTERS="mock"
- ARGS="--verbose"
- python: 3.4
env:
- COVERAGE=false
- TESTERS="conda-forge pytest pytest-mpl coverage"
- EXTRATESTERS=""
- ARGS="--mpl --verbose"
- python: 3.5
env:
- COVERAGE=false
- TESTERS="conda-forge pytest pytest-mpl coverage"
- EXTRATESTERS=""
- ARGS="--mpl --verbose"
- python: 3.5
env:
- COVERAGE=true
- TESTERS="conda-forge pytest pytest-mpl coverage"
- ARGS="--mpl --verbose"
- EXTRATESTERS=""
- ARGS="--mpl --verbose --pep8"

before_install:

Expand All @@ -41,7 +41,7 @@ install:

- conda create --yes -n test python=$TRAVIS_PYTHON_VERSION numpy matplotlib docopt requests pyyaml
- source activate test
- conda install --yes --channel=${TESTERS}
- conda install --yes --channel=conda-forge pytest-mpl pytest-cov pytest-pep8 ${EXTRATESTERS}
- if [ ${COVERAGE} = true ]; then conda install scipy --yes; fi
- pip install codecov
- pip install .
Expand Down
13 changes: 13 additions & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
=======
Credits
=======

Development Lead
----------------

* Paul M. Hobson <[email protected]>

Contributors
------------

* Pierre Haessig
9 changes: 0 additions & 9 deletions CONTRIBUTING.md

This file was deleted.

149 changes: 149 additions & 0 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
.. highlight:: shell

============
Contributing
============

Contributions are welcome, and they are greatly appreciated! Every
little bit helps, and credit will always be given.

You can contribute in many ways:

Types of Contributions
----------------------

Report Bugs
~~~~~~~~~~~

Report bugs at https://github.com/phobson/probscale/issues.

If you are reporting a bug, please include:

* Your operating system name and version.
* Any details about your local setup that might be helpful in troubleshooting.
* Detailed steps to reproduce the bug.

Fix Bugs
~~~~~~~~

Look through the GitHub issues for bugs. Anything tagged with "bug"
and "help wanted" is open to whoever wants to implement it.

Implement Features
~~~~~~~~~~~~~~~~~~

Look through the GitHub issues for features. Anything tagged with "enhancement"
and "help wanted" is open to whoever wants to implement it.

Write Documentation
~~~~~~~~~~~~~~~~~~~

mpl-probscale could always use more documentation, whether as part of the
official mpl-probscale docs, in docstrings, or even on the web in blog posts,
articles, and such.

Submit Feedback
~~~~~~~~~~~~~~~

The best way to send feedback is to file an issue at https://github.com/phobson/probscale/issues.

If you are proposing a feature:

* Explain in detail how it would work.
* Keep the scope as narrow as possible, to make it easier to implement.
* Remember that this is a volunteer-driven project, and that contributions
are welcome :)

Get Started!
------------

Ready to contribute? Here's how to set up `probscale` for local development.

1. Fork the `probscale` repo on GitHub.
2. Clone your fork locally::

$ git clone [email protected]:your_name_here/probscale.git

3. Install your local copy into a conda environment. Assuming you have conda installed, this is how you set up your fork for local development::

$ conda config --add channels conda-forge
$ conda create --name=probscale python=3.5 numpy matplotlib pytest pytest-cov pytest-pep8 pytest-mpl
$ cd probscale/
$ pip install -e .

4. Create a branch for local development::

$ git checkout -b name-of-your-bugfix-or-feature

Now you can make your changes locally.

5. When you're done making changes, check that your changes pass flake8 and the tests, including testing other Python versions with tox::

$ python check_probscale.py --mpl --pep8 --cov

6. Commit your changes and push your branch to GitHub::

$ git add <files you want to stage>
$ git commit -m "Your detailed description of your changes."
$ git push origin name-of-your-bugfix-or-feature

7. Submit a pull request through the GitHub website.

Matplotlib has good info on working with `source code`_ using `git and GitHub`_.

.. _source code: http://matplotlib.org/devel/coding_guide.html`
.. _git and GitHub: http://matplotlib.org/devel/gitwash/development_workflow.html

Pull Request Guidelines
-----------------------

Before you submit a pull request, check that it meets these guidelines:

1. The pull request should include tests.
2. If the pull request adds functionality, the docs should be updated. Put
your new functionality into a function with a docstring, and add the
feature to the list in README.rst.
3. The pull request should work for Python 3.4 and higher. Check
https://travis-ci.org/phobson/probscale/pull_requests
and make sure that the tests pass for all supported Python versions.

Tips
----

To run a subset of tests::

$ py.test tests.test_probscale


Configuring Sublime Text 3 to run the tests
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

In Sublime, got to Tools -> Build System -> New Build System.
Then add the following configuration and save as "probscale.sublime-build"::

{
"working_dir": "<path to the git repository>",
"cmd": "<full path of the python executable> check_probscale.py --verbose <other pytest options>",
}


Configuring Atom to run the tests
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

In Atom, install the build_ package, create a new file called ".atom-build.yml" in the
top level of the project directory, and add the following contents::

cmd: "<full path of the python executable>"
name: "probscale"
args:
- check_probscale.py
- --verbose
- <other pytest options ...>
cwd: <path to the git repository>
sh: false
keymap: ctrl-b
atomCommandName: namespace:testprobscale

After this, hitting ctrl+b in either text editor will run the test suite.

.. _build: https://atom.io/packages/build
1 change: 1 addition & 0 deletions docs/authors.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.. include:: ../AUTHORS.rst
1 change: 1 addition & 0 deletions docs/contributing.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.. include:: ../CONTRIBUTING.rst
51 changes: 51 additions & 0 deletions docs/installation.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
.. highlight:: shell

============
Installation
============


Stable release
--------------

To install mpl-probscale, run this command in your terminal:

.. code-block:: console

$ pip install probscale

This is the preferred method to install mpl-probscale, as it will always install the most recent stable release.

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/


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

The sources for mpl-probscale can be downloaded from the `Github repo`_.

You can either clone the public repository:

.. code-block:: console

$ git clone git://github.com/phobson/probscale

Or download the `tarball`_:

.. code-block:: console

$ curl -OL https://github.com/phobson/probscale/tarball/master

Once you have a copy of the source, you can install it with:

.. code-block:: console

$ pip install .


.. _Github repo: https://github.com/phobson/probscale
.. _tarball: https://github.com/phobson/probscale/tarball/master
1 change: 1 addition & 0 deletions docs/readme.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.. include:: ../README.md
3 changes: 2 additions & 1 deletion probscale/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

import probscale


def test(*args):
options = [resource_filename('probscale', 'tests')]
options.extend(list(args))
return pytest.main(options)
return pytest.main(options)
12 changes: 12 additions & 0 deletions probscale/tests/helpers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from functools import wraps

import numpy


def seed(func):
""" Decorator to seed the RNG before any function. """
@wraps(func)
def wrapper(*args, **kwargs):
numpy.random.seed(0)
return func(*args, **kwargs)
return wrapper
5 changes: 4 additions & 1 deletion probscale/tests/test_formatters.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
from probscale import formatters


@pytest.mark.parametrize("fmtr", [formatters.PctFormatter, formatters.ProbFormatter])
@pytest.mark.parametrize("fmtr", [
formatters.PctFormatter,
formatters.ProbFormatter
])
def test_base_class_of_formatter(fmtr):
assert issubclass(fmtr, formatters._FormatterMixin)

Expand Down
4 changes: 2 additions & 2 deletions probscale/tests/test_probscale.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ def test_minimal_norm__approx_inv_erf(mn, mn_input):

def test_minimal_norm_ppf(mn, mn_input):
known_ppf = numpy.array([
-0.43715354, 0.6495236 , -1.49851307, 0.93847570,
-0.43715354, 0.64952360, -1.49851307, 0.93847570,
-0.36648929, -1.34693863, 0.68713129, -0.40701088,
0.71275076, 0.40701088, -0.70952297, 1.34075503,
+0.71275076, 0.40701088, -0.70952297, 1.34075503,
])
diff = mn.ppf(mn_input) - known_ppf
assert numpy.all(numpy.abs(diff) < 0.001)
Expand Down
16 changes: 12 additions & 4 deletions probscale/tests/test_transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@


def test__mask_out_of_bounds():
known = numpy.array([numpy.nan, numpy.nan, 0.1, 0.5, 0.9, numpy.nan, numpy.nan])
known = numpy.array([
numpy.nan, numpy.nan, 0.1, 0.5,
0.9, numpy.nan, numpy.nan
])
x = [-0.1, 0, 0.1, 0.5, 0.9, 1.0, 1.1]
result = transforms._mask_out_of_bounds(x)
nptest.assert_array_equal(known, result)
Expand All @@ -22,7 +25,6 @@ def test__clip_out_of_bounds():
assert numpy.all(diff < 0.0001)



@pytest.fixture
def prob_trans():
cls = transforms.ProbTransform
Expand Down Expand Up @@ -80,13 +82,19 @@ def test_transform_inverted(trans, inver_cls):
assert trans.out_of_bounds == t_inv.out_of_bounds


@pytest.mark.parametrize('cls', [transforms.ProbTransform, transforms.QuantileTransform])
@pytest.mark.parametrize('cls', [
transforms.ProbTransform,
transforms.QuantileTransform
])
def test_bad_out_of_bounds(cls):
with pytest.raises(ValueError):
cls(_minimal_norm, out_of_bounds='junk')


@pytest.mark.parametrize('cls', [transforms.ProbTransform, transforms.QuantileTransform])
@pytest.mark.parametrize('cls', [
transforms.ProbTransform,
transforms.QuantileTransform
])
@pytest.mark.parametrize(('method', 'func'), [
('clip', transforms._clip_out_of_bounds),
('mask', transforms._mask_out_of_bounds),
Expand Down
Loading