Skip to content

Commit 5deb4fd

Browse files
author
fabioferreira
committed
Actions CI
1 parent d2faaba commit 5deb4fd

4 files changed

Lines changed: 80 additions & 8 deletions

File tree

.github/workflows/ci.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
jobs:
12+
build:
13+
runs-on: macos-latest
14+
strategy:
15+
matrix:
16+
python-version: ["3.11"]
17+
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
22+
- name: Set up Python
23+
uses: actions/setup-python@v5
24+
with:
25+
python-version: ${{ matrix.python-version }}
26+
cache: "pip"
27+
28+
- name: Install dependencies
29+
run: |
30+
python -m pip install --upgrade pip wheel
31+
python -m pip install -r requirements.txt
32+
python -m pip install --break-system-packages -e .
33+
34+
- name: Run estimator tests
35+
run: |
36+
python tests/unittests_estimators.py
37+
python tests/unittests_evaluations.py
38+
python tests/unittests_simulations.py
39+
python tests/unittests_utils.py
40+
41+
#- name: Run torch regression smoke tests
42+
# run: |
43+
# python -m pytest tests/test_nf_torch.py
44+
# python -m pytest tests/test_kmn_torch.py
45+
46+
- name: Build distributions
47+
run: |
48+
python -m pip install build
49+
python -m build --sdist --wheel
50+
51+

.travis.yml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,18 @@ install:
99
- pip install -q -r requirements.txt
1010
- pip install --break-system-packages -e .
1111

12+
before_deploy:
13+
- python -m pip install build
14+
- python -m build --sdist --wheel
15+
1216
# command to run tests
1317
script:
1418
- python tests/unittests_estimators.py
1519
- python tests/unittests_evaluations.py
1620
- python tests/unittests_simulations.py
1721
- python tests/unittests_utils.py
18-
#- python -m pytest tests/test_nf_torch.py
19-
#- python -m pytest tests/test_kmn_torch.py
22+
- python tests/test_nf_torch.py
23+
- python tests/test_kmn_torch.py
2024

2125
notifications:
2226
email:
@@ -25,3 +29,13 @@ notifications:
2529
- fabioferreira@mailbox.org
2630
on_success: never
2731
on_failure: never
32+
33+
deploy:
34+
provider: pypi
35+
user: "__token__"
36+
password:
37+
secure: "REPLACE_WITH_ENCRYPTED_TOKEN"
38+
distributions: "sdist bdist_wheel"
39+
on:
40+
branch: main
41+
tags: true

cde/utils/async_executor.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
import numpy as np
55
from progressbar.bar import ProgressBar
66

7+
try:
8+
multiprocessing.set_start_method('fork')
9+
except RuntimeError:
10+
pass
11+
712
class AsyncExecutor:
813

914
def __init__(self, n_jobs=1):

tests/unittests_simulations.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ def test_pdf(self):
204204
p_sim = sim_model.pdf(x,y)
205205
p_true = stats.norm.pdf(y, loc=1, scale=2)
206206
diff = np.sum(np.abs(p_sim - p_true))
207-
self.assertAlmostEquals(diff, 0.0, places=2)
207+
self.assertAlmostEqual(diff, 0.0, places=2)
208208

209209
def test_cdf(self):
210210
sim_model = EconDensity()
@@ -213,7 +213,7 @@ def test_cdf(self):
213213
p_sim = sim_model.cdf(x,y)
214214
p_true = stats.norm.cdf(y, loc=1, scale=2)
215215
diff = np.sum(np.abs(p_sim - p_true))
216-
self.assertAlmostEquals(diff, 0.0, places=2)
216+
self.assertAlmostEqual(diff, 0.0, places=2)
217217

218218
def test_value_at_risk(self):
219219
sim_model = EconDensity()
@@ -252,8 +252,8 @@ def test_random_seed(self):
252252

253253
diff_x = np.sum(np.abs(X1[:100] - X2[:]))
254254
diff_y = np.sum(np.abs(Y1[:100] - Y2[:]))
255-
self.assertAlmostEquals(diff_x, 0, places=2)
256-
self.assertAlmostEquals(diff_y, 0, places=2)
255+
self.assertAlmostEqual(diff_x, 0, places=2)
256+
self.assertAlmostEqual(diff_y, 0, places=2)
257257

258258
class TetsSkewNormal(unittest.TestCase):
259259
def setUp(self):
@@ -518,7 +518,9 @@ def test_covariance(self):
518518
self.assertAlmostEqual(cov_est[0][1][0], sigma[1][0], places=2)
519519

520520

521-
def mean_pdf(density, x_cond, n_samples=10 ** 6):
521+
_DEFAULT_MC_SAMPLES = 5 * 10 ** 6
522+
523+
def mean_pdf(density, x_cond, n_samples=_DEFAULT_MC_SAMPLES):
522524
means = np.zeros((x_cond.shape[0], density.ndim_y))
523525
for i in range(x_cond.shape[0]):
524526
x = x = np.tile(x_cond[i].reshape((1, x_cond[i].shape[0])), (n_samples, 1))
@@ -527,7 +529,7 @@ def mean_pdf(density, x_cond, n_samples=10 ** 6):
527529
means[i] = integral
528530
return means
529531

530-
def covariance_pdf(density, x_cond, n_samples=10 ** 6):
532+
def covariance_pdf(density, x_cond, n_samples=_DEFAULT_MC_SAMPLES):
531533
covs = np.zeros((x_cond.shape[0], density.ndim_y, density.ndim_y))
532534
mean = density.mean_(x_cond)
533535
for i in range(x_cond.shape[0]):

0 commit comments

Comments
 (0)