Skip to content

Commit

Permalink
Resolve scenario calculation bug (#1126)
Browse files Browse the repository at this point in the history
* Delete .github/workflows/install-canary.yaml

* Remove unused code in montecarlo.py

* Resolve #1103

* GH action script for commenting on issues when related milestone is closed.

* update bw2io requirement

* Update readme install instructions

* Update meta.yaml

* Update README.md

* Change requirement to brightway2 instead of bw2io

* Update README.md

* Increases the flexibility of the excel importer so it can also handle the parameter scenario files.

* Update README.md

How to install using Mamba

* Set up signals infrascructure

* Implement dialog

* Implement finding of suitable alternatives and proper management of failing that.

* Implement actual relinking

* Minor documentation improvements + store exchanges to remove instead of to keep.

* Minor documentation + code improvements

* Resolve #782 + improve documentation of `Contributions` class

* Minor documentation + code improvements

* Fix type hinting error

* Update README.md

* Update README.md

* Update README.md

* Updates to the functions get_relevant_flows and get_relevant_activities (#1069)

* Updates to the functions from de Koning (get_relevant_flows and get_relevant_activities), avoiding use of pandas apply and using python map functionality for splitting pandas dataframes.

* Update the use of DataFrame.applymap to DataFrame.map in the excel file importer module.

* Multiple sdf update (#1083)

* Updates to the logging system to avoid the print statement. Merging with
commits for corrections to the uncertainty distributions that were
included within the same branch. Improves thread safety in logging
increasing stability in the multi-threaded processes.

* Changes the creation of log files. Amends the uncertainty wizard test to correct for use of logging over the standard console. Adds the .logs to .gitignore.

* 1) Simplifies the use of the python logging facility with QtThreads (as published on the python docs for logging), improving the stability of logging.\n2) Changes the generation of the logging object that is more compatible with pytest, supporting the existing test procedures.

* Provides an update to the Model for the calculation_setup Methods table, corrects for deletion of impact assessment methods. Updates the routine to the lca_setup module for calling the logger.

* Updates to the logger module, what was the ABLogger class is renamed to ABHandler. The module now contains the formats and settings for the Stream handlers. Calling of the methods in the other AB modules requires passing a logging.Logger instance and the name of the calling module. These are then incorporated into the wrapping routines in the class. Additions:\n 1) An error wrapper is provided and also explicitly provides a trace of the error.\n 2) A timestamp routine is provided and used for providing the file names for log files.\n 3) A standard location based on appdirs is provided and used for log file locations.

* Corrections to the setup of the logger in the test_uncertainty_wizard module

* Includes a change to the type used for the scenario columns when using multiple files with the combined (combinatoric) approach for the scenarios. Includes respective changes to the boolean tests applied to such Indexes.

* Minor corrections to local repository branch, to keep changes aligned

* Alterations to keep minor changes aligned with master branch and fork

---------

Co-authored-by: zoo <[email protected]>

* Use node16 actions for main pipeline

* Use node16 actions in release pipeline

* Use latest version of release-changelog-builder

* Use node16 action for install canary pipeline

* Remove the special build for arm architecture

This was added before brightway2 supported multi-arch builds on
conda-forge. It is not needed anymore, because the normal AB is now also
installable on arm arch.

* Install canary updates (#1093)

* Increase timeout to 30 min

Originally the idea was that installation should never take longer than
12 min, otherwise we should get a warning with the failed pipeline. But
unfortuantely conda currently takes longer than 12 minutes to solve
the environment.

* Add mamba install canary

* Download artifacts to start implementing env comparison

* Looks like on linux it can take more than 30 minutes :-(

* 60min not enough on linux, increasing to 120

* Completely remove timeout, default is 6 hours

* Use solver libmamba option

* Add diff step to compare installations

* Use node16 actions

* Re-add the 12 timeout

* Split diff into separate steps

* Yq action only runs on linux

* debug yq formatting step

* Simplify

* more fighting with yq action

* artifacts are apparently directories in this case

* Try again with while loop

* Run on all os, but only 3.9

* ignore diff exit code

* Run canary install for 3.8 and 3.9 again

---------

Co-authored-by: haasad <[email protected]>

* Adding error message if no scenario file is loaded in a scenario LCA (#1085)

* Updated and improved contributing file

* Improve text on dependencies

* Fix canary link

* Add good/bad examples to CONTRIBUTING.md for commit messages and PR titles

* Add more specific requirements on communicating work on issues in CONTRIBUTING.md

* Minor updates to CONTRIBUTING.md and README.md

* Minor improvements to CONTRIBUTING.md

* Fix formatting error in PULL_REQUEST_TEMPLATE.md

* Resolve #1105

* Update copyright and license information to only link to one place.

* Resolve 3 bugs for location linking (#1051): 1) database of own activity was not always added (in case none of the exchanges were in own database) 2) improve handling of multiple locations. 3) replaced exchanges were deleted from the old process instead of the new one.

* Improve choosing and handling of alternative locations for location choosing

* Resolve readonly database bug for activity duplication to new activity.

* Store AB version in logfile

* Remove deprecated channels from conda envs

* Remove experimental conda environment creation and upload

I started this mostly as an experimental alternative install method with
`conda env create`. However since the channel handling isn't such a pain
anymore now that everything is on conda-forge this is obsolete.

* Move conda-envs to .github directory

* Move changelog config to .github

* Move dev recipe to .github directory

* Move stable recipe to recipe/meta.yaml

* Update dev recipe

* Use micromamba instead of miniconda to speed up tests

* Update install instructions to use libmamba solver with conda

* Fix path for dev recipe

* Added tooltip for table content

* Added docstring for data method

* Cleaning-up documentation

* Update README.md

Resolve #1127

* Add - copy on impact category copy (#1136)

* Add - copy on impact category copy #1133

* Reorder impact category tree context menu

* Resolve bug with switching project on delete (#1138)

* Switch project on delete #1075

* Cleaning up ProjectController.change_project

* Resolving comments by marc-vdm

* GH action script for commenting on issues when related milestone is closed.

* GH action script for commenting on issues when related milestone is closed.

* GH action script for commenting on issues when related milestone is closed.

* review instructions bot

* review instructions bot

---------

Co-authored-by: bsteubing <[email protected]>
Co-authored-by: zoophobus <[email protected]>
Co-authored-by: Jonathan Kidner <[email protected]>
Co-authored-by: zoo <[email protected]>
Co-authored-by: haasad <[email protected]>
Co-authored-by: Adrian Haas <[email protected]>
Co-authored-by: Marin Visscher <[email protected]>
Co-authored-by: Marin Visscher <[email protected]>
  • Loading branch information
9 people authored Dec 13, 2023
1 parent 7396245 commit 65d13b2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 25 deletions.
15 changes: 0 additions & 15 deletions activity_browser/bwutils/montecarlo.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,26 +50,11 @@ def __init__(self, cs_name):
self.activity_keys = [list(fu.keys())[0] for fu in self.func_units]
self.activity_index = {key: index for index, key in enumerate(self.activity_keys)}
self.rev_activity_index = {index: key for index, key in enumerate(self.activity_keys)}
# previously: self.rev_activity_index = {v: k for k, v in self.activity_keys}
# self.fu_index = {k: i for i, k in enumerate(self.activity_keys)}

# methods
self.methods = self.cs['ia']
self.method_index = {m: i for i, m in enumerate(self.methods)}
self.rev_method_index = {i: m for i, m in enumerate(self.methods)}
# previously: self.rev_method_index = {v: k for k, v in self.method_index.items()}
# self.rev_method_index = {v: k for k, v in self.method_index.items()}

# todo: get rid of the below
self.func_unit_translation_dict = {str(bw.get_activity(list(func_unit.keys())[0])): func_unit
for func_unit in self.func_units}
if len(self.func_unit_translation_dict) != len(self.func_units):
self.func_unit_translation_dict = {}
for fu in self.func_units:
act = bw.get_activity(next(iter(fu)))
self.func_unit_translation_dict["{} {}".format(act, act[0])] = fu
self.func_key_dict = {m: i for i, m in enumerate(self.func_unit_translation_dict.keys())}
self.func_key_list = list(self.func_key_dict.keys())

# GSA calculation variables
self.A_matrices = list()
Expand Down
20 changes: 10 additions & 10 deletions activity_browser/bwutils/multilca.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,17 +170,17 @@ def __init__(self, cs_name: str):
self.process_contributions = np.zeros(
(len(self.func_units), len(self.methods), self.lca.technosphere_matrix.shape[0]))

# TODO: get rid of the below
self.func_unit_translation_dict = {
str(bw.get_activity(list(func_unit.keys())[0])): func_unit for func_unit in self.func_units
}
if len(self.func_unit_translation_dict) != len(self.func_units):
self.func_unit_translation_dict = {}
for fu in self.func_units:
act = bw.get_activity(next(iter(fu)))
self.func_unit_translation_dict["{} {}".format(act, act[0])] = fu
name = 'name'
ref_prod = 'reference product'
db = 'database'
self.func_unit_translation_dict = {}
for fu in self.func_units:
key = next(iter(fu))
amt = fu[key]
act = bw.get_activity(key)
self.func_unit_translation_dict[f'{act[name]} | {act[ref_prod]} | {act[db]} | {amt}'] = fu
self.func_key_dict = {m: i for i, m in enumerate(self.func_unit_translation_dict.keys())}
self.func_key_list = list(self.func_key_dict.keys())
self.func_key_list = list(self.func_unit_translation_dict.keys())

def _construct_lca(self):
return bw.LCA(demand=self.func_units_dict, method=self.methods[0])
Expand Down

0 comments on commit 65d13b2

Please sign in to comment.