Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 315b8a2

Browse files
committedNov 15, 2021
fix None comparison
1 parent 011a5c3 commit 315b8a2

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed
 

‎cluster.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def local_density(max_id, distances, dc, guass=True, cutoff=False):
7777
Returns:
7878
local density vector that index is the point index that start from 1
7979
"""
80-
assert guass and cutoff == False and guass or cutoff == True
80+
assert guass and cutoff is False and guass or cutoff is True
8181
logger.info("PROGRESS: compute local density")
8282
guass_func = lambda dij, dc: math.exp(- (dij / dc) ** 2)
8383
cutoff_func = lambda dij, dc: 1 if dij < dc else 0
@@ -137,9 +137,9 @@ def local_density(self, distances, max_dis, min_dis, max_id, dc=None, auto_selec
137137
Returns:
138138
local density vector, dc
139139
"""
140-
assert not (dc != None and auto_select_dc)
140+
assert not (dc is not None and auto_select_dc)
141141

142-
if dc == None:
142+
if dc is None:
143143
dc = select_dc(max_id, max_dis, min_dis, distances, auto=auto_select_dc)
144144
rho = local_density(max_id, distances, dc)
145145
return rho, dc
@@ -163,7 +163,7 @@ def cluster(self, distances, max_dis, min_dis, max_id, density_threshold, distan
163163
Returns:
164164
local density vector, min_distance vector, nearest neighbor vector
165165
"""
166-
assert not (dc != None and auto_select_dc)
166+
assert not (dc is not None and auto_select_dc)
167167
rho, dc = self.local_density(distances, max_dis, min_dis, max_id, dc=dc, auto_select_dc=auto_select_dc)
168168
delta, nneigh = min_distance(max_id, max_dis, distances, rho)
169169
logger.info("PROGRESS: start cluster")

0 commit comments

Comments
 (0)
Failed to load comments.