Skip to content

Commit ab82907

Browse files
committed
Unit tests, small API changes and updated notebooks
1 parent 31e06c8 commit ab82907

6 files changed

Lines changed: 505 additions & 133 deletions

notebooks/PyBroMo - 1. Simulate 3D trajectories - single core.ipynb

Lines changed: 21 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@
7979
"rs = np.random.RandomState(seed=1)\n",
8080
"print('Initial random state:', pbm.hash_(rs.get_state()))\n",
8181
"\n",
82+
"# Simulation time step (seconds)\n",
83+
"t_step = 0.5e-6\n",
84+
"\n",
85+
"# Time duration of the simulation (seconds)\n",
86+
"t_max = 1\n",
87+
"\n",
8288
"# Diffusion coefficient\n",
8389
"Du = 12.0 # um^2 / s\n",
8490
"D1 = Du*(1e-6)**2 # m^2 / s\n",
@@ -87,18 +93,14 @@
8793
"# Simulation box definition\n",
8894
"box = pbm.Box(x1=-4.e-6, x2=4.e-6, y1=-4.e-6, y2=4.e-6, z1=-6e-6, z2=6e-6)\n",
8995
"\n",
90-
"# PSF definition\n",
91-
"psf = pbm.NumericPSF()\n",
92-
"\n",
9396
"# Particles definition\n",
94-
"P = pbm.Particles(num_particles=2, D=D1, box=box, rs=rs)\n",
95-
"P.add(num_particles=3, D=D2)\n",
96-
"\n",
97-
"# Simulation time step (seconds)\n",
98-
"t_step = 0.5e-6\n",
97+
"P = pbm.Particles.from_specs(\n",
98+
" num_particles=(3, 1),\n",
99+
" D=(D1, D2),\n",
100+
" box=box, rs=rs)\n",
99101
"\n",
100-
"# Time duration of the simulation (seconds)\n",
101-
"t_max = 1\n",
102+
"# PSF definition\n",
103+
"psf = pbm.NumericPSF()\n",
102104
"\n",
103105
"# Particle simulation definition\n",
104106
"S = pbm.ParticlesSimulation(t_step=t_step, t_max=t_max, \n",
@@ -215,16 +217,6 @@
215217
"print('Current random state:', pbm.hash_(rs.get_state()))"
216218
]
217219
},
218-
{
219-
"cell_type": "code",
220-
"execution_count": null,
221-
"metadata": {},
222-
"outputs": [],
223-
"source": [
224-
"position = S.position[:]\n",
225-
"position.shape, position.dtype"
226-
]
227-
},
228220
{
229221
"cell_type": "markdown",
230222
"metadata": {},
@@ -252,19 +244,19 @@
252244
]
253245
},
254246
{
255-
"cell_type": "code",
256-
"execution_count": null,
247+
"cell_type": "markdown",
257248
"metadata": {},
258-
"outputs": [],
259249
"source": [
260-
"S.compact_name()"
250+
"# Load trajectories"
261251
]
262252
},
263253
{
264-
"cell_type": "markdown",
254+
"cell_type": "code",
255+
"execution_count": null,
265256
"metadata": {},
257+
"outputs": [],
266258
"source": [
267-
"# Load trajectories"
259+
"S.hash()"
268260
]
269261
},
270262
{
@@ -273,8 +265,7 @@
273265
"metadata": {},
274266
"outputs": [],
275267
"source": [
276-
"#S = pbm.ParticlesSimulation.from_datafile('9125') # Read-only by default\n",
277-
"S = pbm.ParticlesSimulation.from_datafile('4500')"
268+
"S = pbm.ParticlesSimulation.from_datafile(S.hash()[:4]) # Read-only by default"
278269
]
279270
},
280271
{
@@ -413,33 +404,6 @@
413404
"S.store.close()"
414405
]
415406
},
416-
{
417-
"cell_type": "code",
418-
"execution_count": null,
419-
"metadata": {},
420-
"outputs": [],
421-
"source": [
422-
"S.ts_store.close()"
423-
]
424-
},
425-
{
426-
"cell_type": "code",
427-
"execution_count": null,
428-
"metadata": {},
429-
"outputs": [],
430-
"source": [
431-
"S.compact_name()"
432-
]
433-
},
434-
{
435-
"cell_type": "code",
436-
"execution_count": null,
437-
"metadata": {},
438-
"outputs": [],
439-
"source": [
440-
"S.position"
441-
]
442-
},
443407
{
444408
"cell_type": "markdown",
445409
"metadata": {},
@@ -510,7 +474,7 @@
510474
"source": [
511475
"ts_params2 = dict(\n",
512476
" max_rates=(250e3, 180e3), \n",
513-
" populations=(slice(0,2), slice(2, 2+3)),\n",
477+
" populations=(slice(0,3), slice(3, 3+1)),\n",
514478
" bg_rate=1.2e3\n",
515479
")\n",
516480
"\n",
@@ -658,7 +622,7 @@
658622
"width": "212px"
659623
},
660624
"toc_section_display": "block",
661-
"toc_window_display": true
625+
"toc_window_display": false
662626
}
663627
},
664628
"nbformat": 4,

0 commit comments

Comments
 (0)