Skip to content

Commit 534ae7e

Browse files
committed
New magic method for Cursor class
1 parent 38927a3 commit 534ae7e

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

qstack/io/metatensor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ def _matrix_to_tensormap(mol, dm):
249249
msize1 = 2*l1+1
250250
nsize1 = llists[q1].count(l1)
251251
iq2 = dict.fromkeys(elements, 0)
252-
i1.add(nsize1*msize1)
252+
i1 += nsize1*msize1
253253
i2 = Cursor(action='slicer')
254254
for iat2, q2 in enumerate(atom_charges):
255255
for l2 in set(llists[q2]):
@@ -268,7 +268,7 @@ def _matrix_to_tensormap(mol, dm):
268268
for iat1, q1 in enumerate(atom_charges):
269269
il1 = dict.fromkeys(range(max(llists[q1]) + 1), 0)
270270
for l1 in llists[q1]:
271-
i1.add(2*l1+1)
271+
i1 += 2*l1+1
272272
iq2 = dict.fromkeys(elements, 0)
273273
i2 = Cursor(action='slicer')
274274
for iat2, q2 in enumerate(atom_charges):

qstack/tools.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,10 @@ def _add(self, di):
186186
self.i_prev = self.i
187187
self.i += self.inc(di)
188188

189+
def __iadd__(self, di):
190+
self.add(di)
191+
return self
192+
189193
def __call__(self, di=None):
190194
"""Optionally advance the cursor and return the current range or slice.
191195

0 commit comments

Comments
 (0)