Commit 961dba61 authored by Kumar, Shikhar's avatar Kumar, Shikhar
Browse files

Address @kkiesling comments

parent 58560e60
Loading
Loading
Loading
Loading
+14 −11
Original line number Diff line number Diff line
@@ -5,6 +5,8 @@ from pathlib import Path
import subprocess
import warnings

import pandas as pd

from . import checkvalue as cv
from .config import PyGriffinConfig

@@ -24,6 +26,11 @@ class PyGriffin:
        Location of Griffin input file
    n_procs : int
        Number of processes in Griffin run
    _keff : float
        Output k-effective from Griffin run
    _subassembly_power_volume : pandas.DataFrame
        Dataframe storing assembly_id, plane_id, power, and volume data
        for each unique (assembly_id, plane_id) combination
    """

    def __init__(self, input, mesh=None, n_procs=1):
@@ -242,25 +249,21 @@ class PyGriffin:
            # Subassembly power volume CSV file not found
            return 4

        with open(griffin_subassembly_output_file, 'r') as f:
            lines = f.readlines()
        if len(lines) < 2:
        # Read subassembly CSV file as pandas dataframe
        df = pd.read_csv(griffin_subassembly_output_file, header=0,
                         index_col=False)
        if df.shape[0] < 1:
            # Insufficient row entries in power volume csv file
            return 5

        header = lines[0].split('\n')[0]
        output_fields = header.split(',')
        if len(output_fields) != 4:
        if df.shape[1] != 4:
            # Incorrect number of output fields in power volume csv file
            return 5
        if 'power' not in output_fields or 'volume' not in output_fields:
        if 'power' not in df or 'volume' not in df:
            # Output power and volume fields not found in csv file
            return 6

        self._subassembly_power_volume = {}
        for result_row in lines[1:]:
            assembly_id, plane_id, power, volume = result_row.split(',')
            self._subassembly_power_volume[(int(assembly_id), int(plane_id))] = (float(power), float(volume))
        self._subassembly_power_volume = df
        return 0

    def __call__(self, cwd=None):
+7 −4
Original line number Diff line number Diff line
@@ -3,6 +3,8 @@ from pygriffin.pygriffin import PyGriffin
import pytest
from pathlib import Path

import pandas as pd

from pygriffin import PyGriffinConfig

_TEST_DIR = Path(__file__).parent.absolute()
@@ -23,10 +25,11 @@ def test_griffin_postrun_success():
    ret_code = pyg.postrun(_POSTRUN_EIGEN_SUCCESS_PATH, _POSTRUN_POWERVOL_SUCCESS_PATH)
    assert ret_code == 0
    assert pyg.keff == 0.5
    assert pyg.subassembly_power_volume == {(0, 0): (0, 1.0),
                                            (0, 1): (0, 2.0),
                                            (1, 0): (0, 1.0),
                                            (1, 1): (2.5, 2.0)}
    ref_df = pd.DataFrame({'Level-0-assembly_id': [0, 0, 1, 1],
                          'Level-1-plane_id': [0, 1, 0, 1],
                          'power': [0.0, 0.0, 0.0, 2.5],
                          'volume': [1.0, 2.0, 1.0, 2.0]})
    assert pyg.subassembly_power_volume.equals(ref_df)


def test_griffin_postrun_eigen_file_noexist():