Skip to content

Commit

Permalink
Merge pull request #26 from phobson/maint-0.2.x
Browse files Browse the repository at this point in the history
test clean up and better conda recipe
  • Loading branch information
phobson committed Jan 24, 2016
2 parents 954a028 + 2fadeae commit feb6171
Show file tree
Hide file tree
Showing 9 changed files with 145 additions and 10 deletions.
File renamed without changes.
File renamed without changes.
46 changes: 46 additions & 0 deletions conda.recipe/dev/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package:
name: paramnormal
version: v0.2.dev

source:
git_url: https://github.com/phobson/paramnormal.git
git_tag: master
# patches:
# List any patch files here
# - fix.patch

build:
noarch_python: True
number: 1

requirements:
build:
- python
- numpy
- scipy
- matplotlib

run:
- python
- numpy
- scipy
- matplotlib

test:
imports:
- paramnormal

# commands:
# - PWD=`pwd`; echo $PWD

requires:
- nose

about:
home: http://phobson.github.io/paramnormal/
license: BSD License
summary: 'Conventionally parameterized probability distributions.'

# See
# http://docs.continuum.io/conda/build.html for
# more information about meta.yaml/configure
8 changes: 8 additions & 0 deletions conda.recipe/stable/bld.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
"%PYTHON%" setup.py install
if errorlevel 1 exit 1

:: Add more build steps here, if they are necessary.

:: See
:: http://docs.continuum.io/conda/build.html
:: for a list of environment variables that are set during the build process.
9 changes: 9 additions & 0 deletions conda.recipe/stable/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

$PYTHON setup.py install

# Add more build steps here, if they are necessary.

# See
# http://docs.continuum.io/conda/build.html
# for a list of environment variables that are set during the build process.
7 changes: 5 additions & 2 deletions conda.recipe/meta.yaml → conda.recipe/stable/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,28 @@ source:
# - fix.patch

build:
noarch_python: True
number: 1

requirements:
build:
- python
- numpy
- scipy
- matplotlib

run:
- python
- numpy
- scipy
- matplotlib

test:
imports:
- paramnormal

commands:
- nosetests
# commands:
# - PWD=`pwd`; echo $PWD

requires:
- nose
Expand Down
30 changes: 22 additions & 8 deletions docs/tutorial/activities.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@
"\n",
"Perhaps the most convenient way to access the functionality of `paramnormal` is through the `activity` module.\n",
"\n",
"Random number generation, distribution fitting, and basic plotting are exposed through `activity`.\n",
"\n",
"### Random number generation\n",
"Through the top-level API, you could do the following to generate lognormal random numbers."
"Random number generation, distribution fitting, and basic plotting are exposed through `activity`."
]
},
{
Expand All @@ -29,7 +26,7 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
"collapsed": true
},
"outputs": [],
"source": [
Expand All @@ -43,8 +40,25 @@
"import paramnormal\n",
"\n",
"clean_bkgd = {'axes.facecolor':'none', 'figure.facecolor':'none'}\n",
"seaborn.set(style='ticks', rc=clean_bkgd)\n",
"\n",
"seaborn.set(style='ticks', rc=clean_bkgd)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Random number generation\n",
"Through the top-level API, you could do the following to generate lognormal random numbers."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"seed(0)\n",
"paramnormal.lognormal(mu=0.75, sigma=1.25).rvs(5)"
]
Expand Down Expand Up @@ -74,7 +88,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"And of source, Greek letters are still supported."
"And of course, Greek letters are still supported."
]
},
{
Expand Down
2 changes: 2 additions & 0 deletions paramnormal/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from .dist import *
from . import activity
from . import utils

from .tests import test
53 changes: 53 additions & 0 deletions paramnormal/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
from warnings import simplefilter
from numpy import errstate
from numpy.testing import Tester

class _NoseWrapper(Tester): # pragma: no cover
"""
This is simply a monkey patch for numpy.testing.Tester.
It allows extra_argv to be changed from its default None to ['--exe'] so
that the tests can be run the same across platforms. It also takes kwargs
that are passed to numpy.errstate to suppress floating point warnings.
"""
def test(self, label='fast', verbose=1, extra_argv=['--exe'],
doctests=False, coverage=False, **kwargs):
''' Run tests for module using nose
%(test_header)s
doctests : boolean
If True, run doctests in module, default False
coverage : boolean
If True, report coverage of NumPy code, default False
(Requires the coverage module:
http://nedbatchelder.com/code/modules/coverage.html)
kwargs
Passed to numpy.errstate. See its documentation for details.
'''

# cap verbosity at 3 because nose becomes *very* verbose beyond that
verbose = min(verbose, 3)

from numpy.testing import utils
utils.verbose = verbose

if doctests:
print("Running unit tests and doctests for %s" % self.package_name)
else:
print("Running unit tests for %s" % self.package_name)

self._show_system_info()

# reset doctest state on every run
import doctest
from numpy.testing.noseclasses import NumpyTestProgram

doctest.master = None

argv, plugins = self.prepare_test_args(label, verbose, extra_argv,
doctests, coverage)
with errstate(**kwargs):
simplefilter('ignore', category=DeprecationWarning)
t = NumpyTestProgram(argv=argv, exit=False, plugins=plugins)

return t.result

test = _NoseWrapper().test

0 comments on commit feb6171

Please sign in to comment.