Skip to content

Commit 165dca3

Browse files
committed
change reshape to vstack of padded arrays
when creating np.array from ragged list (list of arrays of differnt lengths) for calc.projections, a visibledeprecationwarning was being issued. stacking padded arrays solves **WARNING** : is this correct from the physical point of view ? in case the atoms are given different functions, I think the Bs of equal indexes are being misaligned.
1 parent f2bf2ca commit 165dca3

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/pyace/asecalc.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,11 @@ def calculate(self, atoms=None, properties=['energy', 'forces', 'stress', 'energ
147147

148148
self.energy, self.forces = np.array(self.ace.energy), np.array(self.ace.forces)
149149
nat = len(atoms)
150-
self.projections = np.reshape(self.ace.projections, (nat, -1))
150+
ragged_projections = self.ace.projections
151+
maxlen = max([len(this_proj) for this_proj in ragged_projections])
152+
padded_projections = [np.pad(this_proj, (0, maxlen-len(this_proj))) for this_proj in ragged_projections ]
153+
self.projections = np.vstack(padded_projections)
154+
# self.projections = np.reshape(self.ace.projections, (nat, -1))
151155

152156
self.energies = np.array(self.ace.energies)
153157

0 commit comments

Comments
 (0)