multi-vector-simulator icon indicating copy to clipboard operation
multi-vector-simulator copied to clipboard

[Bug] `mvs_tool -png` fails if no upfront investment necessary

Open smartie2076 opened this issue 4 years ago • 2 comments

I have a simulation where I do note require any upfront investments (ie. a status quo simulation). I tried running my scenario with

python mvs_tool.py -ext csv -f -pdf -png -i inputs -o outputs

I guess because there are no upfront investments, it is not possible to store a png of those and the simulation terminates:

Upfront Investment Costs ( nan Euro : BYLP Saini Enclave, BYPL Global Optimimum
Traceback (most recent call last):
  File "mvs_tool.py", line 4, in <module>
    main()
  File "d:\pycharmprojects\mvs_eland\src\multi_vector_simulator\cli.py", line 186, in main
    path_png_figs=user_input.get("path_png_figs", None),
  File "d:\pycharmprojects\mvs_eland\src\multi_vector_simulator\F0_output.py", line 139, in evaluate_dict
    F1_plots.plot_piecharts_of_costs(dict_values, file_path=path_png_figs)
  File "d:\pycharmprojects\mvs_eland\src\multi_vector_simulator\F1_plotting.py", line 1173, in plot_piecharts_of_costs
    + project_title
ValueError: cannot convert float NaN to integer

It seems that total_for_title = df_temp2.at["Total", kp_indic] is parsed as ( nan.

2021-10-08 10_49_55-mvs_eland  D__PycharmProjects_mvs_eland  -  _src_multi_vector_simulator_F1_plo

Checklist to make sure that the bug report ist complete:

  • [x] OS: Win10
  • [x] Branch: dev, updated on 2021-10-07
  • [x] If applicable: Attach full error message
  • [x] If applicable: Share screenshots/images of your problem :x: If applicable: Share used input data data confidential, can be provided internally for review. I think all status quo scenarios without upfront investments would work

smartie2076 avatar Oct 08 '21 08:10 smartie2076

I think I misinterpreted something: the issue also takes place if I deactivate -png and only use pdf. Other simulations run though, though, so it must be something specific about the inputs. New error message:

Also, if you're using any of the table format helpers (e.g. Group), replace
`from dash_table.Format import Group` with
`from dash.dash_table.Format import Group`
 import dash_table
d:\pycharmprojects\mvs_eland\src\multi_vector_simulator\F2_autoreport.py:886: ResourceWarning: unclosed file <_io.TextIOWrapper name='D:\\PycharmProjects\\mvs_eland\\2021-10-01-
BYPL-Saini-Enclave_fix_electricity_import\\01_status_quo_outputs\\report\\assets\\proj_map.html' mode='r' encoding='cp1252'>
 leaflet_map_path, "r",
ResourceWarning: Enable tracemalloc to get the object allocation traceback
Annuity Costs ( 598735.15399 Euro : BYLP Saini Enclave, BYPL Global Optimimum
Upfront Investment Costs ( nan Euro : BYLP Saini Enclave, BYPL Global Optimimum
Traceback (most recent call last):
 File "mvs_tool.py", line 4, in <module>
   main()
 File "d:\pycharmprojects\mvs_eland\src\multi_vector_simulator\cli.py", line 186, in main
   path_png_figs=user_input.get("path_png_figs", None),
 File "d:\pycharmprojects\mvs_eland\src\multi_vector_simulator\F0_output.py", line 143, in evaluate_dict
   app = autoreport.create_app(dict_values)
 File "d:\pycharmprojects\mvs_eland\src\multi_vector_simulator\F2_autoreport.py", line 1001, in create_app
   dict_values=results_json, only_print=False,
 File "d:\pycharmprojects\mvs_eland\src\multi_vector_simulator\F2_autoreport.py", line 524, in ready_costs_pie_plots
   figs = plot_piecharts_of_costs(dict_values)
 File "d:\pycharmprojects\mvs_eland\src\multi_vector_simulator\F1_plotting.py", line 1173, in plot_piecharts_of_costs
   + project_title
ValueError: cannot convert float NaN to integer

smartie2076 avatar Oct 08 '21 08:10 smartie2076

Somehow, total_for_title = df_temp2.at["Total", kp_indic] seems to be parsed as something with character ( and then the number that we actually care about.

smartie2076 avatar Oct 08 '21 08:10 smartie2076