From 6d3def9d963b4b481213dbe81a3ed44975e48f29 Mon Sep 17 00:00:00 2001 From: abachma2 Date: Mon, 25 Jan 2021 10:14:34 -0600 Subject: [PATCH 1/4] fixed memory error for Materials metric --- cymetric/metrics.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/cymetric/metrics.py b/cymetric/metrics.py index 3cf56d5..670ab58 100644 --- a/cymetric/metrics.py +++ b/cymetric/metrics.py @@ -115,13 +115,11 @@ def materials(rsrcs, comps): Resources times the massfrac in Compositions) indexed by the SimId, QualId, ResourceId, ObjId, TimeCreated, and NucId. """ + rsrcs = rsrcs[['SimId','ResourceId','ObjId','TimeCreated','Quantity','Units',\ + 'QualId']] x = pd.merge(rsrcs, comps, on=['SimId', 'QualId'], how='inner') - x = x.set_index(['SimId', 'QualId', 'ResourceId', 'ObjId', 'TimeCreated', - 'NucId', 'Units']) - y = x['Quantity'] * x['MassFrac'] - y.name = 'Mass' - z = y.reset_index() - return z + x['Mass'] = x['Quantity'] * x['MassFrac'] + return x del _matdeps, _matschema From e041c688e8488fcbfd4af166fc43cbb1260ce385 Mon Sep 17 00:00:00 2001 From: abachma2 Date: Mon, 25 Jan 2021 10:15:57 -0600 Subject: [PATCH 2/4] pep8 fixes --- cymetric/metrics.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cymetric/metrics.py b/cymetric/metrics.py index 670ab58..613d33f 100644 --- a/cymetric/metrics.py +++ b/cymetric/metrics.py @@ -115,8 +115,8 @@ def materials(rsrcs, comps): Resources times the massfrac in Compositions) indexed by the SimId, QualId, ResourceId, ObjId, TimeCreated, and NucId. """ - rsrcs = rsrcs[['SimId','ResourceId','ObjId','TimeCreated','Quantity','Units',\ - 'QualId']] + rsrcs = rsrcs[['SimId', 'ResourceId', 'ObjId', 'TimeCreated', 'Quantity', + 'Units', 'QualId']] x = pd.merge(rsrcs, comps, on=['SimId', 'QualId'], how='inner') x['Mass'] = x['Quantity'] * x['MassFrac'] return x From e5264fa8b9ff06f6ee020d1fb2444c93431c7741 Mon Sep 17 00:00:00 2001 From: abachma2 Date: Tue, 26 Jan 2021 10:50:39 -0600 Subject: [PATCH 3/4] reordered columns --- cymetric/metrics.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cymetric/metrics.py b/cymetric/metrics.py index 613d33f..099339b 100644 --- a/cymetric/metrics.py +++ b/cymetric/metrics.py @@ -115,10 +115,13 @@ def materials(rsrcs, comps): Resources times the massfrac in Compositions) indexed by the SimId, QualId, ResourceId, ObjId, TimeCreated, and NucId. """ - rsrcs = rsrcs[['SimId', 'ResourceId', 'ObjId', 'TimeCreated', 'Quantity', - 'Units', 'QualId']] + rsrcs = rsrcs[['SimId', 'QualId','ResourceId', 'ObjId', 'TimeCreated', 'Quantity', + 'Units']] x = pd.merge(rsrcs, comps, on=['SimId', 'QualId'], how='inner') x['Mass'] = x['Quantity'] * x['MassFrac'] + x = x.drop(['Quantity', 'MassFrac'], axis=1) + x = x.reindex(columns=['SimId', 'QualId','ResourceId', 'ObjId', 'TimeCreated', 'NucId', + 'Units', 'Mass']) return x From 1d0d84612bee0ce57a432b4942f4f6149784692f Mon Sep 17 00:00:00 2001 From: abachma2 Date: Tue, 26 Jan 2021 10:55:41 -0600 Subject: [PATCH 4/4] pep8 fixes --- cymetric/metrics.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cymetric/metrics.py b/cymetric/metrics.py index 099339b..c798668 100644 --- a/cymetric/metrics.py +++ b/cymetric/metrics.py @@ -115,13 +115,13 @@ def materials(rsrcs, comps): Resources times the massfrac in Compositions) indexed by the SimId, QualId, ResourceId, ObjId, TimeCreated, and NucId. """ - rsrcs = rsrcs[['SimId', 'QualId','ResourceId', 'ObjId', 'TimeCreated', 'Quantity', - 'Units']] + rsrcs = rsrcs[['SimId', 'QualId','ResourceId', 'ObjId', 'TimeCreated', + 'Quantity', 'Units']] x = pd.merge(rsrcs, comps, on=['SimId', 'QualId'], how='inner') x['Mass'] = x['Quantity'] * x['MassFrac'] x = x.drop(['Quantity', 'MassFrac'], axis=1) - x = x.reindex(columns=['SimId', 'QualId','ResourceId', 'ObjId', 'TimeCreated', 'NucId', - 'Units', 'Mass']) + x = x.reindex(columns=['SimId', 'QualId', 'ResourceId', 'ObjId', + 'TimeCreated', 'NucId', 'Units', 'Mass']) return x