Skip to content

Commit 53f7346

Browse files
committed
minor fixes
1 parent 585fc4c commit 53f7346

File tree

1 file changed

+35
-42
lines changed

1 file changed

+35
-42
lines changed

docs/Tutorial_DAMP.ipynb

Lines changed: 35 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
},
4444
{
4545
"cell_type": "code",
46-
"execution_count": 2,
46+
"execution_count": 1,
4747
"id": "c9564cff",
4848
"metadata": {},
4949
"outputs": [],
@@ -69,7 +69,7 @@
6969
},
7070
{
7171
"cell_type": "code",
72-
"execution_count": 3,
72+
"execution_count": 18,
7373
"id": "409dad09",
7474
"metadata": {},
7575
"outputs": [],
@@ -128,14 +128,14 @@
128128
},
129129
{
130130
"cell_type": "code",
131-
"execution_count": 4,
131+
"execution_count": 3,
132132
"id": "c21c4587",
133133
"metadata": {},
134134
"outputs": [],
135135
"source": [
136136
"def next_pow2(val):\n",
137137
" \"\"\"\n",
138-
" Compute the smallest \"power of two\" number that is greater than/ equal to `v`\n",
138+
" Compute the smallest \"power of two\" number that is greater than/ equal to `val`\n",
139139
" \n",
140140
" Parameters\n",
141141
" ----------\n",
@@ -152,7 +152,7 @@
152152
},
153153
{
154154
"cell_type": "code",
155-
"execution_count": 5,
155+
"execution_count": 19,
156156
"id": "dd1f7b3d",
157157
"metadata": {},
158158
"outputs": [],
@@ -214,15 +214,15 @@
214214
" out.append([max(chunk_start, start), chunk_stop])\n",
215215
" chunk_stop = chunk_start + m - 1\n",
216216
" \n",
217-
" if chunk_start <= 0:\n",
217+
" if chunk_start <= start:\n",
218218
" break\n",
219219
" \n",
220220
" return np.array(out)"
221221
]
222222
},
223223
{
224224
"cell_type": "code",
225-
"execution_count": 6,
225+
"execution_count": 20,
226226
"id": "5e45d72c",
227227
"metadata": {},
228228
"outputs": [
@@ -235,7 +235,7 @@
235235
" [ 0, 56]])"
236236
]
237237
},
238-
"execution_count": 6,
238+
"execution_count": 20,
239239
"metadata": {},
240240
"output_type": "execute_result"
241241
}
@@ -256,7 +256,7 @@
256256
},
257257
{
258258
"cell_type": "code",
259-
"execution_count": 7,
259+
"execution_count": 6,
260260
"id": "79663447",
261261
"metadata": {},
262262
"outputs": [],
@@ -269,8 +269,8 @@
269269
" M_T, \n",
270270
" Σ_T, \n",
271271
" T_subseq_isconstant, \n",
272+
" chunks_range,\n",
272273
" bsf,\n",
273-
" chunks_range=None,\n",
274274
"):\n",
275275
" \"\"\"\n",
276276
" Compute the (approximate) distance between the subsequence `T[query_idx:query_idx+m]`\n",
@@ -300,13 +300,13 @@
300300
" A numpy boolean array whose i-th element indicates whether the subsequence\n",
301301
" `T[i : i+m]` is constant (True)\n",
302302
" \n",
303-
" bsf : float\n",
304-
" The best-so-far discord distance\n",
305-
" \n",
306-
" chunks_range : numpy.ndarray, default None\n",
303+
" chunks_range : numpy.ndarray\n",
307304
" A 2D numpy array consisting of rows, each represents\n",
308305
" the (start, stop) range of a chunk\n",
309306
" \n",
307+
" bsf : float\n",
308+
" The best-so-far discord distance\n",
309+
" \n",
310310
" Returns\n",
311311
" -------\n",
312312
" nn_distance : float\n",
@@ -316,11 +316,6 @@
316316
" bsf : float\n",
317317
" The best-so-far discord distance \n",
318318
" \"\"\"\n",
319-
" if chunks_range is None:\n",
320-
" # The avoid the trivial (left) neighbors of `T[query_idx : query_idx+m]`,\n",
321-
" # the stop index of non-trivial subsequences is `query_idx - excl_zone + m`\n",
322-
" chunks_range = naive_get_range_damp(query_idx - excl_zone + m, m, start=0)\n",
323-
" \n",
324319
" nn_distance = np.inf\n",
325320
" for (start, stop) in chunks_range:\n",
326321
" QT = core.sliding_dot_product(\n",
@@ -350,7 +345,7 @@
350345
},
351346
{
352347
"cell_type": "code",
353-
"execution_count": 8,
348+
"execution_count": 21,
354349
"id": "c76317b5",
355350
"metadata": {},
356351
"outputs": [],
@@ -429,7 +424,7 @@
429424
},
430425
{
431426
"cell_type": "code",
432-
"execution_count": 9,
427+
"execution_count": 32,
433428
"id": "769bddad",
434429
"metadata": {},
435430
"outputs": [],
@@ -470,7 +465,6 @@
470465
" \n",
471466
" excl_zone = int(math.ceil(m / stumpy.core.config.STUMPY_EXCL_ZONE_DENOM))\n",
472467
" chunks_range = get_damp_range(split_idx - excl_zone + m, m, start=0)\n",
473-
" \n",
474468
" last_chunk_size = chunks_range[-1, 1] - chunks_range[-1, 0]\n",
475469
" last_chunk_size_cutoff = next_pow2(last_chunk_size)\n",
476470
" \n",
@@ -487,14 +481,13 @@
487481
" excl_zone, \n",
488482
" M_T, \n",
489483
" Σ_T, \n",
490-
" T_subseq_isconstant, \n",
491-
" bsf, \n",
492-
" chunks_range=chunks_range\n",
484+
" T_subseq_isconstant, \n",
485+
" chunks_range,\n",
486+
" bsf,\n",
493487
" )\n",
494488
" _foreward_process(T, m, excl_zone, M_T, Σ_T, T_subseq_isconstant, i, lookahead, PL)\n",
495489
" \n",
496-
" chunks_range = chunks_range + 1 \n",
497-
" # make a decision on whether to create new chunk or not for the subsequence [0, m]\n",
490+
" chunks_range[:] = chunks_range + 1 \n",
498491
" if last_chunk_size < last_chunk_size_cutoff:\n",
499492
" chunks_range[-1, 0] = 0 \n",
500493
" last_chunk_size += 1\n",
@@ -521,7 +514,7 @@
521514
},
522515
{
523516
"cell_type": "code",
524-
"execution_count": 10,
517+
"execution_count": 23,
525518
"id": "2cfbc771",
526519
"metadata": {},
527520
"outputs": [],
@@ -536,7 +529,7 @@
536529
},
537530
{
538531
"cell_type": "code",
539-
"execution_count": 11,
532+
"execution_count": 24,
540533
"id": "a935f31f",
541534
"metadata": {},
542535
"outputs": [
@@ -546,7 +539,7 @@
546539
"text": [
547540
"discord_dist: 8.500883427933504\n",
548541
"discord_index: 209\n",
549-
"running time [sec]: 5.248243093490601\n"
542+
"running time [sec]: 4.881464958190918\n"
550543
]
551544
}
552545
],
@@ -566,7 +559,7 @@
566559
},
567560
{
568561
"cell_type": "code",
569-
"execution_count": 12,
562+
"execution_count": 25,
570563
"id": "2b461592",
571564
"metadata": {},
572565
"outputs": [
@@ -576,7 +569,7 @@
576569
"text": [
577570
"discord_dist: 8.500883427933504\n",
578571
"discord_index: 209\n",
579-
"running time [sec]: 2.2584328651428223\n"
572+
"running time [sec]: 2.2210960388183594\n"
580573
]
581574
}
582575
],
@@ -605,7 +598,7 @@
605598
},
606599
{
607600
"cell_type": "code",
608-
"execution_count": 13,
601+
"execution_count": 26,
609602
"id": "d8e9fa63",
610603
"metadata": {},
611604
"outputs": [],
@@ -620,7 +613,7 @@
620613
},
621614
{
622615
"cell_type": "code",
623-
"execution_count": 14,
616+
"execution_count": 27,
624617
"id": "263bca9c",
625618
"metadata": {},
626619
"outputs": [
@@ -630,7 +623,7 @@
630623
"text": [
631624
"discord_dist: 7.606279752022369\n",
632625
"discord_index: 8109\n",
633-
"running time [sec]: 5.100044012069702\n"
626+
"running time [sec]: 4.996989965438843\n"
634627
]
635628
}
636629
],
@@ -651,7 +644,7 @@
651644
},
652645
{
653646
"cell_type": "code",
654-
"execution_count": 15,
647+
"execution_count": 28,
655648
"id": "78d09bda",
656649
"metadata": {},
657650
"outputs": [
@@ -661,7 +654,7 @@
661654
"text": [
662655
"discord_dist: 7.606279752022363\n",
663656
"discord_index: 8109\n",
664-
"running time [sec]: 6.70897912979126\n"
657+
"running time [sec]: 6.67956805229187\n"
665658
]
666659
}
667660
],
@@ -690,7 +683,7 @@
690683
},
691684
{
692685
"cell_type": "code",
693-
"execution_count": 16,
686+
"execution_count": 33,
694687
"id": "6d64f488",
695688
"metadata": {},
696689
"outputs": [],
@@ -705,7 +698,7 @@
705698
},
706699
{
707700
"cell_type": "code",
708-
"execution_count": 17,
701+
"execution_count": 34,
709702
"id": "159e03dc",
710703
"metadata": {},
711704
"outputs": [
@@ -715,7 +708,7 @@
715708
"text": [
716709
"discord_dist: 29.42331306408431\n",
717710
"discord_index: 6110\n",
718-
"running time [sec]: 5.572257995605469\n"
711+
"running time [sec]: 5.483174085617065\n"
719712
]
720713
}
721714
],
@@ -736,7 +729,7 @@
736729
},
737730
{
738731
"cell_type": "code",
739-
"execution_count": 18,
732+
"execution_count": 35,
740733
"id": "9ef28e10",
741734
"metadata": {},
742735
"outputs": [
@@ -746,7 +739,7 @@
746739
"text": [
747740
"discord_dist: 29.423313064084333\n",
748741
"discord_index: 6110\n",
749-
"running time [sec]: 55.545814990997314\n"
742+
"running time [sec]: 55.60335397720337\n"
750743
]
751744
}
752745
],

0 commit comments

Comments
 (0)