Skip to content

Commit 337a0ec

Browse files
authored
Add ptu support and pyproject.toml, deprecate cython (#213)
A user requested the ability to load ptu (t2) files from a PicoQuant PicoHarp. The test suite covers HydraHarp (t2, t3) and PicoHarp (t2) but the code should be as general as the underlying ptufile package. In the process of setting this up I debugged a bit and made a few changes: * rewrite fib4.pyx as fib4.py, which deprecates cython * bump minimum Python version to 3.11 to support ptufile * migrated from setup.py to pyproject.toml (tested on Linux) * set up tox.ini for running the test suite * set up ruff, ty, and codespell placeholders for gradual linting (remove the exclusions as desired) * fix some stray numpy bugs (np.float_ deprecation) * remove distutils due to deprecation in Python 3.12 * do version generation through setuptools_scm * ensure the test suite fully passes for all versions supported * ensure the CI check stage works up through testing Deprecating cython There was only one function that required cython. I have replaced it with a pure numpy implementation that seems to perform equivalently and gets the same results for both random and test data. In tests/test_file_format.py:test_pt3_basic the behavior is the same as before (expected 2037 is actually 2037.5) but I have no insight as to why that happened in the first place. The correlation data (last two lines of that test) pass on my machine though. So all I can say is that no observable behavior has changed for loading pt3 or running dividAndConquer, not that the trace value is actually correct.
1 parent 1d2d91b commit 337a0ec

31 files changed

+459
-446
lines changed

.github/workflows/check.yml

Lines changed: 66 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
runs-on: ${{ matrix.os }}
1515
strategy:
1616
matrix:
17-
python-version: ['3.10']
17+
python-version: ['3.11']
1818
os: [macos-latest, ubuntu-latest, windows-latest]
1919
env:
2020
# Display must be available globally for linux to know where xvfb is
@@ -27,11 +27,32 @@ jobs:
2727
uses: actions/setup-python@v3
2828
with:
2929
python-version: ${{ matrix.python-version }}
30+
# building on macos results in a long run due to having to build the font cache
31+
- name: Cache Matplotlib font cache
32+
uses: actions/cache@v3
33+
with:
34+
path: ~/.cache/matplotlib
35+
key: ${{ runner.os }}-matplotlib-${{ hashFiles('pyproject.toml') }}
36+
restore-keys: |
37+
${{ runner.os }}-matplotlib-
3038
- name: Setup xvfb (Linux)
3139
if: runner.os == 'Linux'
3240
run: |
3341
sudo apt-get update
34-
sudo apt-get install -y xvfb libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-xinput0 libxcb-xfixes0 libegl1-mesa
42+
sudo apt-get install -y \
43+
xvfb \
44+
libxkbcommon-x11-0 \
45+
libxcb-icccm4 \
46+
libxcb-image0 \
47+
libxcb-keysyms1 \
48+
libxcb-randr0 \
49+
libxcb-render-util0 \
50+
libxcb-xinerama0 \
51+
libxcb-xinput0 \
52+
libxcb-xfixes0 \
53+
libegl1 \
54+
libegl-mesa0 \
55+
libgl1-mesa-dri
3556
# start xvfb in the background
3657
sudo /usr/bin/Xvfb $DISPLAY -screen 0 1280x1024x24 &
3758
- name: Install dependencies
@@ -44,37 +65,51 @@ jobs:
4465
pip install -e .
4566
# show installed packages
4667
pip freeze
68+
# - name: Install large dependencies (Linux)
69+
# if: runner.os == 'Linux'
70+
# run: |
71+
# pip install -U -f https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-24.04 wxPython
72+
# pip install .[GUI]
73+
# - name: Install large dependencies (macOS)
74+
# if: runner.os == 'macOS'
75+
# run: |
76+
# pip install -U -f https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-24.04 wxPython
77+
# pip install --prefer-binary matplotlib
78+
# pip install .[GUI]
79+
# - name: Install large dependencies (Windows)
80+
# if: runner.os == 'windows'
81+
# run: |
82+
# pip install .[GUI]
4783
- name: Test
4884
run: |
4985
coverage run --source=pycorrfit -m pytest tests
5086
- name: Upload coverage to Codecov
5187
uses: codecov/codecov-action@v3
52-
- name: Create app and check if it runs (macOS)
53-
if: runner.os == 'macOS'
54-
working-directory: ./build-recipes
55-
run: |
56-
bash ./macos_build_app.sh PyCorrFit $(python -m pycorrfit --version)
57-
- name: Upload build artifacts
58-
if: (runner.os == 'macOS')
59-
uses: actions/upload-artifact@v3
60-
with:
61-
name: PyCorrFit_macosx
62-
path: |
63-
./build-recipes/dist/*.dmg
64-
65-
- name: Create app and check if it runs (Win)
66-
if: runner.os == 'windows'
67-
working-directory: ./build-recipes
68-
run: |
69-
pip install -r win_build_requirements.txt
70-
pyinstaller -y --log-level=WARN win_PyCorrFit.spec
71-
.\dist\PyCorrFit\PyCorrFit.exe --version
72-
python win_make_iss.py
73-
iscc /Q win_bmicro.iss
74-
- name: Upload build artifacts
75-
if: (runner.os == 'windows')
76-
uses: actions/upload-artifact@v3
77-
with:
78-
name: PyCorrFit
79-
path: |
80-
./build-recipes/Output/*.exe
88+
# - name: Create app and check if it runs (macOS)
89+
# if: runner.os == 'macOS'
90+
# working-directory: ./build-recipes
91+
# run: |
92+
# bash ./macos_build_app.sh PyCorrFit $(python -m pycorrfit --version)
93+
# - name: Upload build artifacts
94+
# if: (runner.os == 'macOS')
95+
# uses: actions/upload-artifact@v4
96+
# with:
97+
# name: PyCorrFit_macosx
98+
# path: |
99+
# ./build-recipes/dist/*.dmg
100+
# - name: Create app and check if it runs (Win)
101+
# if: runner.os == 'windows'
102+
# working-directory: ./build-recipes
103+
# run: |
104+
# pip install -r win_build_requirements.txt
105+
# pyinstaller -y --log-level=WARN win_PyCorrFit.spec
106+
# .\dist\PyCorrFit\PyCorrFit.exe --version
107+
# python win_make_iss.py
108+
# iscc /Q win_bmicro.iss
109+
# - name: Upload build artifacts
110+
# if: (runner.os == 'windows')
111+
# uses: actions/upload-artifact@v4
112+
# with:
113+
# name: PyCorrFit
114+
# path: |
115+
# ./build-recipes/Output/*.exe

.github/workflows/deploy_github.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
runs-on: ${{ matrix.os }}
1212
strategy:
1313
matrix:
14-
python-version: ['3.10']
14+
python-version: ['3.11']
1515
os: [macos-latest, windows-latest]
1616
steps:
1717
- uses: actions/checkout@v3
@@ -20,7 +20,7 @@ jobs:
2020
- name: Set up Python
2121
uses: actions/setup-python@v3
2222
with:
23-
python-version: "3.10"
23+
python-version: "3.11"
2424
- name: Install dependencies
2525
run: |
2626
python -m pip install --upgrade pip

.github/workflows/deploy_pypi.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
runs-on: ${{ matrix.os }}
1212
strategy:
1313
matrix:
14-
python-version: ['3.10']
14+
python-version: ['3.11']
1515
os: [macos-latest, windows-latest]
1616
steps:
1717
- uses: actions/checkout@v3

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ nosetests.xml
7777
tests/data
7878

7979
.cache
80+
__pycache__
8081
.eggs
8182
.env
8283

@@ -86,3 +87,6 @@ docs/_build
8687

8788
# pycharm
8889
.idea
90+
91+
_version.py
92+
*.swp

CHANGELOG

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
[unreleased]
2+
- enh: add support for PicoQuant ptu file format
3+
- setup: drop support for Python <3.11 (due to ptufile)
4+
- tests: set up tox for all supported python version
5+
- tests: add placeholder ruff/ty/codespell configuration for gradual improvements
6+
- enh: deprecate cython
17
1.2.1
28
- fix: compatibility with newer versions of scipy (#211)
39
1.2.0

CONTRIBUTING.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Quickstart
2+
3+
```
4+
uv build
5+
```
6+
7+
Running tests:
8+
9+
```
10+
uv tool install tox --with tox-uv
11+
uvx tox
12+
```

MANIFEST.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ recursive-include examples *.txt *.pcfs
55
recursive-include doc *.tex *.bib *.pdf *.md *.png *.svg
66
recursive-include docs *.py *.md *.txt *.rst *.bib *.gif *.jpg *.png
77
recursive-include tests *.py *.md
8-
recursive-include pycorrfit LICENCE README
8+
recursive-include pycorrfit LICENSE README
99
prune docs/_build
1010
exclude docs/_version_save.py
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pyinstaller

pycorrfit/__init__.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,21 @@
22
PyCorrFit is a tool to fit fluorescence correlation spectroscopy
33
data on a logarithmic scale.
44
"""
5-
from . import meta
6-
from . import models
7-
from . import openfile
8-
from . import readfiles
95

6+
from importlib.metadata import PackageNotFoundError, version
7+
8+
from . import meta, models, openfile, readfiles
109
from .correlation import Correlation
1110
from .fit import Fit
1211
from .trace import Trace
13-
from ._version import version as __version__
1412

15-
__author__ = u"Paul Müller"
13+
try:
14+
__version__ = version("pycorrfit")
15+
except PackageNotFoundError:
16+
# package is not installed
17+
__version__ = "unknown"
18+
19+
20+
__author__ = "Paul Müller"
1621
__license__ = "GPL v2"
22+
__all__ = ["meta", "models", "openfile", "readfiles", "Fit", "Trace", "Correlation"]

0 commit comments

Comments
 (0)