Skip to content

Commit 9f9a7f4

Browse files
committed
make release-tag: Merge branch 'master' into stable
2 parents a8943fe + ae3be3a commit 9f9a7f4

38 files changed

+3361
-1157
lines changed

CONTRIBUTING.rst

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,7 @@ Ready to contribute? Here's how to set up `Copulas` for local development.
6969

7070
$ mkvirtualenv Copulas
7171
$ cd Copulas/
72-
$ pip install -e .
73-
$ pip install -r requirements_dev.txt
72+
$ make install-develop
7473

7574
4. Create a branch for local development::
7675

@@ -181,14 +180,16 @@ The process of releasing a new version involves several steps combining both ``g
181180
these changes are committed and available in ``master`` branch.
182181
Normally this is just a list of the Pull Requests that have been merged since the latest version.
183182

184-
Once this is done, just run the following commands::
183+
Once this is done, run of the following commands:
184+
185+
1. If you are releasing a patch version::
185186

186-
git checkout stable
187-
git merge --no-ff master # This creates a merge commit
188-
bumpversion release # This creates a new commit and a TAG
189-
git push --tags origin stable
190187
make release
191-
git checkout master
192-
git merge stable
193-
bumpversion --no-tag patch
194-
git push
188+
189+
2. If you are releasing a minor version::
190+
191+
make release-minor
192+
193+
3. If you are releasing a major version::
194+
195+
make release-major

HISTORY.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
11
# History
22

3+
## 0.2.1 - Vine serialization
4+
5+
* Add serialization to Vine copulas.
6+
* Add `distribution` as argument for the Gaussian Copula.
7+
* Improve Bivariate Copulas code structure to remove code duplication.
8+
* Fix bug in Vine Copulas sampling: 'Edge' object has no attribute 'index'
9+
* Improve code documentation.
10+
* Improve code style and linting tools configuration.
11+
12+
## 0.2.0 - Unified API
13+
14+
* New API for stats methods.
15+
* Standarize input and output to `numpy.ndarray`.
16+
* Increase unittest coverage to 90%.
17+
* Add methods to load/save copulas.
18+
* Improve Gaussian copula sampling accuracy.
19+
320
## 0.1.1 - Minor Improvements
421

522
* Different Copula types separated in subclasses

Makefile

Lines changed: 105 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
.PHONY: clean clean-test clean-pyc clean-build clean-docs docs help
21
.DEFAULT_GOAL := help
32

43
define BROWSER_PYSCRIPT
@@ -26,38 +25,71 @@ export PRINT_HELP_PYSCRIPT
2625

2726
BROWSER := python -c "$$BROWSER_PYSCRIPT"
2827

28+
.PHONY: help
2929
help:
3030
@python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST)
3131

32-
clean: clean-build clean-pyc clean-test clean-docs ## remove all build, test, coverage, docs and Python artifacts
3332

33+
# CLEAN TARGETS
34+
35+
.PHONY: clean-build
3436
clean-build: ## remove build artifacts
3537
rm -fr build/
3638
rm -fr dist/
3739
rm -fr .eggs/
3840
find . -name '*.egg-info' -exec rm -fr {} +
3941
find . -name '*.egg' -exec rm -f {} +
4042

43+
.PHONY: clean-pyc
4144
clean-pyc: ## remove Python file artifacts
4245
find . -name '*.pyc' -exec rm -f {} +
4346
find . -name '*.pyo' -exec rm -f {} +
4447
find . -name '*~' -exec rm -f {} +
4548
find . -name '__pycache__' -exec rm -fr {} +
4649

50+
.PHONY: clean-docs
51+
clean-docs: ## remove previously built docs
52+
-$(MAKE) -C docs clean 2>/dev/null # this fails if sphinx is not yet installed
53+
54+
.PHONY: clean-coverage
4755
clean-coverage: ## remove coverage artifacts
4856
rm -f .coverage
4957
rm -f .coverage.*
5058
rm -fr htmlcov/
5159

52-
clean-test: ## remove test and coverage artifacts
60+
.PHONY: clean-test
61+
clean-test: ## remove test artifacts
5362
rm -fr .tox/
5463
rm -fr .pytest_cache
5564

65+
.PHONY: clean
66+
clean: clean-build clean-pyc clean-test clean-coverage clean-docs ## remove all build, test, coverage, docs and Python artifacts
67+
68+
69+
# INSTALL TARGETS
70+
71+
.PHONY: install
72+
install: clean-build clean-pyc ## install the package to the active Python's site-packages
73+
pip install .
74+
75+
.PHONY: install-test
76+
install-test: clean-build clean-pyc ## install the package and test dependencies
77+
pip install .[test]
78+
79+
.PHONY: install-develop
80+
install-develop: clean-build clean-pyc ## install the package in editable mode and dependencies for development
81+
pip install -e .[dev]
82+
83+
84+
# LINT TARGETS
85+
86+
.PHONY: lint
5687
lint: ## check style with flake8 and isort
5788
flake8 copulas tests examples
5889
isort -c --recursive copulas tests examples
5990

60-
fixlint: ## fix lint issues using autoflake, autopep8, and isort
91+
.PHONY: fix-lint
92+
fix-lint: ## fix lint issues using autoflake, autopep8, and isort
6193
find copulas -name '*.py' | xargs autoflake --in-place --remove-all-unused-imports --remove-unused-variables
6294
autopep8 --in-place --recursive --aggressive copulas
6395
isort --apply --atomic --recursive copulas
@@ -70,45 +102,97 @@ fixlint: ## fix lint issues using autoflake, autopep8, and isort
70102
autopep8 --in-place --recursive --aggressive examples
71103
isort --apply --atomic --recursive examples
72104

105+
# TEST TARGETS
106+
107+
.PHONY: test
73108
test: ## run tests quickly with the default Python
74-
pytest
109+
python -m pytest --cov=copulas
75110

111+
.PHONY: test-all
76112
test-all: ## run tests on every Python version with tox
77113
tox
78114

79-
coverage: clean-coverage ## check code coverage quickly with the default Python
115+
.PHONY: coverage
116+
coverage: ## check code coverage quickly with the default Python
80117
coverage run --source copulas -m pytest
81118
coverage report -m
82119
coverage html
83120
$(BROWSER) htmlcov/index.html
84121

85-
clean-docs: ## remove previously built docs
86-
rm -f docs/copulas.rst
87-
rm -f docs/copulas.*.rst
88-
rm -f docs/modules.rst
89-
$(MAKE) -C docs clean
90122

123+
# DOCS TARGETS
124+
125+
.PHONY: docs
91126
docs: clean-docs ## generate Sphinx HTML documentation, including API docs
92-
sphinx-apidoc -o docs/ copulas
93127
$(MAKE) -C docs html
94128
touch docs/_build/html/.nojekyll
95129

96-
viewdocs: docs ## view docs in browser
130+
.PHONY: view-docs
131+
view-docs: docs ## view docs in browser
97132
$(BROWSER) docs/_build/html/index.html
98133

99-
servedocs: docs ## compile the docs watching for changes
100-
watchmedo shell-command -p '*.rst' -c '$(MAKE) -C docs html' -R -D .
134+
.PHONY: serve-docs
135+
serve-docs: view-docs ## compile the docs watching for changes
136+
watchmedo shell-command -W -R -D -p '*.rst;*.md' -c '$(MAKE) -C docs html' docs
101137

102-
release: dist ## package and upload a release
103-
twine upload dist/*
104138

105-
test-release: dist ## package and upload a release on TestPyPI
106-
twine upload --repository-url https://test.pypi.org/legacy/ dist/*
139+
# RELEASE TARGETS
107140

141+
.PHONY: dist
108142
dist: clean ## builds source and wheel package
109143
python setup.py sdist
110144
python setup.py bdist_wheel
111145
ls -l dist
112146

113-
install: clean ## install the package to the active Python's site-packages
114-
python setup.py install
147+
.PHONY: test-publish
148+
test-publish: dist ## package and upload a release on TestPyPI
149+
twine upload --repository-url https://test.pypi.org/legacy/ dist/*
150+
151+
.PHONY: publish
152+
publish: dist ## package and upload a release
153+
twine upload dist/*
154+
155+
.PHONY: bumpversion-release
156+
bumpversion-release: ## Merge master to stable and bumpversion release
157+
git checkout stable
158+
git merge --no-ff master -m"make release-tag: Merge branch 'master' into stable"
159+
bumpversion release
160+
git push --tags origin stable
161+
162+
.PHONY: bumpversion-patch
163+
bumpversion-patch: ## Merge stable to master and bumpversion patch
164+
git checkout master
165+
git merge stable
166+
bumpversion --no-tag patch
167+
git push
168+
169+
.PHONY: bumpversion-minor
170+
bumpversion-minor: ## Bump the version the next minor skipping the release
171+
bumpversion --no-tag minor
172+
173+
.PHONY: bumpversion-major
174+
bumpversion-major: ## Bump the version the next major skipping the release
175+
bumpversion --no-tag major
176+
177+
CURRENT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
178+
CHANGELOG_LINES := $(shell git diff HEAD..stable HISTORY.md | wc -l)
179+
180+
.PHONY: check-release
181+
check-release: ## Check if the release can be made
182+
ifneq ($(CURRENT_BRANCH),master)
183+
$(error Please make the release from master branch\n)
184+
endif
185+
ifeq ($(CHANGELOG_LINES),0)
186+
$(error Please insert the release notes in HISTORY.md before releasing)
187+
else
188+
@echo "A new release can be made"
189+
endif
190+
191+
.PHONY: release
192+
release: check-release bumpversion-release publish bumpversion-patch
193+
194+
.PHONY: release-minor
195+
release-minor: check-release bumpversion-minor release
196+
197+
.PHONY: release-major
198+
release-major: check-release bumpversion-major release

README.md

Lines changed: 17 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
[![][pypi-img]][pypi-url]
2-
[![][travis-img]][travis-url]
3-
41
<p align="left">
52
<img width=15% src="https://dai.lids.mit.edu/wp-content/uploads/2018/06/Logo_DAI_highres.png" alt=“Copulas” />
63
<i>An open source project from Data to AI Lab at MIT.</i>
74
</p>
85

6+
7+
[![][pypi-img]][pypi-url]
8+
[![][travis-img]][travis-url]
9+
910
# Copulas
1011

1112
[travis-img]: https://travis-ci.org/DAI-Lab/Copulas.svg?branch=master
@@ -80,11 +81,11 @@ a python terminal.
8081
>>> data = pd.read_csv('data/iris.data.csv')
8182
>>> data.head()
8283
feature_01 feature_02 feature_03 feature_04
83-
0 5.1 3.5 1.4 0.2
84-
1 4.9 3.0 1.4 0.2
85-
2 4.7 3.2 1.3 0.2
86-
3 4.6 3.1 1.5 0.2
87-
4 5.0 3.6 1.4 0.2
84+
0 5.1 3.5 1.4 0.2
85+
1 4.9 3.0 1.4 0.2
86+
2 4.7 3.2 1.3 0.2
87+
3 4.6 3.1 1.5 0.2
88+
4 5.0 3.6 1.4 0.2
8889
```
8990

9091
Once we have the data, we can pass it into the GaussianUnivariate class.
@@ -95,22 +96,21 @@ Once we have the data, we can pass it into the GaussianUnivariate class.
9596
>>> gu.fit(feature1)
9697
>>> print(gu)
9798
Distribution Type: Gaussian
98-
mean = 5.843333333333335
99-
standard deviation = 0.8253012917851409
100-
max = 7.9
101-
min = 4.3
99+
Variable name: feature_01
100+
Mean: 5.843333333333334
101+
Standard deviation: 0.8253012917851409
102102
```
103103

104104
Once you fit the distribution, you can get the pdf or cdf of data points and you can sample
105105
from the distribution.
106106

107107
```python
108-
>>> gu.get_pdf(5)
109-
0.28678585054723732
110-
>>> gu.get_cdf(5)
111-
0.15342617720079199
108+
>>> gu.probability_density(5)
109+
0.2867858505472377
110+
>>> gu.cumulative_distribution(5)
111+
0.15342617720079227
112112
>>> gu.sample(1)
113-
array([ 6.14745446])
113+
array([6.14745446])
114114
```
115115

116116
### Creating a Gaussian Copula
@@ -129,47 +129,27 @@ Distribution Type: Gaussian
129129
Variable name: feature_01
130130
Mean: 5.843333333333334
131131
Standard deviation: 0.8253012917851409
132-
Max: 7.9
133-
Min: 4.3
134132

135133
feature_02
136134
===============
137135
Distribution Type: Gaussian
138136
Variable name: feature_02
139137
Mean: 3.0540000000000003
140138
Standard deviation: 0.4321465800705435
141-
Max: 4.4
142-
Min: 2.0
143139

144140
feature_03
145141
===============
146142
Distribution Type: Gaussian
147143
Variable name: feature_03
148144
Mean: 3.758666666666666
149145
Standard deviation: 1.7585291834055212
150-
Max: 6.9
151-
Min: 1.0
152146

153147
feature_04
154148
===============
155149
Distribution Type: Gaussian
156150
Variable name: feature_04
157151
Mean: 1.1986666666666668
158152
Standard deviation: 0.7606126185881716
159-
Max: 2.5
160-
Min: 0.1
161-
162-
Copula Distribution:
163-
feature_01 feature_02 feature_03 feature_04
164-
0 -0.900681 1.032057 -1.341272 -1.312977
165-
1 -1.143017 -0.124958 -1.341272 -1.312977
166-
2 -1.385353 0.337848 -1.398138 -1.312977
167-
3 -1.506521 0.106445 -1.284407 -1.312977
168-
4 -1.021849 1.263460 -1.341272 -1.312977
169-
5 -0.537178 1.957669 -1.170675 -1.050031
170-
...
171-
172-
[150 rows x 4 columns]
173153

174154
Covariance matrix:
175155
[[ 1.26935536 0.64987728 0.94166734 ... -0.57458312 -0.14548004
@@ -185,10 +165,6 @@ Covariance matrix:
185165
0.14455133]
186166
[-0.43589371 -0.21867228 -0.27836438 ... 0.19208669 0.14455133
187167
0.22229033]]
188-
189-
Means:
190-
[-3.315866100213801e-16, -7.815970093361102e-16, 2.842170943040401e-16, -2.3684757858670006e-16]
191-
192168
```
193169

194170
Once you have fit the copula, you can sample from it.

0 commit comments

Comments
 (0)