Skip to content

Commit b39f2c8

Browse files
committed
make release-tag: Merge branch 'master' into stable
2 parents c546c5d + f1ef8ac commit b39f2c8

30 files changed

+153
-36
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
runs-on: ${{ matrix.os }}
1212
strategy:
1313
matrix:
14-
python-version: [3.5, 3.6, 3.7]
14+
python-version: [3.5, 3.6, 3.7, 3.8]
1515
os: [ubuntu-latest, macos-latest]
1616

1717
steps:

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
dist: bionic
33
language: python
44
python:
5+
- 3.8
56
- 3.7
67
- 3.6
78
- 3.5

HISTORY.md

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

3+
## 0.3.2 (2020-08-08)
4+
5+
### General Improvements
6+
7+
* Support Python 3.8 - Issue [#185](https://github.com/sdv-dev/Copulas/issues/185) by @csala
8+
* Support scipy <1.3 - Issue [#180](https://github.com/sdv-dev/Copulas/issues/180) by @csala
9+
10+
# New Features
11+
12+
* Add Uniform Univariate - Issue [#179](https://github.com/sdv-dev/Copulas/issues/179) by @rollervan
13+
314
## 0.3.1 (2020-07-09)
415

516
### General Improvements

Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ fix-lint: ## fix lint issues using autoflake, autopep8, and isort
105105

106106
.PHONY: test-unit
107107
test-unit: ## run unit tests using pytest
108-
python -m pytest --basetemp=${ENVTMPDIR} --disable-warnings --cov=copulas tests/unit
108+
python -m pytest --disable-warnings --cov=copulas tests/unit
109109

110110
.PHONY: test-numerical
111111
test-numerical: ## run numerical tests using pytest
@@ -115,6 +115,10 @@ test-numerical: ## run numerical tests using pytest
115115
test-end-to-end: ## run end-to-end tests using pytest
116116
python -m pytest --disable-warnings --cov=copulas tests/end-to-end
117117

118+
.PHONY: test-pytest
119+
test-pytest: ## run all the tests using pytest
120+
python -m pytest --disable-warnings --cov=copulas
121+
118122
.PHONY: test-readme
119123
test-readme: ## run the readme snippets
120124
rm -rf tests/readme_test && mkdir tests/readme_test
@@ -126,7 +130,7 @@ test-tutorials: ## run the tutorial notebooks
126130
jupyter nbconvert --execute --ExecutePreprocessor.timeout=600 tutorials/*.ipynb --stdout > /dev/null
127131

128132
.PHONY: test
129-
test: test-unit test-end-to-end test-numerical test-readme test-tutorials ## test everything that needs test dependencies
133+
test: test-pytest test-readme test-tutorials ## test everything that needs test dependencies
130134

131135
.PHONY: test-devel
132136
test-devel: lint docs ## test everything that needs development dependencies

copulas/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
__author__ = 'MIT Data To AI Lab'
66
__email__ = 'dailabmit@gmail.com',
7-
__version__ = '0.3.1'
7+
__version__ = '0.3.2.dev2'
88

99
import contextlib
1010
import importlib

copulas/multivariate/gaussian.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def _transform_to_normal(self, X):
5555
U = list()
5656
for column_name, univariate in zip(self.columns, self.univariates):
5757
column = X[column_name]
58-
U.append(univariate.cdf(column).clip(EPSILON, 1 - EPSILON))
58+
U.append(univariate.cdf(column.values).clip(EPSILON, 1 - EPSILON))
5959

6060
return stats.norm.ppf(np.column_stack(U))
6161

copulas/multivariate/vine.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import logging
2+
import sys
3+
import warnings
24

35
import numpy as np
46
import pandas as pd
@@ -62,6 +64,12 @@ class VineCopula(Multivariate):
6264
"""
6365
@store_args
6466
def __init__(self, vine_type, random_seed=None):
67+
if sys.version_info > (3, 8):
68+
warnings.warn(
69+
'Vines have not been fully tested on Python 3.8 and might '
70+
'produce wrong results. Please use Python 3.5, 3.6 or 3.7'
71+
)
72+
6573
self.random_seed = random_seed
6674
self.vine_type = vine_type
6775
self.u_matrix = None

copulas/univariate/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from copulas.univariate.gaussian_kde import GaussianKDE
66
from copulas.univariate.student_t import StudentTUnivariate
77
from copulas.univariate.truncated_gaussian import TruncatedGaussian
8+
from copulas.univariate.uniform import UniformUnivariate
89

910
__all__ = (
1011
'BetaUnivariate',
@@ -15,5 +16,6 @@
1516
'StudentTUnivariate',
1617
'Univariate',
1718
'ParametricType',
18-
'BoundedType'
19+
'BoundedType',
20+
'UniformUnivariate'
1921
)

copulas/univariate/selection.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,15 @@ def select_univariate(X, candidates):
2020
best_ks = np.inf
2121
best_model = None
2222
for model in candidates:
23-
instance = get_instance(model)
24-
instance.fit(X)
25-
ks, _ = kstest(X, instance.cdf)
26-
if ks < best_ks:
27-
best_ks = ks
28-
best_model = model
23+
try:
24+
instance = get_instance(model)
25+
instance.fit(X)
26+
ks, _ = kstest(X, instance.cdf)
27+
if ks < best_ks:
28+
best_ks = ks
29+
best_model = model
30+
except ValueError:
31+
# Distribution not supported
32+
pass
2933

3034
return get_instance(best_model)

copulas/univariate/uniform.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import numpy as np
2+
from scipy.stats import uniform
3+
4+
from copulas.univariate.base import BoundedType, ParametricType, ScipyModel
5+
6+
7+
class UniformUnivariate(ScipyModel):
8+
"""Uniform univariate model."""
9+
10+
PARAMETRIC = ParametricType.PARAMETRIC
11+
BOUNDED = BoundedType.BOUNDED
12+
13+
MODEL_CLASS = uniform
14+
15+
def _fit_constant(self, X):
16+
self._params = {
17+
'loc': np.min(X),
18+
'scale': np.max(X) - np.min(X)
19+
}
20+
21+
def _fit(self, X):
22+
self._params = {
23+
'loc': np.min(X),
24+
'scale': np.max(X) - np.min(X)
25+
}
26+
27+
def _is_constant(self):
28+
return self._params['scale'] == 0

0 commit comments

Comments
 (0)