Skip to content

Commit

Permalink
Merge branch 'master' into settings-rework
Browse files Browse the repository at this point in the history
# Conflicts:
#	activity_browser/app/ui/tabs/activity.py
  • Loading branch information
dgdekoning committed Jul 31, 2019
2 parents bdf8186 + 9eaed7a commit 6a68431
Show file tree
Hide file tree
Showing 10 changed files with 92 additions and 25 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ matrix:
include:
- python: "3.6"
os: linux
env: VERSION=2.3.1.dev PKG_NAME=activity-browser-dev
env: VERSION=2.3.2.dev PKG_NAME=activity-browser-dev
- python: "3.7"
language: generic-covered
os: osx
env: pyver=3.7 VERSION=2.3.1.dev PKG_NAME=activity-browser-dev
env: pyver=3.7 VERSION=2.3.2.dev PKG_NAME=activity-browser-dev

before_install:
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then
Expand Down
21 changes: 17 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,26 @@

## [Unreleased]

## [2.3.2] - 2019-07-03

### Added

- It is now possible to unpack tuple columns in the `MetaDataStore`, creating additional columns.
- It is now possible to unpack tuple columns in the `MetaDataStore`, creating additional columns. ([#237](https://github.com/LCA-ActivityBrowser/activity-browser/pull/237))
- The results in the elementary flows and process contributions tabs can now be aggregated by their relevant columns. ([#239](https://github.com/LCA-ActivityBrowser/activity-browser/pull/239))
- This changelog file! ([#240](https://github.com/LCA-ActivityBrowser/activity-browser/pull/240))

### Changed

- Documented `MLCA` and `Contributions` classes according to [numpydoc](https://numpydoc.readthedocs.io/en/latest/) standards.
- Importing the `biosphere3` database now casts all `categories` values to tuples.
- Added methods to `MetaDataStore` class to simplify handling of the dataframe object inside.
- Documented `MLCA` and `Contributions` classes according to [numpydoc](https://numpydoc.readthedocs.io/en/latest/) standards. ([#236](https://github.com/LCA-ActivityBrowser/activity-browser/pull/236))
- Importing the `biosphere3` database now casts all `categories` values to tuples. ([07a1cc3 in #237](https://github.com/LCA-ActivityBrowser/activity-browser/pull/237/commits/07a1cc381afe1ddfb8c97f54f7fc98af55dbedd3))
- Added methods to `MetaDataStore` class to simplify handling of the dataframe object inside. ([f95483c in #236](https://github.com/LCA-ActivityBrowser/activity-browser/pull/236/commits/f95483c03f216765f15def5ec7bce898a834b6a3))

### Fixed

- Cleaning up removed project directories ([#194](https://github.com/LCA-ActivityBrowser/activity-browser/issues/194), [#198](https://github.com/LCA-ActivityBrowser/activity-browser/pull/198)) can now be done by running the `activity-browser-cleanup` command in the anaconda prompt.
- Removed the line in the README file recommending people use the development version. Strip 'development' line from the recipe yaml when building a stable version. ([#241](https://github.com/LCA-ActivityBrowser/activity-browser/pull/241))
- Added method to `ProjectSettings` class to ensure the `read-only-databases` key is always present in the settings ([#235](https://github.com/LCA-ActivityBrowser/activity-browser/issues/235), [#242](https://github.com/LCA-ActivityBrowser/activity-browser/pull/242)). This fix also includes adding methods and calls to ensure new databases are added to- and removed from the settings.
- Allow users to add all (default) biosphere types to an activity instead of only exchanges of type 'emission'. ([#244](https://github.com/LCA-ActivityBrowser/activity-browser/pull/244))

## [2.3.1] - 2019-04-15

Expand All @@ -28,3 +35,9 @@

- Major overhaul of the GUI. See [#218](https://github.com/LCA-ActivityBrowser/activity-browser/pull/218) for details.
- New conda stable and development builds (`activity-browser`, `activity-browser-dev`) can now be found in the `bsteubing` [channel](https://anaconda.org/bsteubing/).


[Unreleased]: https://github.com/LCA-ActivityBrowser/activity-browser/compare/2.3.2...HEAD
[2.3.2]: https://github.com/LCA-ActivityBrowser/activity-browser/compare/2.3.1...2.3.2
[2.3.1]: https://github.com/LCA-ActivityBrowser/activity-browser/compare/2.3.0...2.3.1
[2.3.0]: https://github.com/LCA-ActivityBrowser/activity-browser/compare/2.2.5...2.3.0
27 changes: 19 additions & 8 deletions activity_browser/app/ui/tabs/LCA_results_tabs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
QScrollArea, QRadioButton, QLabel, QCheckBox, QPushButton, QComboBox)
from PyQt5 import QtGui, QtWidgets, QtCore

from stats_arrays.errors import InvalidParamsError

from ..style import horizontal_line, vertical_line, header
from ..tables import (
LCAResultsTable,
Expand Down Expand Up @@ -94,7 +96,12 @@ def do_calculations(self):
""" Update the mlca calculation. """
self.mlca = MLCA(self.cs_name)
self.contributions = Contributions(self.mlca)
self.mc = CSMonteCarloLCA(self.cs_name)
try:
self.mc = CSMonteCarloLCA(self.cs_name)
except InvalidParamsError as e:
# This can occur if uncertainty data is missing or otherwise broken
print(e)
self.mc = None
# self.mct = CSMonteCarloLCAThread()
# self.mct.start()
# self.mct.initialize(self.cs_name)
Expand All @@ -121,8 +128,9 @@ def setup_tabs(self):
self.process_contributions_tab = ProcessContributionsTab(self, relativity=True)
self.process_contributions_tab.update_analysis_tab()

self.monte_carlo_tab = MonteCarloTab(self)
self.monte_carlo_tab.update_tab()
if self.mc:
self.monte_carlo_tab = MonteCarloTab(self)
self.monte_carlo_tab.update_tab()

# self.correlations_tab = CorrelationsTab(self)
# self.correlations_tab.update_analysis_tab()
Expand Down Expand Up @@ -210,22 +218,25 @@ def combo_switch_check(self):
self.update_combobox()

def main_space_check(self, table_ch, plot_ch):
""" Show only table or graph, whichever is selected. """
""" Show graph and/or table, whichever is selected.
Can also hide both, if you want to do that.
"""
table_state = table_ch.isChecked()
plot_state = plot_ch.isChecked()

if table_state and plot_state:
self.main_space_table.setVisible(True)
self.main_space_plot.setVisible(True)

elif not table_state and plot_state:
self.main_space_table.setVisible(False)
self.main_space_plot.setVisible(True)

else:
self.main_space_tb_grph_table.setChecked(True)
elif table_state and not plot_state:
self.main_space_table.setVisible(True)
self.main_space_plot.setVisible(False)
else:
self.main_space_table.setVisible(False)
self.main_space_plot.setVisible(False)

def add_main_space(self):
""" Add the main space to the tab. """
Expand Down
10 changes: 7 additions & 3 deletions activity_browser/app/ui/tabs/activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from PyQt5 import QtCore, QtWidgets, QtGui

from ..style import style_activity_tab
from ..tables import ExchangeTable #, ProductTable
from ..tables import ExchangeTable
from ..widgets import ActivityDataGrid, DetailsGroupBox, SignalledPlainTextEdit
from ..panels import ABTab
from ..icons import icons
Expand All @@ -26,12 +26,16 @@ def connect_signals(self):
signals.delete_activity.connect(self.close_tab_by_tab_name)
signals.project_selected.connect(self.close_all)

def open_activity_tab(self, key):
@QtCore.pyqtSlot(tuple)
def open_activity_tab(self, key: tuple) -> None:
"""Opens new tab or focuses on already open one."""
if key not in self.tabs:
act = bw.get_activity(key)
if not act.production():
return
new_tab = ActivityTab(key, parent=self)
self.tabs[key] = new_tab
self.addTab(new_tab, bc.get_activity_name(bw.get_activity(key), str_length=30))
self.addTab(new_tab, bc.get_activity_name(act, str_length=30))

# hovering on the tab shows the full name, in case it's truncated in the tabbar at the top
# new_tab.setToolTip(bw.get_activity(key).as_dict()['name'])
Expand Down
5 changes: 3 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Using multiple examples:
# https://github.com/Anaconda-Platform/anaconda-project/blob/master/appveyor.yml
# https://github.com/AnacondaRecipes/conda-feedstock/blob/master/appveyor.yml
# https://github.com/AnacondaRecipes/conda-feedstock/blob/master/.appveyor.yml
build: "off"

environment:
Expand All @@ -17,7 +17,8 @@ install:
- conda update -q conda
- conda info -a
# Install package requirements & test suite
- conda install -q -c defaults -c conda-forge -c cmutel -c haasad arrow brightway2 bw2io bw2data eidl fuzzywuzzy matplotlib networkx pandas "pyqt==5.9.2" seaborn "pytest<3.5" pytest-qt pytest-mock
# Do not use the conda-forge pytest version 3.2.2, it includes an old version of pluggy which breaks the test.
- conda install -q -c defaults -c conda-forge -c cmutel -c haasad arrow brightway2 bw2io bw2data eidl fuzzywuzzy matplotlib networkx pandas "pyqt==5.9.2" seaborn "pytest>3.2.2,<3.5" pytest-qt pytest-mock

test_script:
- python -m pytest
1 change: 1 addition & 0 deletions ci/conda_upload.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ if [ "$TRAVIS_OS_NAME" == "linux" ]; then
else
export PKG_NAME="activity-browser"
export VERSION="$TRAVIS_TAG"
export SUMMARY="GUI for brightway2"
BUILD_ARGS=""
UPLOAD_ARGS=""
# Strip the last sentence (as this is the stable version) out of the meta.yaml file.
Expand Down
4 changes: 2 additions & 2 deletions ci/travis/recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ build:
- VERSION
- CONDA_BLD_PATH
entry_points:
- activity-browser = activity_browser.app:run_activity_browser
- activity-browser = activity_browser.app:run_activity_browser
- activity-browser-cleanup = activity_browser.app.bwutils:cleanup

requirements:
Expand All @@ -40,7 +40,7 @@ about:
license: GPL3+
license_family: GPL3
license_file: LICENSE
summary: Development version of the Activity Browser
summary: "{{ os.environ.get('SUMMARY', 'Development version of the Activity Browser') }}"
description: |
The Activity Browser is a graphical user interface for the [brightway2](https://brightwaylca.org/)
advanced life cycle assessment framework. More details and installation instructions can be found
Expand Down
6 changes: 3 additions & 3 deletions recipe/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Used https://github.com/conda-forge/staged-recipes/blob/master/recipes/example/meta.yaml as example
{% set version = "2.3.1" %}
{% set version = "2.3.2" %}

package:
name: activity-browser
Expand All @@ -15,7 +15,7 @@ build:
number: 0
script: "{{ PYTHON }} setup.py install --single-version-externally-managed --record record.txt"
entry_points:
- activity-browser = activity_browser.app:run_activity_browser
- activity-browser = activity_browser.app:run_activity_browser
- activity-browser-cleanup = activity_browser.app.bwutils:cleanup

requirements:
Expand Down Expand Up @@ -44,5 +44,5 @@ about:
summary: GUI for brightway2
description: |
The Activity Browser is a graphical user interface for the [brightway2](https://brightwaylca.org/)
advanced life cycle assessment framework. More details and installation instructions can be found
advanced life cycle assessment framework. More details and installation instructions can be found
on [github](https://github.com/LCA-ActivityBrowser/activity-browser).
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

setup(
name='activity-browser',
version="2.3.1",
version="2.3.2",
packages=packages,
include_package_data=True,
author="Bernhard Steubing",
Expand Down
37 changes: 37 additions & 0 deletions tests/test_add_default_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,40 @@ def test_search_biosphere(qtbot, ab_app):
act_bio_widget.search_box.returnPressed.emit()
assert act_bio_widget.table.dataframe.shape[0] > 0
# assert search_results < currently_displayed


def test_fail_open_biosphere(ab_app):
""" Specifically fail to open an activity tab for a biosphere flow
"""
assert bw.projects.current == "pytest_project"
activities_tab = ab_app.main_window.right_panel.tabs["Activities"]
# Select any biosphere activity and emit signal to trigger opening the tab
biosphere_flow = bw.Database("biosphere3").random()
signals.open_activity_tab.emit(biosphere_flow.key)
assert len(activities_tab.tabs) == 0


def test_succceed_open_activity(ab_app):
""" Create a tiny test database with a production activity
"""
assert bw.projects.current == "pytest_project"
db = bw.Database("testdb")
act_key = ("testdb", "act1")
db.write({
act_key: {
"name": "act1",
"unit": "kilogram",
"exchanges": [
{"input": act_key, "amount": 1, "type": "production"}
]
}
})
activities_tab = ab_app.main_window.right_panel.tabs["Activities"]
# Select the activity and emit signal to trigger opening the tab
act = bw.get_activity(act_key)
signals.open_activity_tab.emit(act_key)
assert len(activities_tab.tabs) == 1
assert act_key in activities_tab.tabs
# Current index of QTabWidget is changed by opening the tab
index = activities_tab.currentIndex()
assert act.get("name") == activities_tab.tabText(index)

0 comments on commit 6a68431

Please sign in to comment.