activity-browser icon indicating copy to clipboard operation
activity-browser copied to clipboard

`TypeError: Can not infer number of levels from empty list` When doing Scenario LCA

Open marc-vdm opened this issue 3 years ago • 6 comments

Multiple users I'm helping have reported this issue.

Here's one that is using Parameters:

Adding: biosphere3
Adding: cutoff371
Traceback (most recent call last):
File "C:\Users\alexa\BERND\miniconda3\envs\ab_dev\lib\site-packages\activity_browser\layouts\tabs\LCA_results_tab.py", line 58, in generate_setup
new_tab = LCAResultsSubTab(data, self)
File "C:\Users\alexa\BERND\miniconda3\envs\ab_dev\lib\site-packages\activity_browser\layouts\tabs\LCA_results_tabs.py", line 111, in __init__
ef=ElementaryFlowContributionTab(self),
File "C:\Users\alexa\BERND\miniconda3\envs\ab_dev\lib\site-packages\activity_browser\layouts\tabs\LCA_results_tabs.py", line 881, in __init__
self.toggle_comparisons(self.switches.indexes.func)
File "C:\Users\alexa\BERND\miniconda3\envs\ab_dev\lib\site-packages\activity_browser\layouts\tabs\LCA_results_tabs.py", line 750, in toggle_comparisons
self.update_tab()
File "C:\Users\alexa\BERND\miniconda3\envs\ab_dev\lib\site-packages\activity_browser\layouts\tabs\LCA_results_tabs.py", line 820, in update_tab
self.set_combobox_changes()
File "C:\Users\alexa\BERND\miniconda3\envs\ab_dev\lib\site-packages\activity_browser\layouts\tabs\LCA_results_tabs.py", line 801, in set_combobox_changes
self.df = self.update_dataframe(**compare_fields)
File "C:\Users\alexa\BERND\miniconda3\envs\ab_dev\lib\site-packages\activity_browser\layouts\tabs\LCA_results_tabs.py", line 890, in update_dataframe
return self.parent.contributions.top_elementary_flow_contributions(
File "C:\Users\alexa\BERND\miniconda3\envs\ab_dev\lib\site-packages\activity_browser\bwutils\multilca.py", line 720, in top_elementary_flow_contributions
labelled_df = self.get_labelled_contribution_dict(
File "C:\Users\alexa\BERND\miniconda3\envs\ab_dev\lib\site-packages\activity_browser\bwutils\multilca.py", line 518, in get_labelled_contribution_dict
joined = self.join_df_with_metadata(
File "C:\Users\alexa\BERND\miniconda3\envs\ab_dev\lib\site-packages\activity_browser\bwutils\multilca.py", line 462, in join_df_with_metadata
df.index = pd.MultiIndex.from_tuples(df.index)
File "C:\Users\alexa\BERND\miniconda3\envs\ab_dev\lib\site-packages\pandas\core\indexes\multi.py", line 204, in new_meth
return meth(self_or_cls, *args, **kwargs)
File "C:\Users\alexa\BERND\miniconda3\envs\ab_dev\lib\site-packages\pandas\core\indexes\multi.py", line 553, in from_tuples
raise TypeError("Cannot infer number of levels from empty list")
TypeError: Cannot infer number of levels from empty list

And their conda list output

# packages in environment at C:\Users\alexa\BERND\miniconda3\envs\ab_dev:
#
# Name Version Build Channel
activity-browser-dev 2022.03.29 py_0 bsteubing
appdirs 1.4.4 pyh9f0ad1d_0 conda-forge
arrow 1.2.2 pyhd8ed1ab_0 conda-forge
asteval 0.9.23 pyhd8ed1ab_0 conda-forge
astunparse 1.6.3 pyhd8ed1ab_0 conda-forge
beautifulsoup4 4.10.0 pyha770c72_0 conda-forge
brightway2 2.4.2 py_4 cmutel
brotli 1.0.9 h8ffe710_7 conda-forge
brotli-bin 1.0.9 h8ffe710_7 conda-forge
brotli-python 1.0.9 py39h415ef7b_7 conda-forge
brotlicffi 1.0.9.2 py39h415ef7b_1 conda-forge
brotlipy 0.7.0 py39hb82d6ee_1004 conda-forge
bw2analyzer 0.10 py_1 cmutel
bw2calc 1.8.1 py_2 cmutel
bw2data 3.6.4 py_0 cmutel
bw2io 0.8.6 py_1 cmutel
bw2parameters 0.7 py_0 cmutel
bw_migrations 0.1 py_0 cmutel
bzip2 1.0.8 h8ffe710_4 conda-forge
ca-certificates 2021.10.8 h5b45459_0 conda-forge
certifi 2021.10.8 py39hcbf5309_2 conda-forge
cffi 1.15.0 py39h0878f49_0 conda-forge
charset-normalizer 2.0.12 pyhd8ed1ab_0 conda-forge
cryptography 36.0.2 py39h7bc7c5c_1 conda-forge
cycler 0.11.0 pyhd8ed1ab_0 conda-forge
dill 0.3.4 pyhd8ed1ab_0 conda-forge
docopt 0.6.2 py_1 conda-forge
eidl 1.4.2 py_0 bsteubing
eight 1.0.0 py_0 conda-forge
et_xmlfile 1.0.1 py_1001 conda-forge
fasteners 0.17.3 pyhd8ed1ab_0 conda-forge
fonttools 4.31.2 py39hb82d6ee_1 conda-forge
freetype 2.10.4 h546665d_1 conda-forge
future 0.18.2 py39hcbf5309_5 conda-forge
icu 69.1 h0e60522_0 conda-forge
idna 3.3 pyhd8ed1ab_0 conda-forge
importlib-metadata 4.11.3 py39hcbf5309_1 conda-forge
importlib_metadata 4.11.3 hd8ed1ab_1 conda-forge
intel-openmp 2022.0.0 h57928b3_3663 conda-forge
jbig 2.1 h8d14728_2003 conda-forge
jpeg 9e h8ffe710_0 conda-forge
kiwisolver 1.4.2 py39h2e07f2f_1 conda-forge
lcms2 2.12 h2a16943_0 conda-forge
lerc 3.0 h0e60522_0 conda-forge
libblas 3.9.0 14_win64_mkl conda-forge
libbrotlicommon 1.0.9 h8ffe710_7 conda-forge
libbrotlidec 1.0.9 h8ffe710_7 conda-forge
libbrotlienc 1.0.9 h8ffe710_7 conda-forge
libcblas 3.9.0 14_win64_mkl conda-forge
libclang 13.0.1 default_h81446c8_0 conda-forge
libdeflate 1.10 h8ffe710_0 conda-forge
libffi 3.4.2 h8ffe710_5 conda-forge
libiconv 1.16 he774522_0 conda-forge
liblapack 3.9.0 14_win64_mkl conda-forge
libpng 1.6.37 h1d00b33_2 conda-forge
libtiff 4.3.0 hc4061b1_3 conda-forge
libwebp 1.2.2 h57928b3_0 conda-forge
libwebp-base 1.2.2 h8ffe710_1 conda-forge
libxcb 1.13 hcd874cb_1004 conda-forge
libxml2 2.9.12 hf5bbc77_2 conda-forge
libxslt 1.1.33 h34f844d_4 conda-forge
libzlib 1.2.11 h8ffe710_1014 conda-forge
lxml 4.8.0 py39hb82d6ee_1 conda-forge
lz4-c 1.9.3 h8ffe710_1 conda-forge
m2w64-gcc-libgfortran 5.3.0 6 conda-forge
m2w64-gcc-libs 5.3.0 7 conda-forge
m2w64-gcc-libs-core 5.3.0 7 conda-forge
m2w64-gmp 6.1.0 2 conda-forge
m2w64-libwinpthread-git 5.0.0.4634.697f757 2 conda-forge
matplotlib-base 3.5.1 py39h581301d_0 conda-forge
mkl 2022.0.0 h0e2418a_796 conda-forge
mrio_common_metadata 0.1.1 py_0 cmutel
msys2-conda-epoch 20160418 1 conda-forge
multiprocess 0.70.12.2 py39hb82d6ee_2 conda-forge
multivolumefile 0.2.3 pyhd8ed1ab_0 conda-forge
munkres 1.1.4 pyh9f0ad1d_0 conda-forge
networkx 2.7.1 pyhd8ed1ab_1 conda-forge
numpy 1.22.3 py39h6331f09_1 conda-forge
openjpeg 2.4.0 hb211442_1 conda-forge
openpyxl 3.0.9 pyhd8ed1ab_0 conda-forge
openssl 1.1.1n h8ffe710_0 conda-forge
packaging 21.3 pyhd8ed1ab_0 conda-forge
pandas 1.4.2 py39h2e25243_0 conda-forge
pathos 0.2.8 pyhd8ed1ab_0 conda-forge
patsy 0.5.2 pyhd8ed1ab_0 conda-forge
peewee 3.14.10 py39h539719c_0 conda-forge
pillow 9.1.0 py39ha53f419_0 conda-forge
pip 22.0.4 pyhd8ed1ab_0 conda-forge
pox 0.3.0 pyhd8ed1ab_0 conda-forge
ppft 1.6.6.4 pyhd8ed1ab_0 conda-forge
psutil 5.9.0 py39hb82d6ee_1 conda-forge
pthread-stubs 0.4 hcd874cb_1001 conda-forge
py7zr 0.18.3 pyhd8ed1ab_0 conda-forge
pybcj 0.5.1 py39hb82d6ee_0 conda-forge
pybcpy 0.0.17 pyhd8ed1ab_0 conda-forge
pycparser 2.21 pyhd8ed1ab_0 conda-forge
pycryptodomex 3.14.1 py39hb82d6ee_0 conda-forge
pyopenssl 22.0.0 pyhd8ed1ab_0 conda-forge
pypardiso 0.4.0 pyhd8ed1ab_0 conda-forge
pyparsing 3.0.7 pyhd8ed1ab_0 conda-forge
pyppmd 0.18.2 py39h415ef7b_0 conda-forge
pyprind 2.11.2 py39hcbf5309_1002 conda-forge
pyside2 5.13.2 py39hc084194_8 conda-forge
pysocks 1.7.1 py39hcbf5309_5 conda-forge
python 3.9.12 h9a09f29_1_cpython conda-forge
python-dateutil 2.8.2 pyhd8ed1ab_0 conda-forge
python_abi 3.9 2_cp39 conda-forge
pytz 2022.1 pyhd8ed1ab_0 conda-forge
pyzstd 0.15.1 py39h46500c5_0 conda-forge
qt 5.12.9 h556501e_6 conda-forge
requests 2.27.1 pyhd8ed1ab_0 conda-forge
salib 1.4.5 pyh6c4a22f_0 conda-forge
scipy 1.8.0 py39hc0c34ad_1 conda-forge
seaborn 0.11.2 hd8ed1ab_0 conda-forge
seaborn-base 0.11.2 pyhd8ed1ab_0 conda-forge
setuptools 62.0.0 py39hcbf5309_0 conda-forge
six 1.16.0 pyh6c4a22f_0 conda-forge
soupsieve 2.3.1 pyhd8ed1ab_0 conda-forge
sqlite 3.37.1 h8ffe710_0 conda-forge
stats_arrays 0.6.5 py_2 cmutel
statsmodels 0.13.2 py39h5d4886f_0 conda-forge
tabulate 0.8.9 pyhd8ed1ab_0 conda-forge
tbb 2021.5.0 h2d74725_1 conda-forge
texttable 1.6.4 pyhd8ed1ab_0 conda-forge
tk 8.6.12 h8ffe710_0 conda-forge
typing_extensions 4.1.1 pyha770c72_0 conda-forge
tzdata 2022a h191b570_0 conda-forge
ucrt 10.0.20348.0 h57928b3_0 conda-forge
unicodecsv 0.14.1 py_1 conda-forge
unicodedata2 14.0.0 py39hb82d6ee_1 conda-forge
unidecode 1.3.4 pyhd8ed1ab_0 conda-forge
urllib3 1.26.9 pyhd8ed1ab_0 conda-forge
vc 14.2 hb210afc_6 conda-forge
voluptuous 0.13.0 pyhd8ed1ab_0 conda-forge
vs2015_runtime 14.29.30037 h902a5da_6 conda-forge
wheel 0.37.1 pyhd8ed1ab_0 conda-forge
whoosh 2.7.4 py39hcbf5309_5 conda-forge
win_inet_pton 1.1.0 py39hcbf5309_4 conda-forge
wrapt 1.14.0 py39hb82d6ee_1 conda-forge
xlrd 2.0.1 pyhd8ed1ab_3 conda-forge
xlsxwriter 3.0.3 pyhd8ed1ab_0 conda-forge
xorg-libxau 1.0.9 hcd874cb_0 conda-forge
xorg-libxdmcp 1.1.3 hcd874cb_0 conda-forge
xz 5.2.5 h62dcd97_1 conda-forge
zipfile-deflate64 0.2.0 py39hb82d6ee_1 conda-forge
zipp 3.8.0 pyhd8ed1ab_0 conda-forge
zlib 1.2.11 h8ffe710_1014 conda-forge
zstd 1.5.2 h6255e5f_0 conda-forge

I'm unable to replicate the above with the exact same database and scenario file. Both using the most recent ab_dev My conda list for reference:

# packages in environment at C:\ProgramData\Anaconda3\envs\ab_dev:
#
# Name                    Version                   Build  Channel
activity-browser-dev      2022.03.29                 py_0    bsteubing
appdirs                   1.4.4              pyh9f0ad1d_0    conda-forge
arrow                     1.2.2              pyhd8ed1ab_0    conda-forge
asteval                   0.9.23             pyhd8ed1ab_0    conda-forge
astunparse                1.6.3              pyhd8ed1ab_0    conda-forge
beautifulsoup4            4.10.0             pyha770c72_0    conda-forge
brightway2                2.4.2                      py_4    cmutel
brotli                    1.0.9                h8ffe710_6    conda-forge
brotli-bin                1.0.9                h8ffe710_6    conda-forge
brotli-python             1.0.9            py39h415ef7b_6    conda-forge
brotlicffi                1.0.9.2          py39h415ef7b_1    conda-forge
brotlipy                  0.7.0           py39hb82d6ee_1003    conda-forge
bw2analyzer               0.10                       py_1    cmutel
bw2calc                   1.8.1                      py_2    cmutel
bw2data                   3.6.4                      py_0    cmutel
bw2io                     0.8.6                      py_1    cmutel
bw2parameters             0.7                        py_0    cmutel
bw_migrations             0.1                        py_0    cmutel
bzip2                     1.0.8                h8ffe710_4    conda-forge
ca-certificates           2021.10.8            h5b45459_0    conda-forge
certifi                   2021.10.8        py39hcbf5309_2    conda-forge
cffi                      1.15.0           py39h0878f49_0    conda-forge
charset-normalizer        2.0.12             pyhd8ed1ab_0    conda-forge
cryptography              36.0.2           py39h7bc7c5c_0    conda-forge
cycler                    0.11.0             pyhd8ed1ab_0    conda-forge
dill                      0.3.4              pyhd8ed1ab_0    conda-forge
docopt                    0.6.2                      py_1    conda-forge
eidl                      1.4.2                      py_0    bsteubing
eight                     1.0.0                      py_0    conda-forge
et_xmlfile                1.0.1                   py_1001    conda-forge
fasteners                 0.17.3             pyhd8ed1ab_0    conda-forge
fonttools                 4.31.2           py39hb82d6ee_0    conda-forge
freetype                  2.10.4               h546665d_1    conda-forge
future                    0.18.2           py39hcbf5309_4    conda-forge
icu                       69.1                 h0e60522_0    conda-forge
idna                      3.3                pyhd8ed1ab_0    conda-forge
importlib-metadata        4.11.3           py39hcbf5309_0    conda-forge
importlib_metadata        4.11.3               hd8ed1ab_0    conda-forge
intel-openmp              2022.0.0          h57928b3_3663    conda-forge
jbig                      2.1               h8d14728_2003    conda-forge
jpeg                      9e                   h8ffe710_0    conda-forge
kiwisolver                1.4.2            py39h2e07f2f_0    conda-forge
lcms2                     2.12                 h2a16943_0    conda-forge
lerc                      3.0                  h0e60522_0    conda-forge
libblas                   3.9.0              13_win64_mkl    conda-forge
libbrotlicommon           1.0.9                h8ffe710_6    conda-forge
libbrotlidec              1.0.9                h8ffe710_6    conda-forge
libbrotlienc              1.0.9                h8ffe710_6    conda-forge
libcblas                  3.9.0              13_win64_mkl    conda-forge
libclang                  13.0.1          default_h81446c8_0    conda-forge
libdeflate                1.10                 h8ffe710_0    conda-forge
libffi                    3.4.2                h8ffe710_5    conda-forge
libiconv                  1.16                 he774522_0    conda-forge
liblapack                 3.9.0              13_win64_mkl    conda-forge
libpng                    1.6.37               h1d00b33_2    conda-forge
libtiff                   4.3.0                hc4061b1_3    conda-forge
libwebp                   1.2.2                h57928b3_0    conda-forge
libwebp-base              1.2.2                h8ffe710_1    conda-forge
libxcb                    1.13              hcd874cb_1004    conda-forge
libxml2                   2.9.12               hf5bbc77_2    conda-forge
libxslt                   1.1.33               h65864e5_3    conda-forge
libzlib                   1.2.11            h8ffe710_1014    conda-forge
lxml                      4.8.0            py39hb82d6ee_1    conda-forge
lz4-c                     1.9.3                h8ffe710_1    conda-forge
m2w64-gcc-libgfortran     5.3.0                         6    conda-forge
m2w64-gcc-libs            5.3.0                         7    conda-forge
m2w64-gcc-libs-core       5.3.0                         7    conda-forge
m2w64-gmp                 6.1.0                         2    conda-forge
m2w64-libwinpthread-git   5.0.0.4634.697f757               2    conda-forge
matplotlib-base           3.5.1            py39h581301d_0    conda-forge
mkl                       2022.0.0           h0e2418a_796    conda-forge
mrio_common_metadata      0.1.1                      py_0    cmutel
msys2-conda-epoch         20160418                      1    conda-forge
multiprocess              0.70.12.2        py39hb82d6ee_2    conda-forge
multivolumefile           0.2.3              pyhd8ed1ab_0    conda-forge
munkres                   1.1.4              pyh9f0ad1d_0    conda-forge
networkx                  2.7.1              pyhd8ed1ab_1    conda-forge
numpy                     1.22.3           py39h6331f09_0    conda-forge
openjpeg                  2.4.0                hb211442_1    conda-forge
openpyxl                  3.0.9              pyhd8ed1ab_0    conda-forge
openssl                   1.1.1n               h8ffe710_0    conda-forge
packaging                 21.3               pyhd8ed1ab_0    conda-forge
pandas                    1.4.1            py39h2e25243_0    conda-forge
pathos                    0.2.8              pyhd8ed1ab_0    conda-forge
patsy                     0.5.2              pyhd8ed1ab_0    conda-forge
peewee                    3.14.10          py39h539719c_0    conda-forge
pillow                    9.0.1            py39ha53f419_2    conda-forge
pip                       22.0.4             pyhd8ed1ab_0    conda-forge
pox                       0.3.0              pyhd8ed1ab_0    conda-forge
ppft                      1.6.6.4            pyhd8ed1ab_0    conda-forge
psutil                    5.9.0            py39hb82d6ee_0    conda-forge
pthread-stubs             0.4               hcd874cb_1001    conda-forge
py7zr                     0.18.3             pyhd8ed1ab_0    conda-forge
pybcj                     0.5.1            py39hb82d6ee_0    conda-forge
pybcpy                    0.0.17             pyhd8ed1ab_0    conda-forge
pycparser                 2.21               pyhd8ed1ab_0    conda-forge
pycryptodomex             3.14.1           py39hb82d6ee_0    conda-forge
pyopenssl                 22.0.0             pyhd8ed1ab_0    conda-forge
pypardiso                 0.4.0              pyhd8ed1ab_0    conda-forge
pyparsing                 3.0.7              pyhd8ed1ab_0    conda-forge
pyppmd                    0.18.1           py39h415ef7b_0    conda-forge
pyprind                   2.11.2          py39hcbf5309_1002    conda-forge
pyside2                   5.13.2           py39hc084194_4    conda-forge
pysocks                   1.7.1            py39hcbf5309_4    conda-forge
python                    3.9.12          h9a09f29_1_cpython    conda-forge
python-dateutil           2.8.2              pyhd8ed1ab_0    conda-forge
python_abi                3.9                      2_cp39    conda-forge
pytz                      2022.1             pyhd8ed1ab_0    conda-forge
pyzstd                    0.15.1           py39h46500c5_0    conda-forge
qt                        5.12.9               h556501e_6    conda-forge
requests                  2.27.1             pyhd8ed1ab_0    conda-forge
salib                     1.4.5              pyh6c4a22f_0    conda-forge
scipy                     1.8.0            py39hc0c34ad_1    conda-forge
seaborn                   0.11.2               hd8ed1ab_0    conda-forge
seaborn-base              0.11.2             pyhd8ed1ab_0    conda-forge
setuptools                61.2.0           py39hcbf5309_3    conda-forge
six                       1.16.0             pyh6c4a22f_0    conda-forge
soupsieve                 2.3.1              pyhd8ed1ab_0    conda-forge
sqlite                    3.37.1               h8ffe710_0    conda-forge
stats_arrays              0.6.5                      py_2    cmutel
statsmodels               0.13.2           py39h5d4886f_0    conda-forge
tabulate                  0.8.9              pyhd8ed1ab_0    conda-forge
tbb                       2021.5.0             h2d74725_0    conda-forge
texttable                 1.6.4              pyhd8ed1ab_0    conda-forge
tk                        8.6.12               h8ffe710_0    conda-forge
typing_extensions         4.1.1              pyha770c72_0    conda-forge
tzdata                    2022a                h191b570_0    conda-forge
ucrt                      10.0.20348.0         h57928b3_0    conda-forge
unicodecsv                0.14.1                     py_1    conda-forge
unicodedata2              14.0.0           py39hb82d6ee_0    conda-forge
unidecode                 1.3.4              pyhd8ed1ab_0    conda-forge
urllib3                   1.26.9             pyhd8ed1ab_0    conda-forge
vc                        14.2                 hb210afc_6    conda-forge
voluptuous                0.13.0             pyhd8ed1ab_0    conda-forge
vs2015_runtime            14.29.30037          h902a5da_6    conda-forge
wheel                     0.37.1             pyhd8ed1ab_0    conda-forge
whoosh                    2.7.4            py39hcbf5309_5    conda-forge
win_inet_pton             1.1.0            py39hcbf5309_3    conda-forge
wrapt                     1.14.0           py39hb82d6ee_0    conda-forge
xlrd                      2.0.1              pyhd8ed1ab_3    conda-forge
xlsxwriter                3.0.3              pyhd8ed1ab_0    conda-forge
xorg-libxau               1.0.9                hcd874cb_0    conda-forge
xorg-libxdmcp             1.1.3                hcd874cb_0    conda-forge
xz                        5.2.5                h62dcd97_1    conda-forge
zipfile-deflate64         0.2.0            py39hb82d6ee_1    conda-forge
zipp                      3.7.0              pyhd8ed1ab_1    conda-forge
zlib                      1.2.11            h8ffe710_1014    conda-forge
zstd                      1.5.2                h6255e5f_0    conda-forge

I also have another user reporting the same issue that is not using parameters but a scenario difference file: image

marc-vdm avatar Apr 07 '22 15:04 marc-vdm

Perhaps related: ~~#689~~ #639

edit: #689 confirmed by this comment

marc-vdm avatar Apr 08 '22 07:04 marc-vdm

update:

  • Updating Biosphere does not solve the problem
  • Using different impact category does not solve the problem
  • Not using scenarios does not solve the problem

Intermediate fix is to replace: https://github.com/LCA-ActivityBrowser/activity-browser/blob/be1113aa7214ea4441a66ad146334b7963be52f6/activity_browser/bwutils/multilca.py#L515 with:

        if len(_df := df.replace(0, np.nan).dropna(how='all')) != 0:
            df = _df

This shows all results, though there's nothing to show, but at least allows user to continue using AB more easily (especially with bug of #767)

marc-vdm avatar Apr 08 '22 10:04 marc-vdm

From my experience with the software, I think this error showed up whenever I was trying to run a calculation and that not a single elementary flow was characterized.

MaximeAgez avatar Apr 08 '22 14:04 MaximeAgez

I have come across this TypeError, too. In my case, I was tring to calculate the LCA results of activities that only contained biosphere flows (and no technosphere flows).

The solution was to add one technosphere flow (either from an activity in the ecoinvent database or from my own activities) to one of the activities, while leaving the other activities untouched.

Other things i tried that did not work:

  • add a technosphere flow but set the value to zero
  • create an empty activity and add "1 unit" of it

So in case you need to compare activities with only biosphere flows and run into this error, I suggest that you add another (random) activity to the LCA setup, that includes a technosphere flow, but that does not matter for your comparison. Then, the calculations should go through also for the activities only containing biosphere flows.

muelleram avatar Jun 01 '22 08:06 muelleram

Problem showed again. I am 99% confident that the problem shows up whenever an impact method is called and that there is 0 elementary flow within the life cycle inventory. That explains why whenever @muelleram assesses a process with only biosphere flows, there are higher chances that (for example) no radioactive flow is present in the life cycle inventory and thus when calling an impact method assessing "Ionising radiations" it bugs. When adding a random technosphere input though, chances are there will be at least one radioactive flow somewhere within the upstream value chain, thus not prompting the error.

This error should be corrected because it kind of hinders the use of "direct emissions activities" in which there are only biosphere flows. The fix would be to only call impact method which are relevant for the biosphere flows passed within the studied activity (but it's super long), or as suggested by @muelleram to add a very small input of a random technosphere flow to account for at least a bit of every possible elementary flow (but that's dirty).

MaximeAgez avatar Jun 23 '22 19:06 MaximeAgez

Thanks all for your additional information, this helps solve problems like this!

The problem is not with calculating results on the Brightway level. The problem is in AB, where our results code currently cannot handle the 'empty results' problem. A fix to prevent AB from failing is already posted here, though that is not a 'pretty' way AB should handle this. We need to put in more work to make AB properly catch and handle this problem. For now, when AB fails with this error, consider it results; there were indeed no elem. flows contributing to the characterization factor.

A better fix will be available in time.

marc-vdm avatar Jun 24 '22 12:06 marc-vdm

Hello, I am thankful for this forum. Obviously I am here because I have countered this type error just recently. Upon following the recommended immediate fix, LCA calculation was able to proceed but there are no values of the results. Is this how it is supposed to work? I would admit that I have very little competency in coding so, trouble shooting would be extra hard for me. Thank you in advance for your help!

gleewriterly avatar Jun 01 '23 18:06 gleewriterly

This probably means that there were no valid results (or only '0' results) for the system you tried to calculate.

Could you explain (or share a screenshot) a little more about what you're trying to calculate? Someone above found that this happens in specific cases where activities/processes are used without any other process input and only biosphere/elementary flow inputs. Someone else explained it happens when no elementary flows are characterized.

Some more information from you will help us better understand the problem and allow us to fix it!

marc-vdm avatar Jun 01 '23 18:06 marc-vdm

So for example, I want to calculate impacts of wheat using the EF3.0. image After Calculation, the results window appeared but it was missing the results. It was just strange for me as I have been using AB for quite some time now but this problem just occured now image I hope that my response is exactly what you meant by your question. Thank you in advance!

gleewriterly avatar Jun 01 '23 19:06 gleewriterly

Thanks a lot for the info! This is indeed what we'd like to know. Would it be possible for you to share the database too? Of course if the data is confidential, I would understand you can't but this will help us see what the problem could be.

You can export the database through the top-left File>Export database option, ideally exported as an Excel file. Of course, if this database relies on other databases like ecoinvent, please let us know which one so we can properly import it :).

marc-vdm avatar Jun 02 '23 07:06 marc-vdm

Really, many thanks for being so responsive! I just learned that LCA results appear when calculating inventory from ecoinvent. But when I calculate results from my database, that's when the problem occur. Also, I have problems exporting my database in excel so would it work the same if I provide the python format? But due to confidentiality reasons, perhaps, I can the send the database to you by e-mail?

Exporting the database in excel would lead to a conda prompt like this: image

gleewriterly avatar Jun 02 '23 12:06 gleewriterly

Yes email is also fine! Also the other format is fine, but that's another problem we need to figure out 😅

please mail it to [email protected]

marc-vdm avatar Jun 02 '23 13:06 marc-vdm

Hi @marc-vdm, I see your solution. However, after implementing it, all results are 0. Any hints on this?

danielembc avatar Jun 06 '23 08:06 danielembc

@danielembc That is correct, as I explain here, there are probably only '0' results.

We can look at your data to see if we can easily find an error. Could you please send me the following to [email protected]:

  1. The excel version of the database you're using (you can export under top left File>Export Database)
  2. If you're using ecoinvent as inputs to your system, please share which version (e.g. ecoinvent 3.9.1 cutoff)
  3. The calculation setup; which process(es) were you calculating, which impact category/ies were you using?

We will treat your data confidentially internally.

marc-vdm avatar Jun 06 '23 10:06 marc-vdm

Apologies, it was not very clear to me what '0' results mean after the calculation set-up. Because LCA results should not be zero unless it is something multiplied to zero, which is not the case in our calculations because they do have values other than zero. :/

gleewriterly avatar Jun 06 '23 10:06 gleewriterly

Hi @gleewriterly

the problem you are facing is a difficult one, everything seems to be running fine up until the point that the matrix solver (pardiso) calculates the results. Pardiso pumps out a full list of nans, I've run through your exchanges and products and haven't found any obvious causes (I was hunting for something I know of that can lead to an infinite value, or nan).

I'm going to try and have a look at some of the documentation from brightway and the solver we use to understand what other conditions might be causing this, however it might take a while. You could try posting this in the brightway calc repository, as this occurs in brightway independent of the AB, they have a lot of people with more experience than me.

@danielembc I will make an update to the code that should stop some of these errors happening when there are legitimately no results (something we missed). This should be ready by early next week if you can wait

Zoophobus avatar Jun 07 '23 17:06 Zoophobus

Hi, thanks for the update. I really appreciate the work you do for the AB community! As unlucky as I might be, this seems to be a selective issue no? My colleagues do not have the same issue encountered in their AB. I am therefore interested what could be the possible factors leading to this issue. For now, I tried AB in my personal computer, imported the database from my work PC and voila! AB works just fine in calculating results.

gleewriterly avatar Jun 08 '23 07:06 gleewriterly

Hi @gleewriterly could you please send the environments for your work computer and home computer? This might be an issue with some of these other packages so this would be a huge help to identify what's going on.

Zoophobus avatar Jun 08 '23 07:06 Zoophobus

I am not quite sure that I understand the question but I hope my answer will help you: My work computer runs on windows and I use Anaconda to create environment for AB, meanwhile my home PC is a MAC and miniconda was used to create AB environment.

gleewriterly avatar Jun 08 '23 08:06 gleewriterly

Oh if its helpful to know, I already installed AB in my mac way before I was given my work computer. When I encountered this issue on AB in my work PC, it just occured to me that I have AB in my mac and just tried to import my working database in an attempt to have a functioning AB, to my surprise, the LCA calculations worked fine!

gleewriterly avatar Jun 08 '23 08:06 gleewriterly

Hi @gleewriterly,

my apologies I was wondering if you could copy the output of the conda environments (using conda list from the activated environments), either to a file and post it here or just directly copy it here, thanks for your patience!

Zoophobus avatar Jun 08 '23 09:06 Zoophobus

Hi! here is the conda list of my ab env in my home PC. Unfortunately, i cannot provide the conda list for my work PC as I had a problem as of the moment in locating my ab env after the attempt to uninstall then reinstall AB in my work PC.

(ab) gleezamanulat@Gleeza ~ % conda list
# packages in environment at /Users/gleezamanulat/miniforge3/envs/ab:
#
# Name                    Version                   Build  Channel
activity-browser-dev      2022.04.29                 py_0    bsteubing
appdirs                   1.4.4              pyh9f0ad1d_0    conda-forge
arrow                     1.2.2              pyhd8ed1ab_0    conda-forge
asteval                   0.9.27             pyhd8ed1ab_0    conda-forge
astunparse                1.6.3              pyhd8ed1ab_0    conda-forge
beautifulsoup4            4.11.1             pyha770c72_0    conda-forge
brightway2                2.4.2                      py_6    haasad/label/experimental
brotli                    1.0.9                h5eb16cf_7    conda-forge
brotli-bin                1.0.9                h5eb16cf_7    conda-forge
brotli-python             1.0.9            py39hfd1d529_7    conda-forge
brotlicffi                1.0.9.2          py39hfd1d529_2    conda-forge
brotlipy                  0.7.0           py39h63b48b0_1004    conda-forge
bw2analyzer               0.10                       py_1    cmutel
bw2calc                   1.8.1                      py_2    cmutel
bw2data                   3.6.5                      py_0    cmutel
bw2io                     0.8.6                      py_1    cmutel
bw2parameters             0.7                        py_0    cmutel
bw_migrations             0.1                        py_0    cmutel
bzip2                     1.0.8                h0d85af4_4    conda-forge
ca-certificates           2022.6.15            h033912b_0    conda-forge
certifi                   2022.6.15        py39h6e9494a_0    conda-forge
cffi                      1.15.0           py39he338e87_0    conda-forge
charset-normalizer        2.0.12             pyhd8ed1ab_0    conda-forge
cryptography              37.0.2           py39h9c2a9ce_0    conda-forge
cycler                    0.11.0             pyhd8ed1ab_0    conda-forge
dill                      0.3.5.1            pyhd8ed1ab_0    conda-forge
docopt                    0.6.2                      py_1    conda-forge
eidl                      1.5.1                      py_0    bsteubing
eight                     1.0.0                      py_0    conda-forge
et_xmlfile                1.0.1                   py_1001    conda-forge
fasteners                 0.17.3             pyhd8ed1ab_0    conda-forge
fonttools                 4.33.3           py39h701faf5_0    conda-forge
freetype                  2.10.4               h4cff582_1    conda-forge
future                    0.18.2           py39h6e9494a_5    conda-forge
gettext                   0.19.8.1          hd1a6beb_1008    conda-forge
giflib                    5.2.1                hbcb3906_2    conda-forge
glib                      2.70.2               hcf210ce_4    conda-forge
glib-tools                2.70.2               hcf210ce_4    conda-forge
gmp                       6.2.1                h2e338ed_0    conda-forge
gst-plugins-base          1.20.2               hda0ba4b_2    conda-forge
gstreamer                 1.20.2               hdc08c3f_2    conda-forge
icu                       70.1                 h96cf925_0    conda-forge
idna                      3.3                pyhd8ed1ab_0    conda-forge
importlib-metadata        4.11.4           py39h6e9494a_0    conda-forge
importlib_metadata        4.11.4               hd8ed1ab_0    conda-forge
jpeg                      9e                   h5eb16cf_1    conda-forge
kiwisolver                1.4.3            py39h7c694c3_0    conda-forge
krb5                      1.19.3               hb49756b_0    conda-forge
lcms2                     2.12                 h577c468_0    conda-forge
lerc                      3.0                  he49afe7_0    conda-forge
libblas                   3.9.0           15_osx64_openblas    conda-forge
libbrotlicommon           1.0.9                h5eb16cf_7    conda-forge
libbrotlidec              1.0.9                h5eb16cf_7    conda-forge
libbrotlienc              1.0.9                h5eb16cf_7    conda-forge
libcblas                  3.9.0           15_osx64_openblas    conda-forge
libclang                  14.0.5          default_h55ffa42_0    conda-forge
libclang13                14.0.5          default_hb5731bd_0    conda-forge
libcxx                    14.0.5               hce7ea42_1    conda-forge
libdeflate                1.12                 hac89ed1_0    conda-forge
libedit                   3.1.20191231         h0678c8f_2    conda-forge
libffi                    3.4.2                h0d85af4_5    conda-forge
libgfortran               5.0.0           9_3_0_h6c81a4c_23    conda-forge
libgfortran5              9.3.0               h6c81a4c_23    conda-forge
libglib                   2.70.2               hf1fb8c0_4    conda-forge
libiconv                  1.16                 haf1e3a3_0    conda-forge
liblapack                 3.9.0           15_osx64_openblas    conda-forge
libllvm14                 14.0.5               h41df66c_0    conda-forge
libogg                    1.3.4                h35c211d_1    conda-forge
libopenblas               0.3.20          openmp_hb3cd9ec_0    conda-forge
libopus                   1.3.1                hc929b4f_1    conda-forge
libpng                    1.6.37               h7cec526_2    conda-forge
libpq                     14.4                 hf6bb32a_0    conda-forge
libtiff                   4.4.0                h9847915_1    conda-forge
libvorbis                 1.3.7                h046ec9c_0    conda-forge
libwebp                   1.2.2                h28dabe5_0    conda-forge
libwebp-base              1.2.2                h0d85af4_1    conda-forge
libxcb                    1.13              h0d85af4_1004    conda-forge
libxml2                   2.9.14               h08a9926_0    conda-forge
libxslt                   1.1.35               heaa0ce8_0    conda-forge
libzlib                   1.2.12               hfe4f2af_1    conda-forge
llvm-openmp               14.0.4               ha654fa7_0    conda-forge
lxml                      4.9.0            py39h701faf5_0    conda-forge
lz4-c                     1.9.3                he49afe7_1    conda-forge
matplotlib-base           3.5.2            py39h64a0072_0    conda-forge
metis                     5.1.0             h2e338ed_1006    conda-forge
mpfr                      4.1.0                h0f52abe_1    conda-forge
mrio_common_metadata      0.2.1                      py_0    cmutel
multiprocess              0.70.13          py39h701faf5_1    conda-forge
multivolumefile           0.2.3              pyhd8ed1ab_0    conda-forge
munkres                   1.1.4              pyh9f0ad1d_0    conda-forge
mysql-common              8.0.29               h924029e_1    conda-forge
mysql-libs                8.0.29               h3cab752_1    conda-forge
ncurses                   6.3                  h96cf925_1    conda-forge
networkx                  2.8.4              pyhd8ed1ab_0    conda-forge
nspr                      4.32                 hcd9eead_1    conda-forge
nss                       3.78                 ha8197d3_0    conda-forge
numpy                     1.22.4           py39h677350a_0    conda-forge
openjpeg                  2.4.0                h6e7aa92_1    conda-forge
openpyxl                  3.0.9              pyhd8ed1ab_0    conda-forge
openssl                   1.1.1o               hfe4f2af_0    conda-forge
packaging                 21.3               pyhd8ed1ab_0    conda-forge
pandas                    1.4.2            py39hf72b562_2    conda-forge
pathos                    0.2.9              pyhd8ed1ab_0    conda-forge
patsy                     0.5.2              pyhd8ed1ab_0    conda-forge
pcre                      8.45                 he49afe7_0    conda-forge
peewee                    3.14.10          py39h9a19eac_1    conda-forge
pillow                    9.1.1            py39h579eac4_1    conda-forge
pip                       22.1.2             pyhd8ed1ab_0    conda-forge
pox                       0.3.1              pyhd8ed1ab_0    conda-forge
ppft                      1.7.6.5            pyhd8ed1ab_0    conda-forge
psutil                    5.9.1            py39h701faf5_0    conda-forge
pthread-stubs             0.4               hc929b4f_1001    conda-forge
py7zr                     0.18.9             pyhd8ed1ab_0    conda-forge
pybcj                     0.6.0            py39h701faf5_0    conda-forge
pybcpy                    0.0.17             pyhd8ed1ab_0    conda-forge
pycparser                 2.21               pyhd8ed1ab_0    conda-forge
pycryptodomex             3.14.1           py39h63b48b0_1    conda-forge
pyopenssl                 22.0.0             pyhd8ed1ab_0    conda-forge
pyparsing                 3.0.9              pyhd8ed1ab_0    conda-forge
pyppmd                    0.18.2           py39hfd1d529_0    conda-forge
pyprind                   2.11.2          py39h6e9494a_1002    conda-forge
pyside2                   5.15.4           py39hce94f87_1    conda-forge
pysocks                   1.7.1            py39h6e9494a_5    conda-forge
python                    3.9.13          h57e37ff_0_cpython    conda-forge
python-dateutil           2.8.2              pyhd8ed1ab_0    conda-forge
python_abi                3.9                      2_cp39    conda-forge
pytz                      2022.1             pyhd8ed1ab_0    conda-forge
pyxlsb                    1.0.9              pyhd8ed1ab_0    conda-forge
pyzstd                    0.15.1           py39he9e7ee6_1    conda-forge
qt-main                   5.15.4               h938c29d_2    conda-forge
qt-webengine              5.15.4               h72ca1e5_3    conda-forge
readline                  8.1.2                h3899abd_0    conda-forge
requests                  2.28.0             pyhd8ed1ab_0    conda-forge
salib                     1.4.5              pyh6c4a22f_0    conda-forge
scikit-umfpack            0.3.2           py39h4b7cfb1_1004    conda-forge
scipy                     1.8.1            py39hfa1a3ab_0    conda-forge
seaborn                   0.11.2               hd8ed1ab_0    conda-forge
seaborn-base              0.11.2             pyhd8ed1ab_0    conda-forge
setuptools                62.3.4           py39h6e9494a_0    conda-forge
setuptools-scm            6.4.2              pyhd8ed1ab_0    conda-forge
six                       1.16.0             pyh6c4a22f_0    conda-forge
soupsieve                 2.3.1              pyhd8ed1ab_0    conda-forge
sqlite                    3.38.5               hd9f0692_0    conda-forge
stats_arrays              0.6.5                      py_2    cmutel
statsmodels               0.13.2           py39h15b18c7_0    conda-forge
suitesparse               5.10.1               h7aff33d_1    conda-forge
tabulate                  0.8.9              pyhd8ed1ab_0    conda-forge
tbb                       2021.5.0             hbb4e6a2_1    conda-forge
texttable                 1.6.4              pyhd8ed1ab_0    conda-forge
tk                        8.6.12               h5dbffcc_0    conda-forge
tomli                     2.0.1              pyhd8ed1ab_0    conda-forge
typing_extensions         4.2.0              pyha770c72_1    conda-forge
tzdata                    2022a                h191b570_0    conda-forge
unicodecsv                0.14.1                     py_1    conda-forge
unicodedata2              14.0.0           py39h63b48b0_1    conda-forge
unidecode                 1.3.4              pyhd8ed1ab_0    conda-forge
urllib3                   1.26.9             pyhd8ed1ab_0    conda-forge
voluptuous                0.13.1             pyhd8ed1ab_0    conda-forge
wheel                     0.37.1             pyhd8ed1ab_0    conda-forge
whoosh                    2.7.4            py39h6e9494a_5    conda-forge
wrapt                     1.14.1           py39h701faf5_0    conda-forge
xlrd                      2.0.1              pyhd8ed1ab_3    conda-forge
xlsxwriter                3.0.3              pyhd8ed1ab_0    conda-forge
xorg-libxau               1.0.9                h35c211d_0    conda-forge
xorg-libxdmcp             1.1.3                h35c211d_0    conda-forge
xz                        5.2.5                haf1e3a3_1    conda-forge
zipfile-deflate64         0.2.0            py39h63b48b0_2    conda-forge
zipp                      3.8.0              pyhd8ed1ab_0    conda-forge
zlib                      1.2.12               hfe4f2af_1    conda-forge
zstd                      1.5.2                ha9df2e0_1    conda-forge

gleewriterly avatar Jun 08 '23 12:06 gleewriterly

No worries, I can use this with my setup. Thanks!

Zoophobus avatar Jun 08 '23 12:06 Zoophobus

Hi @gleewriterly,

my apologies for taking so long I have been in touch with CMutel at bw and he gave me some helpful pointers in what to look for. As a result I've been going through your database in bw and have finally been able to identify the issue to your database. Here you have the process ('Gleeza Feed', 'e445f10d368a4eaa9b502b035da1d473_copy2'), or HT heat (mix) (FR), this has a self referential flow of 1 megajoule in the technosphere matrix and a product of 1 megajoule. How we deal with self referential flows in the AB is to find the proportion of the difference in these values (we first take the difference between these and then divide this by the sum of the difference and the technosphere values). This gives the process a production of 0, which makes the matrix calculation impossible.

I'm not sure how you want to proceed, if you have any more specific questions about the HT heat (mix) process, or have any questions then feel free to ask and again my apologies for taking so long to respond

Zoophobus avatar Jul 03 '23 09:07 Zoophobus

Hello Jonathan, Many many thanks for still looking unto this issue. Indeed the issue is with my HT heat mix inventory. The self-referential flow was my mistake. I thank you for finding it for me. As i removed the 1 megajoule in the technosphere mix, I can now view the LCA results in my AB! Again, many many thanks! All the best!

gleewriterly avatar Jul 03 '23 12:07 gleewriterly

Closing this as resolved in #1025

marc-vdm avatar Sep 14 '23 14:09 marc-vdm