Skip to content

Commit

Permalink
Change the parallelization to be handled by joblib (#19)
Browse files Browse the repository at this point in the history
* convert the inference scripts to use joblib

* remove unnecessary imports

* change to joblib

* pass by reference

* pass by reference

* update to parallelize

* fixes

* update data files

* fix setup file

* add configuration model

* rename r

* update

* added a script to collate the cm data

* updated collation scripts

* added data

* fix num samples/num posterior vals mismatch

* add stochastic root finding back in

* updated script for fig. 1b

* added script to generate fig 1c

* updates

* updates

* renaming and reorganizing

* updates

* rename p to alpha
  • Loading branch information
nwlandry authored Dec 13, 2023
1 parent 2f3d8a4 commit 3372b8f
Show file tree
Hide file tree
Showing 64 changed files with 5,516 additions and 1,905 deletions.
1 change: 1 addition & 0 deletions Data/cm.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Data/erdos-renyi.json

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion Data/frac_vs_beta.json

This file was deleted.

1 change: 0 additions & 1 deletion Data/infer_contagion_functions.json

This file was deleted.

2 changes: 1 addition & 1 deletion Data/sbm.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Data/watts-strogatz.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Data/zkc_frac_vs_beta.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Data/zkc_infer_contagion_functions.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Data/zkc_infer_vs_tmax.json

Large diffs are not rendered by default.

132 changes: 132 additions & 0 deletions Extra/plot_frac_vs_beta.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import matplotlib.pyplot as plt\n",
"import json\n",
"import numpy as np\n",
"from lcs import *"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"with open(\"Data/frac_vs_beta.json\") as file:\n",
" data = json.load(file)\n",
"beta = np.array(data[\"beta\"], dtype=float)\n",
"frac = np.array(data[\"fraction\"], dtype=float)\n",
"ps = np.array(data[\"ps\"], dtype=float)\n",
"sps = np.array(data[\"sps\"], dtype=float)\n",
"fce = np.array(data[\"fce\"], dtype=float)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import cmasher as cmr\n",
"\n",
"cmap = cmr.sunburst\n",
"cmap = cmr.ember\n",
"\n",
"ps_summary = ps.mean(axis=2).T\n",
"\n",
"c = plt.imshow(\n",
" to_imshow_orientation(ps_summary),\n",
" extent=(min(frac), max(frac), min(beta), max(beta)),\n",
" aspect=\"auto\",\n",
" cmap=cmap,\n",
")\n",
"plt.xlabel(r\"$f$\")\n",
"plt.ylabel(r\"$\\beta$\")\n",
"plt.colorbar(c)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import cmasher as cmr\n",
"\n",
"cmap = cmr.sunburst\n",
"cmap = cmr.ember\n",
"\n",
"sps_summary = sps.mean(axis=2).T\n",
"\n",
"c = plt.imshow(\n",
" to_imshow_orientation(sps_summary),\n",
" extent=(min(frac), max(frac), min(beta), max(beta)),\n",
" aspect=\"auto\",\n",
" cmap=cmap,\n",
")\n",
"plt.xlabel(r\"$f$\")\n",
"plt.ylabel(r\"$\\beta$\")\n",
"plt.colorbar(c)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import cmasher as cmr\n",
"\n",
"cmap = cmr.sunburst\n",
"cmap = cmr.ember\n",
"\n",
"fce_summary = fce.mean(axis=2).T\n",
"\n",
"c = plt.imshow(\n",
" to_imshow_orientation(fce_summary),\n",
" extent=(min(frac), max(frac), min(beta), max(beta)),\n",
" aspect=\"auto\",\n",
" cmap=cmap,\n",
")\n",
"plt.xlabel(r\"$f$\")\n",
"plt.ylabel(r\"$\\beta$\")\n",
"plt.colorbar(c)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "hyper",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.0"
},
"orig_nbformat": 4
},
"nbformat": 4,
"nbformat_minor": 2
}
File renamed without changes.
361 changes: 361 additions & 0 deletions Extra/plot_infer_contagion_functions.ipynb

Large diffs are not rendered by default.

28 changes: 14 additions & 14 deletions Figures/Fig1/a.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 3372b8f

Please sign in to comment.