Skip to content

Commit

Permalink
Move tests/ to project root
Browse files Browse the repository at this point in the history
  • Loading branch information
jessegrabowski committed Jul 18, 2024
1 parent 51704bd commit d222e4c
Show file tree
Hide file tree
Showing 43 changed files with 118 additions and 48 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
paths:
- ".github/workflows/*"
- "pymc_experimental/**"
- "tests/**"
- "setup.py"
- "pyproject.toml"
- "buildosx"
Expand All @@ -20,7 +21,7 @@ jobs:
os: [ubuntu-latest]
python-version: ["3.10"]
test-subset:
- pymc_experimental/tests
- tests
fail-fast: false
runs-on: ${{ matrix.os }}
env:
Expand Down Expand Up @@ -58,7 +59,7 @@ jobs:
os: [windows-latest]
python-version: ["3.12"]
test-subset:
- pymc_experimental/tests
- tests
fail-fast: false
runs-on: ${{ matrix.os }}
env:
Expand Down
2 changes: 1 addition & 1 deletion codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ coverage:
base: auto

ignore:
- "pymc_experimental/tests/*"
- "tests/*"

comment:
layout: "reach, diff, flags, files"
Expand Down
2 changes: 1 addition & 1 deletion notebooks/SARMA Example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2221,7 +2221,7 @@
],
"source": [
"airpass = pd.read_csv(\n",
" \"../pymc_experimental/tests/statespace/test_data/airpass.csv\",\n",
" \"../tests/statespace/test_data/airpass.csv\",\n",
" parse_dates=True,\n",
" date_format=\"%Y %b\",\n",
" index_col=0,\n",
Expand Down
70 changes: 55 additions & 15 deletions notebooks/discrete_markov_chain.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"cells": [
{
"cell_type": "markdown",
"id": "e1e16d35",
"metadata": {},
"source": [
"# Discrete Markov Chain Distribution"
Expand All @@ -10,6 +11,7 @@
{
"cell_type": "code",
"execution_count": 1,
"id": "cc15e4cd",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -20,8 +22,21 @@
{
"cell_type": "code",
"execution_count": 2,
"id": "7c983797",
"metadata": {},
"outputs": [],
"outputs": [
{
"ename": "ModuleNotFoundError",
"evalue": "No module named 'pymc_experimental'",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)",
"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",
"\u001b[0;31mModuleNotFoundError\u001b[0m: No module named 'pymc_experimental'"
]
}
],
"source": [
"import arviz as az\n",
"import numpy as np\n",
Expand All @@ -38,25 +53,18 @@
},
{
"cell_type": "markdown",
"id": "a36d5e56",
"metadata": {},
"source": [
"## Demonstration of API "
]
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"id": "05d16797",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/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",
" warnings.warn(\n"
]
}
],
"outputs": [],
"source": [
"with pm.Model() as model:\n",
" logit_P = pm.Normal(\"logit_P\", sigma=0.1, size=(3, 3))\n",
Expand All @@ -66,6 +74,7 @@
{
"cell_type": "code",
"execution_count": 4,
"id": "911fc178",
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -131,6 +140,7 @@
},
{
"cell_type": "markdown",
"id": "5d74be4c",
"metadata": {},
"source": [
"Dims of the output are `(batch, time)`."
Expand All @@ -139,6 +149,7 @@
{
"cell_type": "code",
"execution_count": 5,
"id": "88acfab3",
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -167,6 +178,7 @@
},
{
"cell_type": "markdown",
"id": "2d67e342",
"metadata": {},
"source": [
"## Parameter Recovery\n",
Expand All @@ -177,6 +189,7 @@
{
"cell_type": "code",
"execution_count": 6,
"id": "33081e17",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -201,6 +214,7 @@
{
"cell_type": "code",
"execution_count": 7,
"id": "f92d551a",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -210,6 +224,7 @@
{
"cell_type": "code",
"execution_count": 8,
"id": "31751f8c",
"metadata": {
"scrolled": false
},
Expand Down Expand Up @@ -287,6 +302,7 @@
{
"cell_type": "code",
"execution_count": 9,
"id": "87bdb1e0",
"metadata": {},
"outputs": [
{
Expand All @@ -306,6 +322,7 @@
},
{
"cell_type": "markdown",
"id": "610b3596",
"metadata": {},
"source": [
"## Hidden markov model\n",
Expand All @@ -318,6 +335,7 @@
{
"cell_type": "code",
"execution_count": 10,
"id": "dc1f9e25",
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -348,6 +366,7 @@
{
"cell_type": "code",
"execution_count": 11,
"id": "67f7e824",
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -524,6 +543,7 @@
{
"cell_type": "code",
"execution_count": 12,
"id": "1b5d3444",
"metadata": {
"scrolled": false
},
Expand Down Expand Up @@ -594,6 +614,7 @@
{
"cell_type": "code",
"execution_count": 13,
"id": "04de50a9",
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -758,6 +779,7 @@
},
{
"cell_type": "markdown",
"id": "44c1f25b",
"metadata": {},
"source": [
"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. "
Expand All @@ -766,6 +788,7 @@
{
"cell_type": "code",
"execution_count": 14,
"id": "e382b4d4",
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -848,6 +871,7 @@
},
{
"cell_type": "markdown",
"id": "f778d068",
"metadata": {},
"source": [
"### Post-Estimation Diagnostics\n",
Expand All @@ -858,6 +882,7 @@
{
"cell_type": "code",
"execution_count": 15,
"id": "c45b726c",
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -887,6 +912,7 @@
},
{
"cell_type": "markdown",
"id": "b057e84c",
"metadata": {},
"source": [
"...but the trace plots look great! "
Expand All @@ -895,6 +921,7 @@
{
"cell_type": "code",
"execution_count": 16,
"id": "34bb9eb9",
"metadata": {},
"outputs": [
{
Expand All @@ -915,6 +942,7 @@
},
{
"cell_type": "markdown",
"id": "65bb1c27",
"metadata": {},
"source": [
"Even after 20,000 draws, we only have about 500 samples for the transition probabilities to the more rare state 1."
Expand All @@ -923,6 +951,7 @@
{
"cell_type": "code",
"execution_count": 17,
"id": "2d050b4e",
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -1133,6 +1162,7 @@
},
{
"cell_type": "markdown",
"id": "aa017801",
"metadata": {},
"source": [
"## Comparison with Statsmodels"
Expand All @@ -1141,6 +1171,7 @@
{
"cell_type": "code",
"execution_count": 18,
"id": "8200aae3",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -1155,6 +1186,7 @@
{
"cell_type": "code",
"execution_count": 19,
"id": "febd7972",
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -1196,6 +1228,7 @@
},
{
"cell_type": "markdown",
"id": "5588a4f6",
"metadata": {},
"source": [
"## Posterior Prediction"
Expand All @@ -1204,6 +1237,7 @@
{
"cell_type": "code",
"execution_count": 20,
"id": "c4399802",
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -1266,6 +1300,7 @@
{
"cell_type": "code",
"execution_count": 21,
"id": "47c8ce2a",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -1279,6 +1314,7 @@
{
"cell_type": "code",
"execution_count": 22,
"id": "9c047eb0",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -1288,6 +1324,7 @@
{
"cell_type": "code",
"execution_count": 23,
"id": "9a8b3055",
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -1317,6 +1354,7 @@
},
{
"cell_type": "markdown",
"id": "92eb9a8f",
"metadata": {},
"source": [
"## Regime Inference\n",
Expand All @@ -1327,6 +1365,7 @@
{
"cell_type": "code",
"execution_count": 24,
"id": "4487098b",
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -1364,6 +1403,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "7f037fb9",
"metadata": {},
"outputs": [],
"source": []
Expand All @@ -1372,9 +1412,9 @@
"metadata": {
"hide_input": false,
"kernelspec": {
"display_name": "pymc-experimental",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "pymc-experimental"
"name": "python3"
},
"language_info": {
"codemirror_mode": {
Expand All @@ -1386,7 +1426,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.6"
"version": "3.11.9"
},
"toc": {
"base_numbering": 1,
Expand Down
Loading

0 comments on commit d222e4c

Please sign in to comment.