File tree Expand file tree Collapse file tree
Data_science/DataMining/UMAP/Components Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -84,11 +84,16 @@ Module Utils
8484 ''' </summary>
8585 Public Function RejectionSample(nSamples As Integer , poolSize As Integer , random As IProvideRandomValues) As Integer ()
8686 Dim result = New Integer (nSamples - 1 ) {}
87+ Dim maxItrs As Integer = 1000
8788
88- For i = 0 To nSamples - 1
89+ For i As Integer = 0 To nSamples - 1
8990 Dim rejectSample = True
91+ Dim counter As Integer = 0
9092
91- While rejectSample
93+ ' 20250610 possible dead loop at here
94+ ' if always broken
95+ ' use a counter for avoid such possible error
96+ While rejectSample AndAlso counter < maxItrs
9297 Dim j = random.Next( 0 , poolSize)
9398 Dim broken = False
9499
@@ -103,8 +108,13 @@ Module Utils
103108 rejectSample = False
104109 End If
105110
111+ counter += 1
106112 result(i) = j
107113 End While
114+
115+ If counter >= maxItrs Then
116+ Call $"dead loop was detected while make sample rejection for sample {i}!" .Warning
117+ End If
108118 Next
109119
110120 Return result
You can’t perform that action at this time.
0 commit comments