Skip to content

Instantly share code, notes, and snippets.

@hovren
hovren / CMakeLists.txt
Created December 12, 2017 15:35
pybind11 with CMake and setup.py
# Build a Python extension module using pybind11
# pybindings_add_module(<module>)
# Here <module> should be the fully qualified name for the module,
# e.g. pybindings_add_module(foo.bar._baz)
# <module> becomes the target name in case you wish to do something to it later
# The source for the binding *must* be placed in src/pybindings/{relpath}/py{name}.cc
# E.g. for module=foo.bar._baz -> src/pybindings/bar/py_baz.cc
function(pybindings_add_module module)
set(target_name ${module})
string(REPLACE "." "/" modpath ${module})
import itertools
import numpy as np
import numpy.testing as nt
import scipy.misc
def multinomial(n, K):
nom = scipy.misc.factorial(n)
den = np.product([scipy.misc.factorial(k) for k in K])
return nom / den
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.