Repository navigation
Run on numpy 2 and current TensorFlow, without changing what main's users get - #17
Merged
Merged
Conversation
- io.h5.load: read the result with h5py; hdfdict does not import with numpy >= 2 (numpy.string_) - drop the unused tkinter imports: tkinter is missing from many Python builds and crashes when used off the main thread on macOS - np.product -> np.prod (removed in numpy 2) - Fitter: cast the target rois to float32; under NEP 50 subtracting a numpy float64 scalar no longer keeps them float32, and TensorFlow refuses the mixed dtypes - iterlearn_psf: float() of a one-element stage position array - setup.py: tensorflow>=2.9 instead of the 2.9.1 pin, h5py and pillow declared, subpackages included Tested with Python 3.12, numpy 2, TensorFlow 2.21 (CPU): bead learning (zernike_vector, single channel) and in situ learning run end to end. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GiNdULxyiqQEqWHGKTbVzV
…hift - PSFMultiChannel*: the variables' weights are float32; under numpy 2 a float64 numpy scalar times a float32 tensor is refused by TensorFlow - channel_shift (config_base/config_user, default []): a known [y, x] shift per channel, target minus reference, used instead of the search from bead coordinates, which on a regular grid of beads can pair each bead with its neighbour Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GiNdULxyiqQEqWHGKTbVzV
…ing uiPSF tensorflow-probability needs tf-keras with TensorFlow >= 2.16 (Keras 3); the [tf] extra installs it. Checked in a fresh Python 3.12 venv: pip install -e . then learning a bead PSF end to end. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GiNdULxyiqQEqWHGKTbVzV
…hannel_shift - setup.py: Python 3.7 (environment.yml) installs exactly tensorflow 2.9.1 and tensorflow-probability 0.17, as before; Windows on Python 3.8-3.10 stays below TensorFlow 2.11, the last with native GPU support, with numpy < 1.24; only elsewhere (Linux, macOS, Windows on 3.11+, which TensorFlow 2.10 does not support) does it allow current TensorFlow - channel_shift removed again (psflearninglib, config_base, config_user): smappy sets the shift from its own worker instead, so uiPSF needs no new parameter Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GiNdULxyiqQEqWHGKTbVzV
jries
pushed a commit
to ries-lab/SMAPpy
that referenced
this pull request
Oct 7, 2026
The page's install line clones uiPSF's main rather than the branch of ries-lab/uiPSF#17, which is to be merged first; NOTES.md speaks of #17 rather than of the branch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GiNdULxyiqQEqWHGKTbVzV
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Makes uiPSF run on numpy 2 and current TensorFlow (tried: Python 3.12, numpy 2, TensorFlow 2.21, CPU, including Apple-silicon-capable versions), so it can be installed on current Macs and driven from SMAPpy (ries-lab/SMAPpy#5). The aim is to leave existing users exactly where they are: the same installs where they were pinned, and the same results.
Changes (11 files, +50 / −23)
io/h5.py:loadreads the result with h5py instead ofhdfdict, which does not import with numpy ≥ 2 (numpy.string_). It returns the same nestedDottedDict, and closes the file.np.product→np.prod.iterlearn_psftakes element 0 of the one-element stage position beforefloat().tkinter: the unused imports are removed (every use was already commented out). tkinter is missing from many Python builds, and on macOS it crashes off the main thread.setup.py: the TensorFlow requirement now depends on platform and Python version:environment.yml): exactlytensorflow==2.9.1andtensorflow-probability==0.17, as before.tensorflow<2.11(2.10 is the last with native-Windows GPU support),tensorflow-probability<0.19,numpy<1.24.tensorflow>=2.9andtensorflow-probability[tf]>=0.17. The[tf]extra bringstf-keras, which tensorflow-probability needs with Keras 3.hdfdictis dropped;h5pyandpilloware declared;find_packages()so a non-editable install includes the subpackages.No parameter, config file or result format changes.
Checks
Same results on the old stack. Python 3.9 (no 3.7 could be installed in the test environment), TensorFlow 2.9.1, tensorflow-probability 0.17, numpy 1.23.5.
mainand this branch learnt the same three jobs from the same inputs, 15 iterations each: zernike_vector beads in one channel, in two channels, and insitu_zernike from blinking frames. Every array of every result file is bit-identical:I_model,zernike_coeff,pos,T,stagepos,zoffset, the fitted ROIs and the localizations. Reading each result back withio.h5.load(hdfdict onmain, h5py here) gives the same entries, values and types.What pip installs. Resolved with
uv pip compile:Current stack, end to end. In a fresh Python 3.12 venv,
pip install -e .gives a working uiPSF. Learning from simulated beads (one and two channels) and from simulated blinking frames runs end to end on TensorFlow 2.21. A spline fit with the learnt bead models recovers the simulated z with slope 1.03 (one channel) and 1.015 (two channels).Not tried: Windows, GPUs, 4Pi, field-dependent, voxel and LLS models, and multi-channel in situ on the new stack.
🤖 Generated with Claude Code
https://claude.ai/code/session_01GiNdULxyiqQEqWHGKTbVzV