idaholab / TEAL

TEAL is a financial performance calculator plugin for the RAVEN code, framework, resolving around the computation of Net Present Value and associated financial metrics.
Apache License 2.0
9 stars 21 forks source link

[DEFECT] Indexing error in stacked CashFlow bar plot #83

Closed GabrielSoto-INL closed 5 months ago

GabrielSoto-INL commented 5 months ago

Defect Description

Describe the defect

What did you expect to see happen?

I noticed an indexing error in the CashFlowPlot, specifically "Plot 1: Inflows, outflows and Net Cash Flow". In the stacked plot for the negative cash flows, the code is:

    for i, _ in enumerate(cumCashFlow[0:negVar]):
      if i == 0:
        ax1.bar(dfYear['cfYears'], dfCashFlow.iloc[:,i], widthFlowbar, color = compColor[i],
          label = labels.iloc[i,0], edgecolor='white')
      else:
        ax1.bar(dfYear['cfYears'], dfCashFlow.iloc[:,i], widthFlowbar, color = compColor[i],
          bottom = dfCashFlow.iloc[:,0:i-1].sum(axis=1), label = labels.iloc[i,0], edgecolor='white')

If i=1 in the else portion, the bottom argument indexes the cash flow dataframe from 0:0 which does not take into account the i=0 cash flow. This results in a missing portion in the stacked bar plot.

What did you see instead?

image

Do you have a suggested fix for the development team?

The argument for bottom should be changed to bottom = dfCashFlow.iloc[:,0:i].sum(axis=1)

Describe how to Reproduce Steps to reproduce the behavior:

Screenshots and Input Files Please attach the input file(s) that generate this error. The simpler the input, the faster we can find the issue.

Platform (please complete the following information):


For Change Control Board: Issue Review

This review should occur before any development is performed as a response to this issue.


For Change Control Board: Issue Closure

This review should occur when the issue is imminently going to be closed.

PaulTalbot-INL commented 5 months ago

Approved to close via #84.