diff --git a/.github/workflows/build_installer.yaml b/.github/workflows/build_installer.yaml index 4ccea0b1..961bd3e5 100644 --- a/.github/workflows/build_installer.yaml +++ b/.github/workflows/build_installer.yaml @@ -92,7 +92,6 @@ jobs: run: | conda init bash conda activate rascal2 - conda install conda-forge::expat==2.7.3 if [ ${{ matrix.platform }} == "macos-14" ]; then ARCH="arm64" export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/Users/runner/hostedtoolcache/MATLAB/2023.2.999/arm64/MATLAB.app/bin/maca64 diff --git a/environment.yaml b/environment.yaml index dd2e4400..8c4b7310 100644 --- a/environment.yaml +++ b/environment.yaml @@ -6,6 +6,7 @@ dependencies: - python=3.10 - pip - llvm-openmp + - expat=2.7.3 - pip: - -r requirements.txt - -r requirements-dev.txt diff --git a/packaging/linux/build_installer.sh b/packaging/linux/build_installer.sh index 2c10dab8..8da36c0a 100644 --- a/packaging/linux/build_installer.sh +++ b/packaging/linux/build_installer.sh @@ -121,12 +121,13 @@ echo "" wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O "$TMP_DIR/miniconda.sh" bash ./miniconda.sh -b -p ./miniconda ./miniconda/bin/conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/main --channel https://repo.anaconda.com/pkgs/r -./miniconda/bin/conda create -n rascal_builder -y python=3.10 +./miniconda/bin/conda create -n rascal_builder -y python=3.10 expat=2.7.3 echo "" echo "Downloading Dependencies" echo "" python_exec="./miniconda/envs/rascal_builder/bin/python" +mv "$TMP_DIR/rascal/wheels" "wheels" mkdir "$TMP_DIR/packages" $python_exec -m pip download -r "./rascal/requirements.txt" --dest "$TMP_DIR/packages" @@ -135,9 +136,6 @@ if [ -z "$NOMATLAB" ]; then $python_exec -m pip install matlabengine==9.14.* fi -# workaround for centos 7 -#$python_exec -m pip download --only-binary=":all:" --platform="manylinux_2_17_x86_64" --dest "$TMP_DIR/packages" pillow==9.2 - echo "" echo "Compressing Package.tar.gz ..." echo "" @@ -145,7 +143,7 @@ echo "" STAGE_DIR="$TMP_DIR/stage" mkdir "$STAGE_DIR" -mv -t "$STAGE_DIR" "rascal" "miniconda/envs" "packages" +mv -t "$STAGE_DIR" "rascal" "miniconda/envs" "packages" "wheels" chmod 777 "$STAGE_DIR/rascal/packaging/linux/install.sh" echo "" diff --git a/rascal2/widgets/plot.py b/rascal2/widgets/plot.py index 67bd34a3..67cb4f61 100644 --- a/rascal2/widgets/plot.py +++ b/rascal2/widgets/plot.py @@ -94,6 +94,7 @@ def __init__(self, parent): self.add_tab(plot_type, plot_widget) self.sync_and_update_model() + self.plot_tabs.addTab(self.create_confidence_table(), "Parameter values") layout.addWidget(self.plot_tabs) self.setLayout(layout) self.setModal(True) @@ -101,6 +102,38 @@ def __init__(self, parent): self.setWindowTitle("Bayes Results") self.plot_tabs.currentChanged.connect(self.redraw_panel_plot) + def create_confidence_table(self): + """Create table to display the confidence intervals.""" + results = self.parent.presenter.model.results + if results is None: + return + + table = QtWidgets.QTableWidget() + table.setColumnCount(4) + table.setRowCount(len(results.fitNames)) + table.setHorizontalHeaderLabels(["Parameter", "Mean", "95% CI", "65% CI"]) + table.horizontalHeader().setSectionResizeMode(QtWidgets.QHeaderView.ResizeMode.Stretch) + table.verticalHeader().hide() + + ci = results.confidenceIntervals + for i, name in enumerate(results.fitNames): + table.setItem(i, 0, QtWidgets.QTableWidgetItem(name)) + item1 = QtWidgets.QTableWidgetItem(f"{ci.mean[0][i]:g}") + item1.setTextAlignment(QtCore.Qt.AlignmentFlag.AlignHCenter) + table.setItem(i, 1, item1) + + item2 = QtWidgets.QTableWidgetItem(f"[{ci.percentile95[0][i]:g}, {ci.percentile95[1][i]:g}]") + item2.setTextAlignment(QtCore.Qt.AlignmentFlag.AlignHCenter) + table.setItem(i, 2, item2) + + item3 = QtWidgets.QTableWidgetItem(f"[{ci.percentile65[0][i]:g}, {ci.percentile65[1][i]:g}]") + item3.setTextAlignment(QtCore.Qt.AlignmentFlag.AlignHCenter) + table.setItem(i, 3, item3) + + table.resizeColumnsToContents() + + return table + def add_tab(self, plot_type: str, plot_widget: "AbstractPlotWidget"): """Add a widget as a tab to the plot widget. @@ -233,6 +266,7 @@ def __init__(self, parent): self.setMinimumSize(500, 300) scroll_area = QtWidgets.QScrollArea(self) + scroll_area.viewport().setAutoFillBackground(False) scroll_area.setWidget(self.canvas) scroll_area.setWidgetResizable(True) @@ -323,7 +357,10 @@ def make_figure(self) -> matplotlib.figure.Figure: The figure to plot onto. """ - return matplotlib.figure.Figure(figsize=(9, 6)) + figure = matplotlib.figure.Figure(figsize=(9, 6)) + figure.set_tight_layout(True) + figure.set_tight_layout({"pad": 0.01, "w_pad": 0.5}) + return figure @abstractmethod def plot(self, project: ratapi.Project, results: ratapi.outputs.Results | ratapi.outputs.BayesResults): @@ -388,19 +425,17 @@ def make_toolbar_widget(self): self.slider = QtWidgets.QSlider(QtCore.Qt.Orientation.Vertical) self.slider.setTracking(False) self.slider.setInvertedAppearance(True) - self.slider.setMinimum(1) + self.slider.setMinimum(0) self.slider.setMaximum(100) - self.slider.setValue(1) + self.slider.setValue(0) self.slider.valueChanged.connect(self.handle_control_changed) return self.slider def make_figure(self) -> matplotlib.figure.Figure: self.resize_timer = 0 - figure = matplotlib.figure.Figure() + figure = super().make_figure() figure.subplots(1, 2) - figure.set_tight_layout(True) - figure.set_tight_layout({"pad": 0, "w_pad": 0.5}) return figure @@ -607,6 +642,18 @@ def make_control_layout(self): return layout + def make_figure(self) -> matplotlib.figure.Figure: + """Make the figure to plot onto. + + Returns + ------- + Figure + The figure to plot onto. + + """ + figure = matplotlib.figure.Figure(figsize=(9, 6)) + return figure + def make_interaction_layout(self): """Make layout with pan, zoom, and reset button.""" diff --git a/requirements.txt b/requirements.txt index 1fc5bca6..7b1745ff 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,10 @@ PyInstaller==6.9.0 PyQt6==6.7.1 PyQt6-Qt6==6.7.3 -ratapi==0.0.0.dev13 +./wheels/ratapi-0.0.0.dev13-cp310-cp310-win_amd64.whl; sys_platform == 'win32' +./wheels/ratapi-0.0.0.dev13-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl; sys_platform == 'linux' +./wheels/ratapi-0.0.0.dev13-cp310-cp310-macosx_14_0_x86_64.whl; sys_platform == 'darwin' and platform_machine == 'i386' +./wheels/ratapi-0.0.0.dev13-cp310-cp310-macosx_14_0_arm64.whl; sys_platform == 'darwin' and platform_machine != 'i386' pydantic==2.8.2 PyQt6-QScintilla==2.14.1 nexusformat==1.0.7 diff --git a/tests/widgets/test_plot.py b/tests/widgets/test_plot.py index ef52ca7a..49ff3e95 100644 --- a/tests/widgets/test_plot.py +++ b/tests/widgets/test_plot.py @@ -123,7 +123,7 @@ def test_ref_sld_plot_event(mock_plot_sld, sld_widget): show_error_bar=True, show_grid=False, show_legend=True, - shift_value=1, + shift_value=0, ) sld_widget.canvas.draw.assert_called_once() data.contrastNames = [] @@ -137,7 +137,7 @@ def test_ref_sld_plot_event(mock_plot_sld, sld_widget): show_error_bar=True, show_grid=False, show_legend=False, - shift_value=1, + shift_value=0, ) data.contrastNames = ["Hello"] sld_widget.x_axis.setCurrentText("Linear") @@ -154,7 +154,7 @@ def test_ref_sld_plot_event(mock_plot_sld, sld_widget): show_error_bar=False, show_grid=True, show_legend=False, - shift_value=1, + shift_value=0, ) diff --git a/wheels/ratapi-0.0.0.dev13-cp310-cp310-macosx_14_0_arm64.whl b/wheels/ratapi-0.0.0.dev13-cp310-cp310-macosx_14_0_arm64.whl new file mode 100644 index 00000000..00cfc94f Binary files /dev/null and b/wheels/ratapi-0.0.0.dev13-cp310-cp310-macosx_14_0_arm64.whl differ diff --git a/wheels/ratapi-0.0.0.dev13-cp310-cp310-macosx_14_0_x86_64.whl b/wheels/ratapi-0.0.0.dev13-cp310-cp310-macosx_14_0_x86_64.whl new file mode 100644 index 00000000..748df189 Binary files /dev/null and b/wheels/ratapi-0.0.0.dev13-cp310-cp310-macosx_14_0_x86_64.whl differ diff --git a/wheels/ratapi-0.0.0.dev13-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl b/wheels/ratapi-0.0.0.dev13-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl new file mode 100644 index 00000000..c9f2f49b Binary files /dev/null and b/wheels/ratapi-0.0.0.dev13-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl differ diff --git a/wheels/ratapi-0.0.0.dev13-cp310-cp310-win_amd64.whl b/wheels/ratapi-0.0.0.dev13-cp310-cp310-win_amd64.whl new file mode 100644 index 00000000..8fb512be Binary files /dev/null and b/wheels/ratapi-0.0.0.dev13-cp310-cp310-win_amd64.whl differ