Skip to content

Quick fix for slider bug in interactive viewers #76

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

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
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
25 changes: 13 additions & 12 deletions .github/workflows/build-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
# Indicates the location of the vcpkg as a Git submodule of the project repository.
VCPKG_ROOT: ${{ github.workspace }}/external/LibAPR/vcpkg
CIBW_ENVIRONMENT_WINDOWS: EXTRA_CMAKE_ARGS="-DCMAKE_TOOLCHAIN_FILE=D:\\a\\pyapr\\pyapr\\external\\LibAPR\\vcpkg\\scripts\\buildsystems\\vcpkg.cmake -DVCPKG_MANIFEST_DIR=D:\\a\\pyapr\\pyapr\\external\\LibAPR\\"
CIBW_BUILD: "cp38-* cp39-* cp310-* cp311-*"
CIBW_BUILD: "cp38-* cp39-* cp310-* cp311-* cp312-*"
CIBW_SKIP: "*musllinux*"
CIBW_ARCHS: "auto64"
CIBW_BUILD_VERBOSITY: 1
Expand All @@ -55,7 +55,7 @@ jobs:
CIBW_TEST_COMMAND: "python3 -m pytest -vv {project}/pyapr/tests"
CIBW_TEST_SKIP: "*-win_amd64" # windows tests are run separately
CIBW_BEFORE_BUILD_LINUX: "yum makecache && yum install -y libtiff-devel hdf5-devel"
CIBW_ENVIRONMENT_MACOS: CPPFLAGS="-I/usr/local/opt/llvm/include" LDFLAGS="-L/usr/local/opt/llvm/lib -Wl,-rpath,/usr/local/opt/llvm/lib" CXX="/usr/local/opt/llvm/bin/clang++" CC="/usr/local/opt/llvm/bin/clang"
CIBW_ENVIRONMENT_MACOS: CPPFLAGS="-I/opt/homebrew/opt/llvm/include" LDFLAGS="-L/opt/homebrew/opt/llvm/lib" CXX="/opt/homebrew/opt/llvm/bin/clang++" CC="/opt/homebrew/opt/llvm/bin/clang" EXTRA_CMAKE_ARGS="-DCMAKE_PREFIX_PATH=/opt/homebrew/Cellar/libtiff/4.6.0;/opt/homebrew/opt/libomp"

steps:
- uses: actions/checkout@v4
Expand All @@ -72,7 +72,7 @@ jobs:
- uses: lukka/get-cmake@latest
# Restore both vcpkg and its artifacts from the GitHub cache service.
- name: Restore vcpkg and its artifacts.
uses: actions/cache@v3
uses: actions/cache@v4
with:
# The first path is where vcpkg generates artifacts while consuming the vcpkg.json manifest file.
# The second path is the location of vcpkg (it contains the vcpkg executable and data files).
Expand Down Expand Up @@ -101,10 +101,10 @@ jobs:
# On Windows runners, let's ensure to have the Developer Command Prompt environment setup correctly. As used here the Developer Command Prompt created is targeting x64 and using the default the Windows SDK.
- uses: ilammy/msvc-dev-cmd@v1

- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
name: Install Python
with:
python-version: '3.9'
python-version: '3.12'

- name: Install cibuildwheel
run: |
Expand All @@ -117,14 +117,15 @@ jobs:
brew install libomp
brew install c-blosc
brew install hdf5
brew reinstall libtiff

- name: Run cibuildwheel
run: |
git status
python3 -m cibuildwheel --output-dir ${{matrix.builddir}}

- name: Upload wheels as artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os }}-wheels
path: ${{matrix.builddir}}/
Expand All @@ -138,7 +139,7 @@ jobs:
fail-fast: false
matrix:
os: [ windows-latest ]
python-version: ['3.8', '3.9', '3.10', '3.11']
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']

steps:
- name: Checkout
Expand All @@ -147,12 +148,12 @@ jobs:
submodules: false

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Download wheels from artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: ${{ matrix.os }}-wheels
path: wheelhouse
Expand Down Expand Up @@ -182,14 +183,14 @@ jobs:
if: contains(github.ref, 'tags')
steps:
- name: Download wheels from artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
path: wheelhouse

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: '3.9'
python-version: '3.12'

- name: Install dependencies
run: |
Expand Down
20 changes: 19 additions & 1 deletion pyapr/data_containers/src/BindAPR.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,21 @@ namespace py = pybind11;

PYBIND11_MAKE_OPAQUE(std::vector<APR*>)


auto _get_y_vec = [](APR& apr) -> py::array {
return py::array_t<uint16>(apr.linearAccess.y_vec.size(), apr.linearAccess.y_vec.begin());
};

auto _get_xz_end_vec = [](APR& apr) -> py::array {
return py::array_t<uint64>(apr.linearAccess.xz_end_vec.size(), apr.linearAccess.xz_end_vec.begin());
};

auto _get_level_xz_vec = [](APR& apr) -> py::array {
return py::array_t<uint64>(apr.linearAccess.level_xz_vec.size(), apr.linearAccess.level_xz_vec.begin());
};



void AddAPR(pybind11::module &m, const std::string &modulename) {

using namespace py::literals;
Expand All @@ -38,7 +53,10 @@ void AddAPR(pybind11::module &m, const std::string &modulename) {
.def("org_dims", &APR::org_dims, "returns the original image size in a specified dimension (y, x, z)" , "dim"_a)
.def("shape", [](APR& self){return py::make_tuple(self.org_dims(2), self.org_dims(1), self.org_dims(0));}, "returns the original pixel image dimensions as a tuple (z, x, y)")
.def("get_parameters", &APR::get_apr_parameters, "return the parameters used to create the APR")
.def("computational_ratio", &APR::computational_ratio, "return the computational ratio (number of pixels in original image / number of particles in the APR)");
.def("computational_ratio", &APR::computational_ratio, "return the computational ratio (number of pixels in original image / number of particles in the APR)")
.def("get_y_vec", _get_y_vec, "return linearAccess y_vec as a numpy array")
.def("get_xz_end_vec", _get_xz_end_vec, "return linearAccess xz_end_vec as a numpy array")
.def("get_level_xz_vec", _get_level_xz_vec, "return linearAccess level_xz_vec as a numpy array");

py::bind_vector<std::vector<APR*>>(m, "APRPtrVector", py::module_local(false));
}
Expand Down
16 changes: 11 additions & 5 deletions pyapr/utils/filegui.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,19 @@ def setValue(self, value):
super(DoubleSlider, self).setValue(int(value * self._multi))

def setMinimum(self, value):
return super(DoubleSlider, self).setMinimum(value * self._multi)
# Convert the result to an integer to comply with the expected type
int_value = int(value * self._multi)
return super(DoubleSlider, self).setMinimum(int_value)

def setMaximum(self, value):
return super(DoubleSlider, self).setMaximum(value * self._multi)
# Convert the result to an integer to comply with the expected type
int_value = int(value * self._multi)
return super(DoubleSlider, self).setMaximum(int_value)

def setSingleStep(self, value):
return super(DoubleSlider, self).setSingleStep(value * self._multi)
# Convert the result to an integer to comply with the expected type
int_value = int(value * self._multi)
return super(DoubleSlider, self).setSingleStep(int_value)

def singleStep(self):
return float(super(DoubleSlider, self).singleStep()) / self._multi
Expand Down Expand Up @@ -116,7 +122,7 @@ def __init__(self, slider_decimals=0):

self.slider.valueChanged.connect(self.valuechange)

self.setGeometry(300, 300, self.full_size, self.full_size)
self.setGeometry(int(300), int(300), self.full_size, self.full_size)

self.layout.addWidget(self.slider, 1, 0)

Expand Down Expand Up @@ -352,7 +358,7 @@ def set_image(self, img, converter):
self.slider.setMinimum(0)
self.slider.setMaximum(self.z_num - 1)
self.slider.setTickPosition(QtWidgets.QSlider.TicksBothSides)
self.slider.setGeometry(0.05 * self.full_size, 0.97 * self.full_size, 0.95 * self.full_size, 40)
self.slider.setGeometry(int(0.05 * self.full_size), int(0.97 * self.full_size), int(0.95 * self.full_size), int(40))

self.setLUT('viridis')

Expand Down
2 changes: 1 addition & 1 deletion pyapr/viewer/compressInteractive.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def __init__(self):
self.slider_q.move(200, 70)
self.slider_q.connectSlider(self.valuechangeQ)
self.slider_q.maxBox.setValue(20)
self.slider_q.slider.setSingleStep(0.1)
self.slider_q.slider.setSingleStep(int(1))

self.slider_B = CustomSlider(self, "background")
self.slider_B.move(200, 100)
Expand Down
Loading