rl-institut / multi-vector-simulator

Multi-vector Simulation Tool assessing and optimizing Local Energy Systems (LES) for the E-LAND project
GNU General Public License v2.0
21 stars 10 forks source link

[Bug] Bug in store_result_matrix(dict_kpi, dict_asset) #465

Closed Piranias closed 4 years ago

Piranias commented 4 years ago

See error message below

Checklist to make sure that the bug report ist complete:

Error message:

error_mvs

smartie2076 commented 4 years ago

@ursulaelmir I think this is due to the LCOE_ASSET definition. Can you fix it by either changing

If the total flow is 0 in any of the previous cases, then the LCOE_ASSET is set to None. -> set to 0

Or if you need that information for your analysis: add an exception in E0.store_result_matrix() for cases in which the value of the key is none (hint: if isinstance(value, None): {key: None}).

Bachibouzouk commented 4 years ago

The error is still there for these tests:

tests/test_F1_plotting.py FF.........
tests/test_benchmark_simple_scenarios.py .FF

Here is a log of the error (same for all 4 failures)

These tests (running the whole simulation) are only ran with EXECUTE_TESTS_ON=master pytest, they do not run on travis (except if one merges in master) because they take more time. If devs consistently forget to run this command locally (although it is in the PR checklist), I think we'll have to run all tests also on branch dev. What do you think @smartie2076 ?

tests/test_benchmark_simple_scenarios.py:110: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
mvs_eland_tool/local_deploy.py:151: in main
    evaluation.evaluate_dict(dict_values, results_main, results_meta)
src/E0_evaluation.py:144: in evaluate_dict
    store_result_matrix(dict_values[KPI], dict_values[group][asset])
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

dict_kpi = {'cost_matrix':                       label  costs_total  costs_om_total  ... annuity_total annuity_om  levelized_cost...          inverter         1000               0     35587.0       1.855608e+06      784.7     211.82738, 'scalars': {}}
dict_asset = {'age_installed': {'unit': 'year', 'value': 0}, 'annual_total_flow': {'unit': 'kWh', 'value': 0.0}, 'annuity_of_specif...fic_annual_om': {'unit': 'currency/kW/year', 'value': 0.0}, 'annuity_om': {'unit': 'currency/year', 'value': 0.0}, ...}

    def store_result_matrix(dict_kpi, dict_asset):
        """
        Storing results to vector and then result matrix for saving it in csv.
        Defined value types: Str, bool, None, dict (with key "VALUE"), else (int, float)
        Parameters
        ----------
        dict_kpi: dict
            dictionary with the two kpi groups (costs and scalars), which are pd.DF

        dict_asset: dict
            all information known for a specific asset

        Returns
        -------
        Updated dict_kpi DF, with new row of kpis of the specific asset

        """

        round_to_comma = 5

        for kpi_storage in [KPI_COST_MATRIX, KPI_SCALAR_MATRIX]:
            asset_result_dict = {}
            for key in dict_kpi[kpi_storage].columns.values:
                # Check if called value is in oemof results -> Remember: check if pandas index has certain index: pd.object.index.contains(key)
                if key in dict_asset:
                    if isinstance(dict_asset[key], str):
                        asset_result_dict.update({key: dict_asset[key]})
                    elif isinstance(dict_asset[key], bool):
                        asset_result_dict.update({key: dict_asset[key]})
                    elif dict_asset[key] is None:
                        asset_result_dict.update({key: None})
                    elif isinstance(dict_asset[key], dict):
                        if VALUE in dict_asset[key].keys():
                            asset_result_dict.update(
>                               {key: round(dict_asset[key][VALUE], round_to_comma)}
                            )
E                           TypeError: type NoneType doesn't define __round__ method

src/E0_evaluation.py:190: TypeError