Skip to content
This repository was archived by the owner on Feb 12, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
b6b58fc
Point badges to the posterior github org
fritzo Feb 4, 2015
c14fb6f
Cpplint compliance
fritzo Feb 4, 2015
9d6d61b
Revert explicit constructor
fritzo Feb 4, 2015
585595f
Fix src/test_headers.hpp make target to work in OS X
fritzo Feb 4, 2015
ca68057
Sketch cdf for vector_density_goodness_of_fit
fritzo Feb 5, 2015
86d8dd5
Fix gof issues in distributions.util
fritzo Feb 5, 2015
a35d4c1
Switch to dbg version of niw
fritzo Feb 5, 2015
cdc127e
Merge branch 'master' into vector-gof
fritzo Feb 5, 2015
9e9625c
Implement vector_density_goodness_of_fit (tests fail)
fritzo Feb 5, 2015
194270c
Add normalized flag to goodness_of_fit methods
fritzo Feb 5, 2015
7c51b3d
Get examples/testing/gof working (tests still fail)
fritzo Feb 9, 2015
d57b3d0
Ignore dpd mixture bug for now
fritzo Feb 10, 2015
5c0a3d3
Merge branch 'master' into vector-gof
fritzo Feb 10, 2015
cd2c546
Simplify testing example
fritzo Feb 10, 2015
054046e
Pep8 compliance
fritzo Feb 10, 2015
e12cf43
Merge branch 'master' into vector-gof
fritzo Feb 10, 2015
353e374
Increase sample count to get dbg.models.niw to pass tests
fritzo Feb 10, 2015
6653102
Skip test_sample_value for lp.models.niw
fritzo Feb 10, 2015
16f2ed9
Bump version to 2.0.30
fritzo Feb 10, 2015
9b94316
Demonstrate lp.niw bug in derivations/vector_gof
fritzo Feb 10, 2015
2820457
Update license headers
fritzo Feb 14, 2015
ab88139
Implement mixed_density_goodness_of_fit (untested)
fritzo Feb 15, 2015
047becc
Fix bugs in and add tests for split_discrete_continuous
fritzo Feb 15, 2015
b279427
Fix normalization bug in mixed_density_goodness_of_fit
fritzo Feb 16, 2015
dd44b9e
Bump to version 2.1.0
fritzo Feb 16, 2015
06c932c
Ignore pep8 warning W503
fritzo Feb 16, 2015
74c7168
Add plotting to mixed_density_goodness_of_fit
fritzo Feb 17, 2015
695be34
Defer to goftests for goodness of fit tests
fritzo Feb 17, 2015
dbff616
Move from forcedotcom to posterior
fritzo Feb 17, 2015
e1c3093
Update derivations to use goftests
fritzo Feb 17, 2015
d353498
Use pip install --upgrade in Makefile
fritzo Mar 3, 2015
4966cc5
Allow gcc in Darwin
fritzo Mar 13, 2015
3ae364f
Merge branch 'master' of github.com:posterior/distributions
fritzo Mar 13, 2015
38a09d0
Fix os.env typo in setup.py
fritzo Mar 14, 2015
405e087
Fixes inclusion of Eigen3.
tdhopper Mar 19, 2015
6f67deb
Allow user to set CONDA_ROOT environmental variable
tdhopper Mar 23, 2015
5e07c51
Refactor redunant code
tdhopper Mar 23, 2015
389cce0
Remove conda hack in setup.py
tdhopper Mar 23, 2015
6ef6a5a
Use PATH instead of DIRECTORY since Travis uses old cmake
tdhopper Mar 23, 2015
26db42c
Merge pull request #9 from tdhopper/fix/build
fritzo Apr 27, 2015
795befc
Add DOI badge to README
fritzo Jun 28, 2017
c967122
Fixes for Ubuntu 1604
fritzo Nov 6, 2017
55ef279
Merge pull request #12 from posterior/fix-ubuntu-1604
fritzo Nov 6, 2017
9895f41
Bump to version 2.2.1
fritzo Nov 6, 2017
0a03c93
Candidate fix for Travis build with DISTRIBUTIONS_USE_PROTOBUF=1.
Nov 6, 2017
b75dcc6
Fix #10, remove compiled protobuf files.
Nov 6, 2017
9db375f
Merge pull request #14 from posterior/20171106-fsaad-travis-ubuntu1404
fritzo Nov 10, 2017
8a8f853
Fix numpy strict conversion error, (related to issue #15).
Nov 6, 2017
173c55d
Merge pull request #16 from posterior/20171106-fsaad-travis-ubuntu1604
Nov 10, 2017
85f5c26
Update distributions to Python 3.
emilyfertig Feb 12, 2024
0a4a5ca
Update a line in Makefile for Python 3.
emilyfertig Feb 12, 2024
f31d568
Add publish.yml
fritzo Feb 19, 2024
3a20ecc
Bump sample_count in tests so GOF passes.
emilyfertig Feb 21, 2024
c2a9dcc
Merge pull request #18 from emilyfertig/emilyaf-distributions-py3
fritzo Feb 21, 2024
f4c6a46
A few more Python 2->3 fixes.
emilyfertig Mar 26, 2024
43c1161
Merge pull request #19 from emilyfertig/master
fritzo Mar 27, 2024
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
35 changes: 35 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

# GitHub recommends pinning actions to a commit SHA.
# To get a newer version, you will need to update the SHA.
# You can also reference a tag or branch, but the action may change without warning.

name: Upload Python Package

on:
release:
types: [published]

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build
- name: Publish package
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}

6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,9 @@ temp.*
*.swp
doc/_build
MANIFEST

# Files generated by protobuf.
distributions/io/schema_pb2.py
include/distributions/io/schema.pb.cc
include/distributions/io/schema.pb.h
src/io/schema.pb.cc
7 changes: 3 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ virtualenv:
system_site_packages: true
before_install:
- pip uninstall numpy -y || echo 'numpy not installed'
- sudo add-apt-repository -y ppa:cython-dev/master-ppa
- sudo apt-get update -qq
- sudo apt-get install -qq cython python-numpy python-scipy
- sudo apt-get install libprotobuf-dev libeigen3-dev
- pip install cpplint
- sudo apt-get install -qq cython python-numpy python-pil python-scipy
- sudo apt-get install libprotobuf-dev libeigen3-dev protobuf-compiler
- pip install cpplint pyflakes
env:
- FLAVOR=_cc
- FLAVOR=_cc DISTRIBUTIONS_USE_PROTOBUF=1
Expand Down
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ if(DEFINED EXTRA_LIBRARY_PATH)
endif()

find_package(Eigen3 REQUIRED)
include_directories(${EIGEN3_INCLUDE_DIRS})
get_filename_component(PARENT_DIR ${EIGEN3_INCLUDE_DIR} PATH)
include_directories(${PARENT_DIR})

find_package(Yeppp)
if(YEPPP_FOUND)
Expand Down
32 changes: 18 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
uname:=$(shell uname -s)
cpu_count=$(shell python -c 'import multiprocessing as m; print m.cpu_count()')
cpu_count=$(shell python -c 'import multiprocessing as m; print(m.cpu_count())')


ld_library_path=
Expand All @@ -16,14 +16,18 @@ endif
cmake_args=
nose_env:=NOSE_PROCESSES=$(cpu_count) NOSE_PROCESS_TIMEOUT=240
ifdef VIRTUAL_ENV
cmake_args=-DCMAKE_INSTALL_PREFIX=$(VIRTUAL_ENV)
library_path=$(LIBRARY_PATH):$(VIRTUAL_ENV)/lib/
nose_env+=$(ld_library_path)=$($(ld_library_path)):$(VIRTUAL_ENV)/lib/
root_path=$(VIRTUAL_ENV)
else
cmake_args=-DCMAKE_INSTALL_PREFIX=../..
library_path=$(LIBRARY_PATH):`pwd`/lib/
nose_env+=$(ld_library_path)=$($(ld_library_path)):`pwd`/lib/
ifdef CONDA_ROOT
root_path=$(CONDA_ROOT)
else
root_path='../..'
endif
endif
cmake_args=-DCMAKE_INSTALL_PREFIX=$(root_path)
library_path=$(LIBRARY_PATH):$(root_path)/lib/
nose_env+=$(ld_library_path)=$($(ld_library_path)):$(root_path)/lib/

ifdef CMAKE_INSTALL_PREFIX
cmake_args=-DCMAKE_INSTALL_PREFIX=$(CMAKE_INSTALL_PREFIX)
endif
Expand All @@ -32,12 +36,12 @@ all: test

headers:=$(shell find include | grep '\.hpp' | grep -v protobuf | sort -d)
src/test_headers.cc: $(headers)
echo $(headers) \
| sed 's/include\/\(\S*\)\s*/#include <\1>\n/g' \
find include | grep '\.hpp' | grep -v protobuf | sort -d \
| sed 's/include\/\(.*\)/#include <\1>/g' \
> src/test_headers.cc
echo 'int main () { return 0; }' >> src/test_headers.cc
@echo '\nint main () { return 0; }' >> src/test_headers.cc

prepare_cc: src/test_headers.cc FORCE
prepare_cc: src/test_headers.cc protobuf FORCE
mkdir -p lib

build/python: prepare_cc FORCE
Expand Down Expand Up @@ -73,7 +77,7 @@ dev_cy: deps_cy FORCE
LIBRARY_PATH=$(library_path) pip install -e .

install_cy: deps_cy FORCE
LIBRARY_PATH=$(library_path) pip install .
LIBRARY_PATH=$(library_path) pip install --upgrade .

install: install_cc install_cy FORCE

Expand All @@ -90,7 +94,7 @@ test_cc_examples: install_cc_examples FORCE
CPP_SOURCES:=$(shell find include src examples benchmarks | grep -v 'vendor\|\.pb\.' | grep -v 'src/test_headers.cc' | grep '\.\(cc\|hpp\)$$')

lint_cc: FORCE
cpplint --filter=-build/include_order,-readability/streams,-readability/function,-runtime/arrays $(CPP_SOURCES)
cpplint --filter=-build/include_order,-readability/streams,-readability/function,-runtime/arrays,-runtime/reference,-runtime/explicit,-readability/alt_tokens,-build/c++11 $(CPP_SOURCES)

test_cc: install_cc lint_cc FORCE
cd build && ctest
Expand All @@ -101,7 +105,7 @@ PY_SOURCES=setup.py update_license.py distributions derivations examples/mixture

test_cy: dev_cy FORCE
pyflakes $(PY_SOURCES)
pep8 --repeat --ignore=E265 --exclude=*_pb2.py,vendor $(PY_SOURCES)
pep8 --repeat --ignore=E265,E402,W503 --exclude=*_pb2.py,vendor $(PY_SOURCES)
$(nose_env) nosetests -v distributions derivations examples
@echo '----------------'
@echo 'PASSED CY TESTS'
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[![Build Status](https://travis-ci.org/forcedotcom/distributions.svg?branch=master)](https://travis-ci.org/forcedotcom/distributions)
[![Code Quality](http://img.shields.io/scrutinizer/g/forcedotcom/distributions.svg)](https://scrutinizer-ci.com/g/forcedotcom/distributions/code-structure/master/hot-spots)
[![Latest Version](https://badge.fury.io/py/distributions.svg)](https://pypi.python.org/pypi/distributions)

# Distributions

[![Build Status](https://travis-ci.org/posterior/distributions.svg?branch=master)](https://travis-ci.org/posterior/distributions)
[![Latest Version](https://badge.fury.io/py/distributions.svg)](https://pypi.python.org/pypi/distributions)
[![DOI](https://zenodo.org/badge/29212688.svg)](https://zenodo.org/badge/latestdoi/29212688)

Distributions provides low-level primitives for
collapsed Gibbs sampling in Python and C++ including:

Expand Down
2 changes: 1 addition & 1 deletion conda/distributions/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ fi
echo "Conda build env"
printenv
echo "protoc: `which protoc`"
git clone https://github.com/forcedotcom/distributions.git
git clone https://github.com/posterior/distributions.git
cd distributions && git checkout tags/2.0.26
make protobuf
mkdir build && cd build
Expand Down
2 changes: 1 addition & 1 deletion conda/distributions/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ test:
- distributions.lp.models.bb

about:
home: https://github.com/forcedotcom/distributions
home: https://github.com/posterior/distributions
27 changes: 27 additions & 0 deletions conda/libprotobuf/schema.proto
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
// Copyright (c) 2014, Salesforce.com, Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// - Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// - Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// - Neither the name of Salesforce.com nor the names of its contributors
// may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
// TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

message HelloWorld {
required string message = 1;
}
27 changes: 27 additions & 0 deletions conda/libprotobuf/test.cc
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
// Copyright (c) 2014, Salesforce.com, Inc. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// - Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// - Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// - Neither the name of Salesforce.com nor the names of its contributors
// may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
// OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
// TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#include "schema.pb.h"
#include <cassert>
int
Expand Down
14 changes: 7 additions & 7 deletions derivations/betabinomial.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def simtwo(alpha, beta, n, ITERS):
thetas = np.random.beta(alpha, beta, size=ITERS)
for i in range(ITERS):
if i % 1000000 == 0:
print i
print(i)

counts[i] = np.random.binomial(n, thetas[i], size=2)
return counts
Expand Down Expand Up @@ -126,7 +126,7 @@ def test_post_pred_equal_likelihood():
for alpha in [5.0]:
for beta in [5.0]:
for ks in [[9, 1], [1, 9]]:
print "-" * 60
print("-" * 60)
hps.alpha = alpha
hps.beta = beta

Expand All @@ -139,12 +139,12 @@ def test_post_pred_equal_likelihood():

total_score = compute_total_likelihood(hps, ss)
res = two_d_hist(alpha, beta, hps.N, 10000000)
print res
print res.shape
print(res)
print(res.shape)
emp_score = res[ks[0], ks[1]]
d1 = abs(pred_score - emp_score)
d2 = abs(emp_score - total_score)
d3 = abs(total_score - pred_score)
print "alpha=", alpha, "beta=", beta, "ks =", ks
print pred_score, total_score, emp_score
print "error=", d1 + d2 + d3
print("alpha=", alpha, "beta=", beta, "ks =", ks)
print(pred_score, total_score, emp_score)
print("error=", d1 + d2 + d3)
Loading