Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calculate LCA causes ValueError: Length mismatch #284

Closed
nheeren opened this issue Sep 9, 2019 · 7 comments
Closed

Calculate LCA causes ValueError: Length mismatch #284

nheeren opened this issue Sep 9, 2019 · 7 comments

Comments

@nheeren
Copy link

nheeren commented Sep 9, 2019

Just tried to do an LCA for 14 products and 11 impact categories and got the following error. Not sure what caused it. Will explore further and update.

Traceback (most recent call last):
  File "/Users/n/code/_env/miniconda3/envs/ab/lib/python3.7/site-packages/activity_browser/app/ui/tabs/LCA_results_tab.py", line 41, in generate_setup
    new_tab = LCAResultsSubTab(self, name)
  File "/Users/n/code/_env/miniconda3/envs/ab/lib/python3.7/site-packages/activity_browser/app/ui/tabs/LCA_results_tabs.py", line 90, in __init__
    self.setup_tabs()
  File "/Users/n/code/_env/miniconda3/envs/ab/lib/python3.7/site-packages/activity_browser/app/ui/tabs/LCA_results_tabs.py", line 119, in setup_tabs
    self.inventory_tab.update_table()
  File "/Users/n/code/_env/miniconda3/envs/ab/lib/python3.7/site-packages/activity_browser/app/ui/tabs/LCA_results_tabs.py", line 576, in update_table
    self.df_biosphere = self.parent.contributions.inventory_df(inventory_type='biosphere')
  File "/Users/n/code/_env/miniconda3/envs/ab/lib/python3.7/site-packages/activity_browser/app/bwutils/multilca.py", line 463, in inventory_df
    df.columns = self.get_labels(self.mlca.fu_activity_keys, max_length=30)
  File "/Users/n/code/_env/miniconda3/envs/ab/lib/python3.7/site-packages/pandas/core/generic.py", line 5192, in __setattr__
    return object.__setattr__(self, name, value)
  File "pandas/_libs/properties.pyx", line 67, in pandas._libs.properties.AxisProperty.__set__
  File "/Users/n/code/_env/miniconda3/envs/ab/lib/python3.7/site-packages/pandas/core/generic.py", line 690, in _set_axis
    self._data.set_axis(axis, labels)
  File "/Users/n/code/_env/miniconda3/envs/ab/lib/python3.7/site-packages/pandas/core/internals/managers.py", line 183, in set_axis
    "values have {new} elements".format(old=old_len, new=new_len)
ValueError: Length mismatch: Expected axis has 13 elements, new values have 14 elements
@nheeren
Copy link
Author

nheeren commented Sep 9, 2019

Just re-did the calculation setup and it works there. Possibly the calculation setup somehow got dorked...

@nheeren
Copy link
Author

nheeren commented Sep 9, 2019

Went back to the old calculation setup, deleted a few processes and now it works. Sorry, not sure how to debug further. Feel free to close.

@dgdekoning
Copy link
Contributor

Interesting, I'll make a note of this, seems like an annoyance to have happen.
Did you edit the processes in the setup after creating the calculation setup (add/remove exchanges, change names, locations, units)?

@nheeren
Copy link
Author

nheeren commented Sep 9, 2019

Did you edit the processes in the setup after creating the calculation setup (add/remove exchanges, change names, locations, units)?

No. I didn't do anything fancy really...

@dgdekoning
Copy link
Contributor

I'll check up and down the error message tomorrow and see if there is something that could cause this, might find some things to improve.

@dgdekoning
Copy link
Contributor

Closing until further notice, feel free to (re)open if it happens again!

@dgdekoning
Copy link
Contributor

A possible fix for this issue is included in this pull request. It turns out that the rows in the table were being counted before the underlying models had been updated, which meant that the problem could mysteriously fix itself (e.g. The app was closed/opened or by moving between projects).

@dgdekoning dgdekoning modified the milestone: Version 2.4.0 Oct 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants