Skip to content

Commit

Permalink
Merge pull request scikit-hep#66 from cdeil/docs
Browse files Browse the repository at this point in the history
Add docs build on travis-ci
  • Loading branch information
cdeil authored Oct 22, 2016
2 parents 22840fe + 6930b0a commit cafa9db
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 29 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ install:
- pip install matplotlib
- pip install iminuit
- pip install nose
# ipython needed for docs: IPython.sphinxext.ipython_directive
- pip install ipython sphinx sphinx_rtd_theme

script:
- python setup.py build_ext -i
- nosetests
- cd doc && make html
4 changes: 2 additions & 2 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ Commonly used API

Refer to :ref:`fullapi` for complete reference.

Cost Functions.
"""""""""""""""
Cost Functions
""""""""""""""

Refer to :ref:`costfunc`.

Expand Down
7 changes: 7 additions & 0 deletions probfit/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
"""
probfit - Cost function builder. For fitting distributions.
* Code: https://github.com/iminuit/probfit
* Docs: http://probfit.readthedocs.io
"""

from .costfunc import UnbinnedLH, BinnedLH, Chi2Regression, BinnedChi2, SimultaneousFit
from .pdf import doublegaussian, ugaussian, gaussian, crystalball, \
argus, cruijff, linear, poly2, poly3, novosibirsk, \
Expand Down
29 changes: 15 additions & 14 deletions probfit/costfunc.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,20 @@ cdef extern from "math.h":
bint isnan(double x)

cdef class SimultaneousFit:
"""
Construct simultaneous fit from given cost functions.
**Arguments**
- **factors** Optional factor array. If not None, each cost function
is scaled by `factors[i]` before being summed up. Default None.
- **prefix** Optional list of prefix. Add prefix to variable name of
each cost function so that you don't accidentally merge them.
Default None.
- **skip_prefix** list of variable names that prefix should not be
applied to. Useful if you want to prefix them and shared some
of them.
"""
cdef readonly list allf
cdef readonly list allpos
cdef readonly int numf
Expand All @@ -27,20 +41,6 @@ cdef class SimultaneousFit:
cdef readonly object prefix
#FIXME: cache each part if called with same parameter
def __init__(self, *arg, factors=None, prefix=None, skip_prefix=None):
"""
Construct Simultaneous fit from given cost functions.
**Arguments**
- **factors** Optional factor array. If not None, each cost function
is scaled by `factors[i]` before being summed up. Default None.
- **prefix** Optional list of prefix. Add prefix to variablename of
each cost function so that you don't accidentally merge them.
Default None.
- **skip_prefix** list of variable names that prefix should not be
applied to. Useful if you want to prefix them and shared some
of them.
"""
self.allf = list(arg)
func_code, allpos = merge_func_code(*arg, prefix=prefix,
skip_prefix=skip_prefix)
Expand Down Expand Up @@ -244,6 +244,7 @@ cdef class UnbinnedLH:
parameter errors are determined from **errors**. Default None.
- **show_errbars** Show error bars. Default 'normal'
* 'normal' : error = sqrt( sum of weight )
* 'sumw2' : error = sqrt( sum of weight**2 )
* None : no errorbars (shown as a step histogram)
Expand Down
7 changes: 4 additions & 3 deletions probfit/nputil.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ def float2double(a):

def vector_apply(f, x, *arg):
"""
apply **f** to array **x** with given arguments fast. This is a fast
version of::
Apply **f** to array **x** with given arguments fast.
This is a fast version of::
np.array([f(xi,*arg) for xi in x ])
useful when you try to plot something
useful when you try to plot something.
"""
return _vector_apply(f, x, arg)
22 changes: 12 additions & 10 deletions probfit/pdf.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,22 @@ cdef double badvalue = 1e-300
cdef double smallestdiv = 1e-10

cdef class Polynomial:
"""
Polynomial.
.. math::
f(x; c_i) = \sum_{i < \\text{order}} c_i x^i
User can supply order as integer in which case it uses (c_0....c_n+1)
default or the list of coefficient name which the first one will be the
lowest order and the last one will be the highest order. (order=1 is
a linear function)
"""
cdef int order
cdef public object func_code
cdef public object func_defaults
def __init__(self,order,xname='x'):
"""
.. math::
f(x; c_i) = \sum_{i < \\text{order}} c_i x^i
User can supply order as integer in which case it uses (c_0....c_n+1)
default or the list of coefficient name which the first one will be the
lowest order and the last one will be the highest order. (order=1 is
a linear function)
"""
varnames = None
argcount = 0
if isinstance(order, int):
Expand Down

0 comments on commit cafa9db

Please sign in to comment.