Skip to content

Commit d222e4c

Browse files
Move tests/ to project root
1 parent 51704bd commit d222e4c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+118
-48
lines changed

.github/workflows/test.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77
paths:
88
- ".github/workflows/*"
99
- "pymc_experimental/**"
10+
- "tests/**"
1011
- "setup.py"
1112
- "pyproject.toml"
1213
- "buildosx"
@@ -20,7 +21,7 @@ jobs:
2021
os: [ubuntu-latest]
2122
python-version: ["3.10"]
2223
test-subset:
23-
- pymc_experimental/tests
24+
- tests
2425
fail-fast: false
2526
runs-on: ${{ matrix.os }}
2627
env:
@@ -58,7 +59,7 @@ jobs:
5859
os: [windows-latest]
5960
python-version: ["3.12"]
6061
test-subset:
61-
- pymc_experimental/tests
62+
- tests
6263
fail-fast: false
6364
runs-on: ${{ matrix.os }}
6465
env:

codecov.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ coverage:
2222
base: auto
2323

2424
ignore:
25-
- "pymc_experimental/tests/*"
25+
- "tests/*"
2626

2727
comment:
2828
layout: "reach, diff, flags, files"

notebooks/SARMA Example.ipynb

+1-1
Original file line numberDiff line numberDiff line change
@@ -2221,7 +2221,7 @@
22212221
],
22222222
"source": [
22232223
"airpass = pd.read_csv(\n",
2224-
" \"../pymc_experimental/tests/statespace/test_data/airpass.csv\",\n",
2224+
" \"../tests/statespace/test_data/airpass.csv\",\n",
22252225
" parse_dates=True,\n",
22262226
" date_format=\"%Y %b\",\n",
22272227
" index_col=0,\n",

notebooks/discrete_markov_chain.ipynb

+55-15
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"cells": [
33
{
44
"cell_type": "markdown",
5+
"id": "e1e16d35",
56
"metadata": {},
67
"source": [
78
"# Discrete Markov Chain Distribution"
@@ -10,6 +11,7 @@
1011
{
1112
"cell_type": "code",
1213
"execution_count": 1,
14+
"id": "cc15e4cd",
1315
"metadata": {},
1416
"outputs": [],
1517
"source": [
@@ -20,8 +22,21 @@
2022
{
2123
"cell_type": "code",
2224
"execution_count": 2,
25+
"id": "7c983797",
2326
"metadata": {},
24-
"outputs": [],
27+
"outputs": [
28+
{
29+
"ename": "ModuleNotFoundError",
30+
"evalue": "No module named 'pymc_experimental'",
31+
"output_type": "error",
32+
"traceback": [
33+
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
34+
"\u001b[0;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)",
35+
"Cell \u001b[0;32mIn[2], line 11\u001b[0m\n\u001b[1;32m 7\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mmatplotlib\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mpyplot\u001b[39;00m \u001b[38;5;28;01mas\u001b[39;00m \u001b[38;5;21;01mplt\u001b[39;00m\n\u001b[1;32m 9\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mmatplotlib\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m ticker \u001b[38;5;28;01mas\u001b[39;00m mtick\n\u001b[0;32m---> 11\u001b[0m \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;21;01mpymc_experimental\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mdistributions\u001b[39;00m\u001b[38;5;21;01m.\u001b[39;00m\u001b[38;5;21;01mtimeseries\u001b[39;00m \u001b[38;5;28;01mimport\u001b[39;00m DiscreteMarkovChain\n",
36+
"\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'pymc_experimental'"
37+
]
38+
}
39+
],
2540
"source": [
2641
"import arviz as az\n",
2742
"import numpy as np\n",
@@ -38,25 +53,18 @@
3853
},
3954
{
4055
"cell_type": "markdown",
56+
"id": "a36d5e56",
4157
"metadata": {},
4258
"source": [
4359
"## Demonstration of API "
4460
]
4561
},
4662
{
4763
"cell_type": "code",
48-
"execution_count": 3,
64+
"execution_count": null,
65+
"id": "05d16797",
4966
"metadata": {},
50-
"outputs": [
51-
{
52-
"name": "stderr",
53-
"output_type": "stream",
54-
"text": [
55-
"/home/ricardo/Documents/Projects/pymc-experimental/pymc_experimental/distributions/timeseries.py:159: UserWarning: Initial distribution not specified, defaulting to `Categorical.dist(p=pt.full((k_states, ), 1/k_states), shape=...)`. You can specify an init_dist manually to suppress this warning.\n",
56-
" warnings.warn(\n"
57-
]
58-
}
59-
],
67+
"outputs": [],
6068
"source": [
6169
"with pm.Model() as model:\n",
6270
" logit_P = pm.Normal(\"logit_P\", sigma=0.1, size=(3, 3))\n",
@@ -66,6 +74,7 @@
6674
{
6775
"cell_type": "code",
6876
"execution_count": 4,
77+
"id": "911fc178",
6978
"metadata": {},
7079
"outputs": [
7180
{
@@ -131,6 +140,7 @@
131140
},
132141
{
133142
"cell_type": "markdown",
143+
"id": "5d74be4c",
134144
"metadata": {},
135145
"source": [
136146
"Dims of the output are `(batch, time)`."
@@ -139,6 +149,7 @@
139149
{
140150
"cell_type": "code",
141151
"execution_count": 5,
152+
"id": "88acfab3",
142153
"metadata": {},
143154
"outputs": [
144155
{
@@ -167,6 +178,7 @@
167178
},
168179
{
169180
"cell_type": "markdown",
181+
"id": "2d67e342",
170182
"metadata": {},
171183
"source": [
172184
"## Parameter Recovery\n",
@@ -177,6 +189,7 @@
177189
{
178190
"cell_type": "code",
179191
"execution_count": 6,
192+
"id": "33081e17",
180193
"metadata": {},
181194
"outputs": [],
182195
"source": [
@@ -201,6 +214,7 @@
201214
{
202215
"cell_type": "code",
203216
"execution_count": 7,
217+
"id": "f92d551a",
204218
"metadata": {},
205219
"outputs": [],
206220
"source": [
@@ -210,6 +224,7 @@
210224
{
211225
"cell_type": "code",
212226
"execution_count": 8,
227+
"id": "31751f8c",
213228
"metadata": {
214229
"scrolled": false
215230
},
@@ -287,6 +302,7 @@
287302
{
288303
"cell_type": "code",
289304
"execution_count": 9,
305+
"id": "87bdb1e0",
290306
"metadata": {},
291307
"outputs": [
292308
{
@@ -306,6 +322,7 @@
306322
},
307323
{
308324
"cell_type": "markdown",
325+
"id": "610b3596",
309326
"metadata": {},
310327
"source": [
311328
"## Hidden markov model\n",
@@ -318,6 +335,7 @@
318335
{
319336
"cell_type": "code",
320337
"execution_count": 10,
338+
"id": "dc1f9e25",
321339
"metadata": {},
322340
"outputs": [
323341
{
@@ -348,6 +366,7 @@
348366
{
349367
"cell_type": "code",
350368
"execution_count": 11,
369+
"id": "67f7e824",
351370
"metadata": {},
352371
"outputs": [
353372
{
@@ -524,6 +543,7 @@
524543
{
525544
"cell_type": "code",
526545
"execution_count": 12,
546+
"id": "1b5d3444",
527547
"metadata": {
528548
"scrolled": false
529549
},
@@ -594,6 +614,7 @@
594614
{
595615
"cell_type": "code",
596616
"execution_count": 13,
617+
"id": "04de50a9",
597618
"metadata": {},
598619
"outputs": [
599620
{
@@ -758,6 +779,7 @@
758779
},
759780
{
760781
"cell_type": "markdown",
782+
"id": "44c1f25b",
761783
"metadata": {},
762784
"source": [
763785
"It's quite difficult to sample this model, so I use a very high `target_accept` and a very large number of draws. It seems to be hard to get a sufficient number of effective samples for rare rates without a lot of draws. "
@@ -766,6 +788,7 @@
766788
{
767789
"cell_type": "code",
768790
"execution_count": 14,
791+
"id": "e382b4d4",
769792
"metadata": {},
770793
"outputs": [
771794
{
@@ -848,6 +871,7 @@
848871
},
849872
{
850873
"cell_type": "markdown",
874+
"id": "f778d068",
851875
"metadata": {},
852876
"source": [
853877
"### Post-Estimation Diagnostics\n",
@@ -858,6 +882,7 @@
858882
{
859883
"cell_type": "code",
860884
"execution_count": 15,
885+
"id": "c45b726c",
861886
"metadata": {},
862887
"outputs": [
863888
{
@@ -887,6 +912,7 @@
887912
},
888913
{
889914
"cell_type": "markdown",
915+
"id": "b057e84c",
890916
"metadata": {},
891917
"source": [
892918
"...but the trace plots look great! "
@@ -895,6 +921,7 @@
895921
{
896922
"cell_type": "code",
897923
"execution_count": 16,
924+
"id": "34bb9eb9",
898925
"metadata": {},
899926
"outputs": [
900927
{
@@ -915,6 +942,7 @@
915942
},
916943
{
917944
"cell_type": "markdown",
945+
"id": "65bb1c27",
918946
"metadata": {},
919947
"source": [
920948
"Even after 20,000 draws, we only have about 500 samples for the transition probabilities to the more rare state 1."
@@ -923,6 +951,7 @@
923951
{
924952
"cell_type": "code",
925953
"execution_count": 17,
954+
"id": "2d050b4e",
926955
"metadata": {},
927956
"outputs": [
928957
{
@@ -1133,6 +1162,7 @@
11331162
},
11341163
{
11351164
"cell_type": "markdown",
1165+
"id": "aa017801",
11361166
"metadata": {},
11371167
"source": [
11381168
"## Comparison with Statsmodels"
@@ -1141,6 +1171,7 @@
11411171
{
11421172
"cell_type": "code",
11431173
"execution_count": 18,
1174+
"id": "8200aae3",
11441175
"metadata": {},
11451176
"outputs": [],
11461177
"source": [
@@ -1155,6 +1186,7 @@
11551186
{
11561187
"cell_type": "code",
11571188
"execution_count": 19,
1189+
"id": "febd7972",
11581190
"metadata": {},
11591191
"outputs": [
11601192
{
@@ -1196,6 +1228,7 @@
11961228
},
11971229
{
11981230
"cell_type": "markdown",
1231+
"id": "5588a4f6",
11991232
"metadata": {},
12001233
"source": [
12011234
"## Posterior Prediction"
@@ -1204,6 +1237,7 @@
12041237
{
12051238
"cell_type": "code",
12061239
"execution_count": 20,
1240+
"id": "c4399802",
12071241
"metadata": {},
12081242
"outputs": [
12091243
{
@@ -1266,6 +1300,7 @@
12661300
{
12671301
"cell_type": "code",
12681302
"execution_count": 21,
1303+
"id": "47c8ce2a",
12691304
"metadata": {},
12701305
"outputs": [],
12711306
"source": [
@@ -1279,6 +1314,7 @@
12791314
{
12801315
"cell_type": "code",
12811316
"execution_count": 22,
1317+
"id": "9c047eb0",
12821318
"metadata": {},
12831319
"outputs": [],
12841320
"source": [
@@ -1288,6 +1324,7 @@
12881324
{
12891325
"cell_type": "code",
12901326
"execution_count": 23,
1327+
"id": "9a8b3055",
12911328
"metadata": {},
12921329
"outputs": [
12931330
{
@@ -1317,6 +1354,7 @@
13171354
},
13181355
{
13191356
"cell_type": "markdown",
1357+
"id": "92eb9a8f",
13201358
"metadata": {},
13211359
"source": [
13221360
"## Regime Inference\n",
@@ -1327,6 +1365,7 @@
13271365
{
13281366
"cell_type": "code",
13291367
"execution_count": 24,
1368+
"id": "4487098b",
13301369
"metadata": {},
13311370
"outputs": [
13321371
{
@@ -1364,6 +1403,7 @@
13641403
{
13651404
"cell_type": "code",
13661405
"execution_count": null,
1406+
"id": "7f037fb9",
13671407
"metadata": {},
13681408
"outputs": [],
13691409
"source": []
@@ -1372,9 +1412,9 @@
13721412
"metadata": {
13731413
"hide_input": false,
13741414
"kernelspec": {
1375-
"display_name": "pymc-experimental",
1415+
"display_name": "Python 3 (ipykernel)",
13761416
"language": "python",
1377-
"name": "pymc-experimental"
1417+
"name": "python3"
13781418
},
13791419
"language_info": {
13801420
"codemirror_mode": {
@@ -1386,7 +1426,7 @@
13861426
"name": "python",
13871427
"nbconvert_exporter": "python",
13881428
"pygments_lexer": "ipython3",
1389-
"version": "3.10.6"
1429+
"version": "3.11.9"
13901430
},
13911431
"toc": {
13921432
"base_numbering": 1,

0 commit comments

Comments
 (0)