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

Add vispy test #17

Merged
merged 19 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion .github/workflows/local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ jobs:
qt: "pyqt5"
- os: ubuntu-24.04
qt: "pyqt6"
- os: windows-latest
qt: "pyqt6"
- os: ubuntu-latest
qt: "pyside6"
runs-on: ${{ matrix.os }}
Expand All @@ -48,11 +50,24 @@ jobs:
if: matrix.qt != ''
run: |
set -eo pipefail
pip install ${{ matrix.qt }} matplotlib
pip install ${{ matrix.qt }} matplotlib qtpy
QT_DEBUG_PLUGINS=1 LIBGL_DEBUG=verbose python tests/test_qt.py
shell: bash
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os }}-${{ matrix.qt }}-cube
path: ${{ matrix.os }}-${{ matrix.qt }}-cube.png
if-no-files-found: error
- name: Test Vispy Qt
if: matrix.qt != ''
run: |
pip install vispy pillow pyopengl
python tests/test_vispy_qt.py
env:
MATRIX_OS: ${{ matrix.os }}
MATRIX_QT: ${{ matrix.qt }}
- uses: actions/upload-artifact@v4
if: matrix.qt != ''
with:
name: ${{ matrix.os }}-${{ matrix.qt }}-vispy-volume
path: ${{ matrix.os }}-${{ matrix.qt }}-vispy-volume.png
3 changes: 3 additions & 0 deletions tests/test_qt.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
plt.figure()
backend = matplotlib.get_backend()
assert backend == 'QtAgg', backend

from qtpy import QtDBus
_ = QtDBus.QDBusConnection('Name')
21 changes: 21 additions & 0 deletions tests/test_vispy_qt.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"""Quickly check if vispy off screen plotting works."""

import os
from pathlib import Path
import numpy as np
from qtpy.QtWidgets import QApplication
from vispy import scene
from PIL import Image

qapp = QApplication([])
canvas = scene.SceneCanvas(size=(512, 512))
view = canvas.central_widget.add_view()
np.random.seed(0)
vol_data = np.random.rand(64, 64, 64).astype(np.float32)
image = scene.visuals.Volume(vol_data, cmap="viridis", parent=view.scene)
view.camera = scene.ArcballCamera()
canvas.show()

fname = f'{os.environ['MATRIX_OS']}-{os.environ['MATRIX_QT']}-vispy-volume.png'
out_path = Path(__file__).parent.parent / fname
Image.fromarray(canvas.render()).save(out_path)