Skip to content

Commit c09b083

Browse files
authored
Merge pull request #269 from herbertludowieg/output-parsing
Increase output parsing
2 parents 39a8ce6 + d2b102d commit c09b083

12 files changed

Lines changed: 16299 additions & 211 deletions

File tree

cicd-matrix.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
versions = [
1313
"3.7",
1414
"3.8",
15+
"3.9",
16+
"3.10",
1517
]
1618

1719
print(

exatomic/core/gradient.py

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from exatomic.exa import DataFrame
66
import numpy as np
7-
#import pandas as pd
7+
import pandas as pd
88

99
class Gradient(DataFrame):
1010
"""
@@ -14,3 +14,40 @@ class Gradient(DataFrame):
1414
_index = 'gradient'
1515
_columns = ['Z', 'atom', 'fx', 'fy', 'fz', 'symbol', 'frame']
1616
_categories = {'frame': np.int64, 'atom': np.int64, 'symbol': str}
17+
18+
@property
19+
def stats(self):
20+
cols = ['fx', 'fy', 'fz']
21+
srs = []
22+
for _, data in self.groupby('frame'):
23+
norms = np.linalg.norm(data[cols].values, axis=1)
24+
rms = np.sqrt(np.mean(np.square(norms)))
25+
avg = np.mean(norms)
26+
max = norms.max()
27+
min = norms.min()
28+
sr = pd.Series([rms, avg, max, min], index=['rms', 'mean',
29+
'max', 'min'])
30+
srs.append(sr)
31+
df = pd.concat(srs, axis=1, ignore_index=True).T
32+
return df
33+
34+
@property
35+
def rms_grad(self):
36+
cols = ['fx', 'fy', 'fz']
37+
arr = []
38+
for _, data in self.groupby('frame'):
39+
val = np.sqrt(np.mean(np.square(data[cols].values)))
40+
arr.append(val)
41+
rms = pd.Series(arr)
42+
return rms
43+
44+
@property
45+
def avg_grad(self):
46+
cols = ['fx', 'fy', 'fz']
47+
arr = []
48+
for _, data in self.groupby('frame'):
49+
val = np.mean(data[cols].values)
50+
arr.append(val)
51+
avg = pd.Series(arr)
52+
return avg
53+

exatomic/exa/core/editor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ def pandas_dataframe(self, start, stop, ncol, **kwargs):
297297
Returns:
298298
pd.DataFrame: structured data
299299
"""
300-
if isinstance(ncol, (int, np.int, np.int64, np.int32)):
300+
if isinstance(ncol, (int, np.int64, np.int32)):
301301
return pd.read_csv(io.StringIO('\n'.join(self[start:stop])), delim_whitespace=True, names=range(ncol), **kwargs)
302302
else:
303303
return pd.read_csv(io.StringIO('\n'.join(self[start:stop])), delim_whitespace=True, names=ncol, **kwargs)

0 commit comments

Comments
 (0)