Skip to content
This repository was archived by the owner on Mar 22, 2024. It is now read-only.

add conditions to cluster section of load_one_graph #5

Merged
merged 1 commit into from
Sep 30, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions graphprot/DataSet.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,22 @@ def load_one_graph(self, fname, mol):
data.internal_edge_attr = internal_edge_attr

# cluster
if 'clustering' in grp:
if self.clustering_method in grp['clustering']:
data.cluster0 = torch.tensor(
grp['clustering/' + self.clustering_method + '/depth_0'][()], dtype=torch.long)
data.cluster1 = torch.tensor(
grp['clustering/' + self.clustering_method + '/depth_1'][()], dtype=torch.long)
if 'clustering' in grp.keys():
if self.clustering_method in grp['clustering'].keys() :
if ( 'depth_0' in grp['clustering/{}'.format(self.clustering_method)].keys() and
'depth_1' in grp['clustering/{}'.format(self.clustering_method)].keys()
):
data.cluster0 = torch.tensor(
grp['clustering/' + self.clustering_method + '/depth_0'][()], dtype=torch.long)
data.cluster1 = torch.tensor(
grp['clustering/' + self.clustering_method + '/depth_1'][()], dtype=torch.long)
else :
print ('WARNING: no cluster detected')
else :
print ('WARNING: no cluster detected')
else :
print ('WARNING: no cluster detected')


f5.close()
return data
Expand Down