Skip to content

Commit ac418d6

Browse files
committed
Changed list assignment to "assign_property" method
1 parent 5c78e3e commit ac418d6

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

kgcnn/data/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def _attr_to_list(attr):
9393
elif isinstance(attr, str):
9494
attr = [attr]
9595
if not isinstance(attr, list):
96-
raise TypeError("Attribute name is neither list or string.")
96+
raise TypeError("Attribute name is neither list nor string.")
9797
return attr
9898

9999
# Loop over nodes in graph.

kgcnn/data/crystal.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -159,15 +159,15 @@ def read_in_memory(self, label_column_name: str = None):
159159
node_occ.append(occ)
160160
node_oxidation.append(oxi)
161161

162-
self.node_attributes = node_occ
163-
self.node_oxidation = node_oxidation
164-
self.node_number = [np.argmax(x, axis=-1) for x in node_occ] # Only takes maximum occupation here!!!
165-
self.node_symbol = node_symbol
166-
self.node_coordinates = node_coordinates
167-
self.graph_lattice_matrix = graph_lattice_matrix
168-
self.graph_abc = graph_abc
169-
self.graph_charge = graph_charge
170-
self.graph_volume = graph_volume
162+
self.assign_property("node_attributes", node_occ)
163+
self.assign_property("node_oxidation", node_oxidation)
164+
self.assign_property("node_number", [np.argmax(x, axis=-1) for x in node_occ]) # Only takes maximum occupation here!!!
165+
self.assign_property("node_symbol", node_symbol)
166+
self.assign_property("node_coordinates", node_coordinates)
167+
self.assign_property("graph_lattice_matrix", graph_lattice_matrix)
168+
self.assign_property("graph_abc", graph_abc)
169+
self.assign_property("graph_charge", graph_charge)
170+
self.assign_property("graph_volume", graph_volume)
171171

172172
return self
173173

@@ -183,9 +183,9 @@ def _set_dataset_range_from_structures(self, structs, radius: float = 4.0, numer
183183
range_indices.append(ridx)
184184
range_image.append(rimg)
185185
range_distance.append(rd)
186-
self.range_indices = range_indices
187-
self.range_image = range_image
188-
self.range_attributes = range_distance
186+
self.assign_property("range_indices", range_indices)
187+
self.assign_property("range_image", range_image)
188+
self.assign_property("range_attributes", range_distance)
189189

190190
def set_range(self, max_distance: float = 4.0, max_neighbours=15, do_invert_distance=False,
191191
self_loops=True, exclusive=True):

kgcnn/data/tudataset.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -154,14 +154,14 @@ def read_in_memory(self):
154154
nod_id, nod_counts = np.unique(x[:, 0], return_counts=True)
155155
node_degree[i][nod_id] = nod_counts
156156

157-
self.node_degree = node_degree
158-
self.node_attributes = n_attr
159-
self.edge_attributes = e_attr
160-
self.graph_attributes = g_attr
161-
self.edge_indices = edge_indices
162-
self.node_labels = n_labels
163-
self.edge_labels = e_labels
164-
self.graph_labels = [x for x in g_labels]
157+
self.assign_property("node_degree", node_degree)
158+
self.assign_property("node_attributes", n_attr)
159+
self.assign_property("edge_attributes", e_attr)
160+
self.assign_property("graph_attributes", g_attr)
161+
self.assign_property("edge_indices", edge_indices)
162+
self.assign_property("node_labels", n_labels)
163+
self.assign_property("edge_labels", e_labels)
164+
self.assign_property("graph_labels", [x for x in g_labels])
165165

166166
return self
167167

0 commit comments

Comments
 (0)