Skip to content

Commit

Permalink
bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
heinwol committed Jan 11, 2024
1 parent c891fb9 commit 5f22e7a
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 87 deletions.
155 changes: 69 additions & 86 deletions jupyter/network_main.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,24 @@
"metadata": {},
"outputs": [],
"source": [
"# import sys\n",
"# sys.path.append('..')\n",
"import sys\n",
"sys.path.append('..')\n",
"\n",
"# %reload_ext autoreload\n",
"# %autoreload 2\n",
"# # %aimport sponge_networks\n",
"%reload_ext autoreload\n",
"%autoreload 2\n",
"%aimport sponge_networks\n",
"# # %aimport sponge_networks.utils"
]
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 2,
"id": "d2e6c76f-f590-4fee-897e-c0ede2a2367b",
"metadata": {},
"outputs": [],
"source": [
"import sponge_networks as sn\n",
"# from sponge_networks import sponge_networks \n",
"\n",
"import matplotlib.pyplot as plt\n",
"plt.rcParams[\"figure.figsize\"] = (10, 7)\n",
Expand All @@ -46,13 +47,13 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 3,
"id": "d8d29daf-9181-420f-a3c6-01fec02b531c",
"metadata": {},
"outputs": [],
"source": [
"nw = sn.build_sponge_network(\n",
" grid_type=\"triangular\", n_cols=4, n_rows=2,\n",
" grid_type=\"hexagonal\", n_cols=1, n_rows=1,\n",
" layout={\n",
" \"weights_sink_edge\": 1,\n",
" \"weights_loop\": 1,\n",
Expand All @@ -61,60 +62,92 @@
" \"weights_down_up\": 1,\n",
" },\n",
" generate_sinks=True,\n",
" visual_sink_edge_length=0.6\n",
" visual_sink_edge_length=1.\n",
")"
]
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 4,
"id": "d53a35c9-77e4-48d5-a8e4-13f7b3072e1c",
"metadata": {},
"outputs": [],
"source": [
"# nw.resource_network.plot()"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "14e9d69d-7cb0-4ab8-9e08-98c8a7625c77",
"metadata": {},
"outputs": [
{
"ename": "NameError",
"evalue": "name 'sim' is not defined",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[0;32mIn[5], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m df \u001b[38;5;241m=\u001b[39m \u001b[43msim\u001b[49m\u001b[38;5;241m.\u001b[39msimple_protocol()\n\u001b[1;32m 2\u001b[0m df\u001b[38;5;241m.\u001b[39msum(\u001b[38;5;241m1\u001b[39m)\n",
"\u001b[0;31mNameError\u001b[0m: name 'sim' is not defined"
]
}
],
"source": [
"df = sim.simple_protocol()\n",
"df.sum(1)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "8b91dcb0-fb07-4922-999a-6589be0ace63",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "6f3604e0323444249eb7619618f2004a",
"model_id": "de8f94305f3d414e8e0667b91c83f47f",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"interactive(children=(IntSlider(value=0, description='№ of iteration', max=49), Output()), _dom_classes=('widg…"
"interactive(children=(IntSlider(value=0, description='№ of iteration', max=99), Output()), _dom_classes=('widg…"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"sim = nw.run_sponge_simulation([50, 20, 20], n_iters=50)\n",
"nw.plot_simulation(sim, scale=1.4)"
"sim = nw.run_sponge_simulation([50, 0], n_iters=100)\n",
"nw.plot_simulation(sim, scale=1.2)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "f2785446-8bca-445d-bf45-0c18e03c3fc9",
"metadata": {},
"outputs": [],
"source": [
"4 * 5/6"
]
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": null,
"id": "e681f0f5-579a-4e67-9a1f-36cd39ad336d",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"NodeView(((0, 0), (1, 0), (2, 0), (0, 1), (1, 1), (2, 1), (0, 2), (1, 2), (2, 2), (0, -1), (1, -1), (2, -1)))"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"nw.resource_network.G.nodes()"
]
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": null,
"id": "2e608e24-410f-4ee6-bfe0-4b6586d97940",
"metadata": {},
"outputs": [],
Expand All @@ -129,91 +162,41 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": null,
"id": "6c162550-6e3c-49d4-86f5-151fbaba098a",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([[0, 1, 2],\n",
" [1, 0, 0],\n",
" [1, 3, 0]])"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"R"
]
},
{
"cell_type": "code",
"execution_count": 22,
"execution_count": null,
"id": "696aa541-e692-4e73-bc41-6d6c20397449",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([[0. , 0.33333333, 0.66666667],\n",
" [1. , 0. , 0. ],\n",
" [0.25 , 0.75 , 0. ]])"
]
},
"execution_count": 22,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"rn.stochastic_matrix"
]
},
{
"cell_type": "code",
"execution_count": 33,
"execution_count": null,
"id": "67202550-b3ac-4aca-a647-c0416320e15a",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([[[1, 1, 1],\n",
" [1, 1, 1],\n",
" [2, 2, 2]]])"
]
},
"execution_count": 33,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"v = np.array([[1, 1, 2]])\n",
"np.tensordot(v, np.array([1, 1, 1]), 0)"
]
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": null,
"id": "dc586d88-457b-454a-9431-bee826c2886b",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([2, 4, 2])"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"(np.array([1, 1, 1])@R)"
]
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "sponge-networks"
version = "0.2.2"
version = "0.2.3"
description = "a generalization of the resource network model with greedy vertices"
authors = ["heinwol <koreshkovhw@yandex.ru>"]
license = "MIT"
Expand Down

0 comments on commit 5f22e7a

Please sign in to comment.