diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 169d720..d40e606 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,7 +27,7 @@ jobs: shell: bash run: | apt update - apt install -y libglu1-mesa + apt install -y libglu1-mesa libglib2.0-0 libfontconfig1 - uses: actions/checkout@v2 - diff --git a/openmc_plotter/docks.py b/openmc_plotter/docks.py index 1a4a11c..e63930e 100644 --- a/openmc_plotter/docks.py +++ b/openmc_plotter/docks.py @@ -412,7 +412,12 @@ def _bin_sort_val(bin): else: return bin - for bin in sorted(tally_filter.bins, key=_bin_sort_val): + if isinstance(tally_filter, openmc.EnergyFunctionFilter): + bins = [0] + else: + bins = tally_filter.bins + + for bin in sorted(bins, key=_bin_sort_val): item = QTreeWidgetItem(filter_item, [str(bin),]) if not spatial_filters: item.setFlags(QtCore.Qt.ItemIsUserCheckable) @@ -577,7 +582,11 @@ def updateFilters(self): filter_checked = f_item.checkState(0) if filter_checked != QtCore.Qt.Unchecked: selected_bins = [] - for idx, b in enumerate(f.bins): + if isinstance(f, openmc.EnergyFunctionFilter): + bins = [0] + else: + bins = f.bins + for idx, b in enumerate(bins): b = b if not isinstance(b, Iterable) else tuple(b) bin_checked = self.bin_map[(f, b)].checkState(0) if bin_checked == QtCore.Qt.Checked: diff --git a/openmc_plotter/plotmodel.py b/openmc_plotter/plotmodel.py index f9f5cc7..4cea483 100644 --- a/openmc_plotter/plotmodel.py +++ b/openmc_plotter/plotmodel.py @@ -1,8 +1,8 @@ +from ast import literal_eval from collections import defaultdict import copy import itertools import threading -from ast import literal_eval from PySide2.QtWidgets import QItemDelegate, QColorDialog, QLineEdit, QMessageBox from PySide2.QtCore import QAbstractTableModel, QModelIndex, Qt, QSize, QEvent @@ -503,20 +503,29 @@ def _do_op(array, tally_value, ax=0): # applied to the mesh filter lower_left = mesh.lower_left upper_right = mesh.upper_right + width = mesh.width + dimension = mesh.dimension if hasattr(mesh_filter, 'translation') and mesh_filter.translation is not None: lower_left += mesh_filter.translation upper_right += mesh_filter.translation + # For 2D meshes, add an extra z dimension + if len(mesh.dimension) == 2: + lower_left = np.hstack((lower_left, -1e50)) + upper_right = np.hstack((upper_right, 1e50)) + width = np.hstack((width, 2e50)) + dimension = np.hstack((dimension, 1)) + # reduce data to the visible slice of the mesh values - k = int((view.origin[ax] - lower_left[ax]) // mesh.width[ax]) + k = int((view.origin[ax] - lower_left[ax]) // width[ax]) # setup slice data_slice = [None, None, None] - data_slice[h_ind] = slice(mesh.dimension[h_ind]) - data_slice[v_ind] = slice(mesh.dimension[v_ind]) + data_slice[h_ind] = slice(dimension[h_ind]) + data_slice[v_ind] = slice(dimension[v_ind]) data_slice[ax] = k - if k < 0 or k > mesh.dimension[ax]: + if k < 0 or k > dimension[ax]: return (None, None, None, None) # move mesh axes to the end of the filters @@ -524,7 +533,7 @@ def _do_op(array, tally_value, ax=0): data = np.moveaxis(data, filter_idx, -1) # reshape data (with zyx ordering for mesh data) - data = data.reshape(data.shape[:-1] + tuple(mesh.dimension[::-1])) + data = data.reshape(data.shape[:-1] + tuple(dimension[::-1])) data = data[..., data_slice[2], data_slice[1], data_slice[0]] # sum over the rest of the tally filters diff --git a/pytest.ini b/pytest.ini index 818dfa8..af65033 100644 --- a/pytest.ini +++ b/pytest.ini @@ -2,5 +2,5 @@ qt_api=pyside2 python_files = test*.py python_classes = NoThanks -filter_warnings = ignore::UserWarning -addopts = -rs \ No newline at end of file +filterwarnings = ignore::UserWarning +addopts = -rs diff --git a/tests/setup_test/test.py b/tests/setup_test/test.py index f017d59..5a711d1 100644 --- a/tests/setup_test/test.py +++ b/tests/setup_test/test.py @@ -1,5 +1,3 @@ -import openmc.lib - from openmc_plotter.main_window import MainWindow, _openmcReload def test_window(qtbot):