Skip to content

Commit

Permalink
fixed sphereSDDR output
Browse files Browse the repository at this point in the history
  • Loading branch information
dodu94 committed Feb 21, 2024
1 parent af1a8bd commit 6925765
Show file tree
Hide file tree
Showing 14 changed files with 51 additions and 19 deletions.
10 changes: 7 additions & 3 deletions jade/sphereoutput.py
Original file line number Diff line number Diff line change
Expand Up @@ -1564,7 +1564,7 @@ def _generate_plots(self, libraries, allzaids, outputs, globalname, outpath):
title = "Gamma Leakage flux after a {} cooldown".format(time)
data = []
for lib in libraries:

try: # Zaid could not be common to the libraries
outp = self.outputs["d1s"][zaidnum, mt, lib]
except KeyError:
Expand Down Expand Up @@ -1755,7 +1755,9 @@ def _extract_data4plots(self, zaid, mt, lib, time):
# Memorize values
return nflux, pflux, sddr

def _compute_single_results(self):
def _compute_single_results(
self,
) -> tuple[dict[str, dict], pd.DataFrame, pd.DataFrame, pd.DataFrame]:
"""
Compute the excel single post processing results and memorize them
Expand All @@ -1764,6 +1766,8 @@ def _compute_single_results(self):
Returns
-------
outputs: dict[str, dict]
dictionary of the outputs. the first level is the code level
results : pd.DataFrame
global excel datataframe of all values.
errors : pd.DataFrame
Expand Down Expand Up @@ -1845,7 +1849,7 @@ def _compute_compare_result(self, reflib, tarlib):
error_dfs.append(error_df)
lib_dics.append(outputs)
for dic in lib_dics:
code_outputs.update(dic)
code_outputs.update(dic)
print(code_outputs)
self.outputs["d1s"] = code_outputs
# Consider only common zaids
Expand Down
60 changes: 44 additions & 16 deletions tests/sphereoutput_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,35 +34,63 @@


# Files
OUTP_SDDR = os.path.join(cp, 'TestFiles', 'sphereoutput',
'SphereSDDR_11023_Na-23_102_o')
OUTM_SDDR = os.path.join(cp, 'TestFiles', 'sphereoutput',
'SphereSDDR_11023_Na-23_102_m')
OUTP_SDDR = os.path.join(
cp, "TestFiles", "sphereoutput", "SphereSDDR_11023_Na-23_102_o"
)
OUTM_SDDR = os.path.join(
cp, "TestFiles", "sphereoutput", "SphereSDDR_11023_Na-23_102_m"
)


class MockSphereSDDRoutput(sout.SphereSDDRoutput):
def __init__(self):
self.lib = '99c'
self.testname = 'SphereSDDR'
self.test_path = os.path.join(cp, 'TestFiles', 'sphereoutput',
'single_excel_sddr')
mat_settings = [{'num': 'M203', 'Name': 'material', 'other': 1},
{'num': 'dummy', 'Name': 'dummy', 'dummy': 1}]
self.mat_settings = pd.DataFrame(mat_settings).set_index('num')
self.lib = "99c"
self.testname = "SphereSDDR"
self.test_path = os.path.join(
cp, "TestFiles", "sphereoutput", "single_excel_sddr"
)
mat_settings = [
{"num": "M203", "Name": "material", "other": 1},
{"num": "dummy", "Name": "dummy", "dummy": 1},
]
self.mat_settings = pd.DataFrame(mat_settings).set_index("num")
self.raw_data = {}
self.outputs = {}
self.d1s = True


class TestSphereSDDRoutput:
mockoutput = MockSphereSDDRoutput()

def test_compute_single_results(self):

cols = ['Parent', 'Parent Name', 'MT', 'F1.0', 'F2.0', 'F3.0', 'F4.0',
'F5.0', 'F6.0', 'D1.0', 'D2.0', 'D3.0', 'D4.0', 'D5.0',
'D6.0', 'H1.0', 'H2.0', 'H3.0', 'H4.0', 'H5.0', 'H6.0']

results, errors, stat_checks = self.mockoutput._compute_single_results()
cols = [
"Parent",
"Parent Name",
"MT",
"F1.0",
"F2.0",
"F3.0",
"F4.0",
"F5.0",
"F6.0",
"D1.0",
"D2.0",
"D3.0",
"D4.0",
"D5.0",
"D6.0",
"H1.0",
"H2.0",
"H3.0",
"H4.0",
"H5.0",
"H6.0",
]

outputs, results, errors, stat_checks = (
self.mockoutput._compute_single_results()
)
for df in [results, errors, stat_checks]:
assert len(df) == 2

Expand Down

0 comments on commit 6925765

Please sign in to comment.