psyphy 0.0.2__tar.gz → 0.0.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. psyphy-0.0.5/.gitignore +51 -0
  2. psyphy-0.0.5/CHANGELOG.md +121 -0
  3. {psyphy-0.0.2 → psyphy-0.0.5}/PKG-INFO +45 -64
  4. psyphy-0.0.5/README.md +60 -0
  5. {psyphy-0.0.2 → psyphy-0.0.5}/pyproject.toml +43 -2
  6. {psyphy-0.0.2 → psyphy-0.0.5}/src/psyphy/__init__.py +2 -1
  7. {psyphy-0.0.2 → psyphy-0.0.5}/src/psyphy/data/__init__.py +3 -1
  8. psyphy-0.0.5/src/psyphy/data/dataset.py +425 -0
  9. {psyphy-0.0.2 → psyphy-0.0.5}/src/psyphy/data/io.py +19 -10
  10. psyphy-0.0.5/src/psyphy/data/published/__init__.py +30 -0
  11. psyphy-0.0.5/src/psyphy/data/published/hong2025.py +861 -0
  12. {psyphy-0.0.2 → psyphy-0.0.5}/src/psyphy/inference/map_optimizer.py +133 -5
  13. {psyphy-0.0.2 → psyphy-0.0.5}/src/psyphy/model/likelihood.py +376 -296
  14. {psyphy-0.0.2 → psyphy-0.0.5}/src/psyphy/model/prior.py +13 -2
  15. {psyphy-0.0.2 → psyphy-0.0.5}/src/psyphy/model/wppm.py +22 -53
  16. {psyphy-0.0.2 → psyphy-0.0.5}/src/psyphy/posterior/__init__.py +6 -1
  17. {psyphy-0.0.2 → psyphy-0.0.5}/src/psyphy/posterior/parameter_posterior.py +1 -2
  18. psyphy-0.0.5/src/psyphy/posterior/predictive_posterior.py +561 -0
  19. {psyphy-0.0.2 → psyphy-0.0.5}/src/psyphy/trial_placement/__init__.py +2 -0
  20. {psyphy-0.0.2 → psyphy-0.0.5}/src/psyphy/trial_placement/grid.py +5 -6
  21. {psyphy-0.0.2 → psyphy-0.0.5}/src/psyphy/trial_placement/sobol.py +14 -0
  22. {psyphy-0.0.2 → psyphy-0.0.5}/src/psyphy/utils/math.py +0 -4
  23. psyphy-0.0.5/src/psyphy/viz/__init__.py +40 -0
  24. psyphy-0.0.5/src/psyphy/viz/ellipses.py +252 -0
  25. psyphy-0.0.5/src/psyphy/viz/geometry.py +170 -0
  26. {psyphy-0.0.2 → psyphy-0.0.5}/tests/test_3stimulus_decision_rule.py +28 -40
  27. {psyphy-0.0.2 → psyphy-0.0.5}/tests/test_covariance_field.py +1 -1
  28. psyphy-0.0.5/tests/test_data_format.py +285 -0
  29. psyphy-0.0.5/tests/test_data_published_hong2025.py +403 -0
  30. psyphy-0.0.5/tests/test_docs_recipe.py +136 -0
  31. {psyphy-0.0.2 → psyphy-0.0.5}/tests/test_imports.py +1 -0
  32. psyphy-0.0.5/tests/test_input_dim_validation.py +85 -0
  33. psyphy-0.0.5/tests/test_likelihood_logic.py +119 -0
  34. psyphy-0.0.5/tests/test_map_optimizer_clipping.py +110 -0
  35. {psyphy-0.0.2 → psyphy-0.0.5}/tests/test_mc_likelihood.py +154 -73
  36. {psyphy-0.0.2 → psyphy-0.0.5}/tests/test_model_api.py +14 -11
  37. {psyphy-0.0.2 → psyphy-0.0.5}/tests/test_noise_models.py +2 -9
  38. psyphy-0.0.5/tests/test_posteriors.py +405 -0
  39. psyphy-0.0.5/tests/test_quick_start_recovery.py +207 -0
  40. psyphy-0.0.5/tests/test_viz.py +203 -0
  41. {psyphy-0.0.2 → psyphy-0.0.5}/tests/test_wishart_covariance.py +3 -2
  42. psyphy-0.0.2/.gitignore +0 -33
  43. psyphy-0.0.2/README.md +0 -89
  44. psyphy-0.0.2/src/psyphy/data/dataset.py +0 -303
  45. psyphy-0.0.2/src/psyphy/posterior/predictive_posterior.py +0 -287
  46. psyphy-0.0.2/tests/test_input_dim_validation.py +0 -38
  47. psyphy-0.0.2/tests/test_posteriors.py +0 -236
  48. {psyphy-0.0.2 → psyphy-0.0.5}/LICENSE.md +0 -0
  49. {psyphy-0.0.2 → psyphy-0.0.5}/src/psyphy/inference/__init__.py +0 -0
  50. {psyphy-0.0.2 → psyphy-0.0.5}/src/psyphy/inference/base.py +0 -0
  51. {psyphy-0.0.2 → psyphy-0.0.5}/src/psyphy/inference/langevin.py +0 -0
  52. {psyphy-0.0.2 → psyphy-0.0.5}/src/psyphy/inference/laplace.py +0 -0
  53. {psyphy-0.0.2 → psyphy-0.0.5}/src/psyphy/model/__init__.py +0 -0
  54. {psyphy-0.0.2 → psyphy-0.0.5}/src/psyphy/model/base.py +0 -0
  55. {psyphy-0.0.2 → psyphy-0.0.5}/src/psyphy/model/covariance_field.py +0 -0
  56. {psyphy-0.0.2 → psyphy-0.0.5}/src/psyphy/model/noise.py +0 -0
  57. {psyphy-0.0.2 → psyphy-0.0.5}/src/psyphy/posterior/posterior.py +0 -0
  58. {psyphy-0.0.2 → psyphy-0.0.5}/src/psyphy/utils/__init__.py +0 -0
  59. {psyphy-0.0.2 → psyphy-0.0.5}/tests/conftest.py +0 -0
  60. {psyphy-0.0.2 → psyphy-0.0.5}/tests/test_basis_input_domain.py +0 -0
  61. {psyphy-0.0.2 → psyphy-0.0.5}/tests/test_covariance_field_single_entry_point.py +0 -0
  62. {psyphy-0.0.2 → psyphy-0.0.5}/tests/test_covariance_positive_definite.py +0 -0
  63. {psyphy-0.0.2 → psyphy-0.0.5}/tests/test_embedding_dim.py +0 -0
  64. {psyphy-0.0.2 → psyphy-0.0.5}/tests/test_rectangular_U.py +0 -0
  65. {psyphy-0.0.2 → psyphy-0.0.5}/tests/test_wppm_model_kwargs_guard.py +0 -0
@@ -0,0 +1,51 @@
1
+ __pycache__/
2
+ *.pyc
3
+ .pytest_cache/
4
+ .mypy_cache/
5
+ dist/
6
+ build/
7
+ *.egg-info/
8
+ .venv/
9
+
10
+ *.sh
11
+
12
+ # MkDocs build output and caches
13
+ site/
14
+ .cache/
15
+ .mkdocs-cache/
16
+
17
+ # Ignore apple macOS system files
18
+ .DS_Store
19
+ # Ignore Jupyter Notebook checkpoints
20
+ .ipynb_checkpoints
21
+
22
+ # Ignore VSCode settings
23
+ .vscode/
24
+
25
+ # Generated plot output directories
26
+ # docs/examples/**/plots/*
27
+
28
+ # common Python tooling artifacts
29
+ .ruff_cache/
30
+ .coverage
31
+ coverage.xml
32
+ htmlcov/
33
+ .env
34
+ env/
35
+ venv/
36
+ .python-version
37
+
38
+
39
+
40
+
41
+
42
+ # docs/examples/wppm/hong2025_reproduction.md
43
+
44
+ docs/examples/wppm/plots/hong2025_quick_ellipses.png
45
+ docs/examples/wppm/plots/hong2025_quick_learning_curve.png
46
+ docs/examples/wppm/plots/hong2025_quick_thresholds_end_to_end.png
47
+
48
+ # Saved weights from stage 3. Quick-mode fits are smoke-test noise; the
49
+ # full-mode .npz is ~2 KB and worth committing, since it lets anyone
50
+ # regenerate the end-to-end figure without a GPU.
51
+ docs/examples/wppm/fits/hong2025_quick_fit.npz
@@ -0,0 +1,121 @@
1
+ # Changelog
2
+
3
+ All notable changes to `psyphy` are documented here.
4
+
5
+ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). `psyphy` is
6
+ pre-1.0: while the version is `0.0.x`, **any release may change the public API**, so
7
+ breaking changes are called out below but do not force a minor-version bump.
8
+
9
+ ## [0.0.5] — 2026-10-09
10
+
11
+ Two new subpackages
12
+ (`psyphy.viz`, `psyphy.data.published`), a reproduction of a published figure, and two
13
+ breaking API changes in the model layer.
14
+
15
+ ### Breaking
16
+
17
+ - **`TaskLikelihood.predict` signature and return type changed** (#139). Stimuli are now
18
+ passed as one packed, slot-indexed array instead of separate arguments, and the return
19
+ is a tuple of sufficient statistics instead of a bare scalar:
20
+
21
+ ```python
22
+ # before (0.0.4)
23
+ def predict(self, params, ref, comparison, model, *, key=None) -> jnp.ndarray: ...
24
+ # returns p_correct
25
+
26
+ # now (0.0.5)
27
+ def predict(self, params, stimuli, model, *, key=None) -> tuple[jnp.ndarray, ...]: ...
28
+ # stimuli has shape (K, input_dim); OddityTask reads stimuli[0], stimuli[1]
29
+ # returns (p_correct,) for Bernoulli tasks, (mu, sigma) for Gaussian task likelihoods
30
+ ```
31
+
32
+ **If you wrote a custom `TaskLikelihood`, it must be updated.** Unpack `stimuli`
33
+ yourself and wrap the return in a tuple. Returning a bare array no longer works
34
+ correctly: `BernoulliTaskLikelihood.loglik` indexes element 0 of the returned tuple, so
35
+ a bare scalar silently collapses every trial onto the first trial's probability.
36
+
37
+ - **`TrialData` now stores stimuli as one array** (#136). `refs=` / `comparisons=` are
38
+ replaced by a single `stimuli` array of shape `(N, K, d)`, with `responses` of shape
39
+ `(N, R)`; `K` is the number of stimuli per trial, so tasks with more than two slots are
40
+ now representable.
41
+
42
+ ```python
43
+ # before
44
+ TrialData(refs=refs, comparisons=comparisons, responses=responses)
45
+ # now
46
+ TrialData(stimuli=jnp.stack([refs, comparisons], axis=1), responses=responses)
47
+ ```
48
+
49
+ A 1-D `responses` array of shape `(N,)` is still accepted and normalized to `(N, 1)`.
50
+ Slots may optionally be named, e.g., `stimulus_names=("ref", "comp")` enables
51
+ `data.stimulus("ref")` alongside positional `data.stimuli[:, 0, :]`.
52
+
53
+ **For the oddity task, `K` is 2, not 3.** The observer is shown three stimuli, but only
54
+ the two distinct means are stored; presenting the reference twice is encoded in
55
+ `OddityTask`, which draws two samples from the reference distribution and one from the
56
+ comparison. `K` counts stored stimuli, not presentations.
57
+
58
+ ### Added
59
+
60
+ - **`psyphy.data.published`** loaders for published datasets, starting with
61
+ `hong2025`: `fetch`, `fetch_calibration_matrix`, `load_calibration_matrix`,
62
+ `load_trials`, `load_reference_W`, `load_sigma_table`, `build_paper_model`,
63
+ `w2d_to_rgb`, `default_data_dir`. Datasets are downloaded on demand (resumable, cached
64
+ outside the repo) rather than shipped with the package.
65
+ - **`psyphy.viz`** : `plot_ellipses`, plus `auto_scale` and `ellipse_segments`. The
66
+ geometry is separated from the drawing layer so it is testable without a plotting
67
+ backend, and `matplotlib` is imported lazily.
68
+ - **Threshold prediction as first-class API** , `WPPMPredictivePosterior(...,
69
+ threshold_pred=True)` with a `ThresholdConfig`, recovering threshold contours by
70
+ numerically inverting `P(correct)`. In this mode `X` is bare reference points of shape
71
+ `(n_test, input_dim)` rather than paired stimuli.
72
+ - **1-D WPPM support** `input_dim=1` is now handled by the Chebyshev basis, the
73
+ prior, and the covariance-field computation, alongside the existing 2-D and 3-D cases.
74
+ - **A distributional layer in the likelihood hierarchy**
75
+ `BernoulliTaskLikelihood` and `GaussianTaskLikelihood` sit between `TaskLikelihood` and
76
+ concrete tasks, each providing `loglik` and `simulate` so a new task only implements
77
+ `predict`. `OddityTask` is now a `BernoulliTaskLikelihood`.
78
+ - **`reduction` on `MAPOptimizer`** `"mean"` (new default) or `"sum"`, controlling how
79
+ the per-trial objective is aggregated. This interacts with gradient clipping: under
80
+ `"sum"` the gradient scales with the number of trials, so a learning rate tuned on one
81
+ dataset size does not transfer. `"mean"` makes learning rates comparable to those
82
+ reported by Hong et al 2025.
83
+ - **Tutorials** reproduction of Hong et al. (2025) Figure 2B (threshold contours) from the published data,
84
+ recovery of Weber's law with a flexible WPPM, and ellipse-field plotting.
85
+ - **Tests**: `test_data_published_hong2025.py`, `test_viz.py`, `test_docs_recipe.py`
86
+ (parses the code quoted in the docs and checks every call against the live API),
87
+ `test_quick_start_recovery.py`, `test_map_optimizer_clipping.py`,
88
+ `test_likelihood_logic.py`, `test_data_format.py`.
89
+
90
+ ### Fixed
91
+
92
+ - **Response-shape broadcasting in the Bernoulli log-likelihood** (#140). With
93
+ `responses` of shape `(N, 1)` and probabilities of shape `(N,)`, `jnp.where` broadcast
94
+ to `(N, N)`, so the summed objective mixed every trial's response with every trial's
95
+ probability and the gradient was wrong. Responses are now reduced to `(N,)` first.
96
+ - **Deprecated `jax.tree_map` replaced** with `jax.tree.map` (#71 — thanks
97
+ @rohansood10).
98
+
99
+ ### Changed
100
+
101
+ - `requires-python` is `>=3.10`; CI runs lint, type checks, and tests on 3.10, 3.11, and
102
+ 3.12.
103
+ - Documentation pages now quote code from the runnable scripts beside them via snippet
104
+ includes, so a page and its script cannot drift apart.
105
+
106
+ ## [0.0.4] — 2026-03-31
107
+
108
+ Likelihood refactor. `loglik` and `simulate` became concrete methods on
109
+ `TaskLikelihood`, so a concrete task implements only `predict`; `OddityTask` lost its own
110
+ `loglik` and the duplicated vectorised Monte Carlo path (`likelihood.py` net −200 lines).
111
+ Documentation restructuring.
112
+
113
+ ## [0.0.2] — 2026-03-27
114
+
115
+ First release published to PyPI. Full initial module set: `psyphy.model` (WPPM, priors,
116
+ noise models, the oddity task), `psyphy.inference` (MAP optimizer), `psyphy.posterior`,
117
+ `psyphy.data`, `psyphy.utils`.
118
+
119
+ [0.0.5]: https://github.com/flatironinstitute/psyphy/compare/v0.0.4...v0.0.5
120
+ [0.0.4]: https://github.com/flatironinstitute/psyphy/compare/v0.0.2...v0.0.4
121
+ [0.0.2]: https://github.com/flatironinstitute/psyphy/releases/tag/v0.0.2
@@ -1,10 +1,11 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.5
2
2
  Name: psyphy
3
- Version: 0.0.2
3
+ Version: 0.0.5
4
4
  Summary: Adaptive Trial Placement for Psychophysical Experiments
5
5
  Project-URL: Homepage, https://flatironinstitute.github.io/psyphy
6
6
  Project-URL: Repository, https://github.com/flatironinstitute/psyphy
7
7
  Project-URL: Issues, https://github.com/flatironinstitute/psyphy/issues
8
+ Project-URL: Changelog, https://flatironinstitute.github.io/psyphy/changelog/
8
9
  Author: Hanna Dettki, Alex Williams
9
10
  Maintainer: Hanna Dettki
10
11
  License: MIT License
@@ -37,26 +38,34 @@ Requires-Dist: jax>=0.4.28
37
38
  Requires-Dist: numpy>=1.22
38
39
  Requires-Dist: optax>=0.2.4
39
40
  Requires-Dist: scipy>=1.7
41
+ Provides-Extra: cuda
42
+ Requires-Dist: jax[cuda12]>=0.4.28; extra == 'cuda'
40
43
  Provides-Extra: dev
41
44
  Requires-Dist: mypy>=1.0; extra == 'dev'
42
45
  Requires-Dist: pre-commit>=3.0; extra == 'dev'
43
46
  Requires-Dist: pytest>=8.0; extra == 'dev'
44
47
  Requires-Dist: ruff>=0.9; extra == 'dev'
45
48
  Provides-Extra: docs
46
- Requires-Dist: jupyterlab>=4.0; extra == 'docs'
47
- Requires-Dist: matplotlib>=3.5; extra == 'docs'
48
- Requires-Dist: seaborn>=0.13; extra == 'docs'
49
+ Requires-Dist: mkdocs-material>=9.7; extra == 'docs'
50
+ Requires-Dist: mkdocs<2,>=1.6; extra == 'docs'
51
+ Requires-Dist: mkdocstrings[python]>=1.0; extra == 'docs'
52
+ Requires-Dist: pymdown-extensions>=11.0; extra == 'docs'
53
+ Provides-Extra: examples
54
+ Requires-Dist: jupyterlab>=4.0; extra == 'examples'
55
+ Requires-Dist: matplotlib>=3.5; extra == 'examples'
56
+ Requires-Dist: seaborn>=0.13; extra == 'examples'
57
+ Provides-Extra: viz
58
+ Requires-Dist: matplotlib>=3.5; extra == 'viz'
49
59
  Description-Content-Type: text/markdown
50
60
 
51
- ![psyphy logo](docs/images/psyphy_logo_draft.png)
52
61
 
53
62
  <div align="center">
54
63
  <picture>
55
- <source srcset="docs/images/psyphy_logo_draft.png" media="(prefers-color-scheme: light)"/>
56
- <source srcset="docs/images/psyphy_logo_draft.png" media="(prefers-color-scheme: dark)"/>
57
- <!-- <img align="center" src="docs/assets/logo/logo_text_black.svg" alt="Inferno" width="400" style="padding-right: 10px; padding left: 10px;"/> -->
64
+ <source srcset="docs/images/psyphy_logo.png" media="(prefers-color-scheme: light)"/>
65
+ <source srcset="docs/images/psyphy_logo.png" media="(prefers-color-scheme: dark)"/>
66
+ <img alt="psyphy logo" src="docs/images/psyphy_logo.png" width="200">
58
67
  </picture>
59
- <h3>Psychophysical Modeling and Adaptive Trial Placement</h3>
68
+ <h3>Active-learning-driven adaptive experimentation in psychophysics</h3>
60
69
  </div>
61
70
 
62
71
 
@@ -67,73 +76,45 @@ Description-Content-Type: text/markdown
67
76
  <a href="https://flatironinstitute.github.io/psyphy/CONTRIBUTING/">Contributing</a>
68
77
  </h4>
69
78
 
79
+ ## Overview
70
80
 
71
- ## Install (editable)
81
+ `psyphy` is an open-source, JAX-based framework for psychophysics research. It leverages GPU acceleration and efficient approximate inference to power Bayesian, active-learning-driven adaptive experiments.
82
+
83
+ Designed to be modular and extensible, `psyphy` accelerates research workflows and enables real-time adaptive experiments. While currently focused on human color perception, it can be adapted to other perceptual modalities.
84
+
85
+ The package is under active development, and we welcome contributions.
86
+
87
+ ## Install
88
+ `psyphy` only supports python 3.10+. We recommend installing `psyphy` under a virtual environment. Once you've created a virtual environment for `psyphy` and activated it, you can install `psyphy` using pip:
72
89
 
90
+ ```bash
91
+ pip install psyphy
92
+ ```
93
+
94
+ If you're developer or want to use the latest features, you can install from GitHub using:
73
95
  ```bash
74
96
  git clone https://flatironinstitute.github.io/psyphy.git
75
97
  cd psyphy
76
98
  pip install -e .
77
99
 
78
100
  ```
101
+ Contributors can also use [uv](https://docs.astral.sh/uv/), which installs from the committed `uv.lock` for a reproducible environment instead of resolving the loose ranges above fresh each time; see [CONTRIBUTING.md](CONTRIBUTING.md) for the uv-based workflow.
79
102
 
80
- ## [Quickstart](https://flatironinstitute.github.io/psyphy/examples/wppm/quick_start/)
81
- - Go [here](https://flatironinstitute.github.io/psyphy/examples/wppm/quick_start/) for a light-weight tutorial that demonstrates how to instantiate, evaluate and fit a model quickly. You should be able to run the underlying [script](https://github.com/flatironinstitute/psyphy/blob/main/docs/examples/wppm/quick_start.py) on your CPU.
82
- - Go [here](https://flatironinstitute.github.io/psyphy/examples/wppm/full_wppm_fit_example/) for a more comprehensive example visualizing a spatially varying covariance field, also explaining the underlying math. The underlying [script](https://github.com/flatironinstitute/psyphy/blob/main/docs/examples/wppm/full_wppm_fit_example.py) for this tutorial requires a GPU.
83
-
84
-
85
- ## This package provides:
86
-
87
- - Wishart Process Psychophysical Model (WPPM)
88
- - fit to subject's data
89
- - predict psychphysical thresholds
90
- - optional trial placement strategy leveraging model's posterior (e.g., information gain, place next batch of trials such that model's uncertainty is maximally reduced)
91
- - Priors and noise models
92
- - supports cold and warm starts where warm means initialzing with parameters from previous subjects fitted parameters
93
- - Noise Model:
94
- - default: Gaussian
95
- - supports Student's T
96
- - Task likelihoods
97
- - currently supports OddityTask, TwoAFC
98
- - Inference engines (MAP, Langevin, Laplace)
99
- - Posterior wrappers and diagnostics
100
- - Trial placement strategies (grid, information gain)
101
- - supports online and batchwise trial placement
102
- - Experiment session orchestration
103
- - reading session data and exporting next batch of trial placments
104
-
105
-
106
-
107
- ## Background
108
-
109
- This package implements methods described in:
110
- - [Hong et al. (2025). *Comprehensive characterization of human color discrimination thresholds*.](https://www.biorxiv.org/content/10.1101/2025.07.16.665219v1)
111
-
112
- While the paper above used AEPsych (a Gaussian Process–based trial placer),
113
- `psyphy` integrates trial placement directly with the WPPM posterior (e.g. via InfoGain/EAVC),
114
- making the adaptive trial placement model-aware.
115
-
116
- ## Docs
117
-
118
- Build and preview the documentation locally:
119
-
103
+ ### GPU support
104
+ The commands above install a **CPU-only** `jax`. For an NVIDIA/CUDA GPU (including the Flatiron cluster), install the `cuda` extra instead:
120
105
  ```bash
121
- # from repo root
122
- source .venv/bin/activate
123
- pip install mkdocs mkdocs-material 'mkdocstrings[python]'
124
- mkdocs serve
106
+ pip install "psyphy[cuda]" # from PyPI
107
+ pip install -e ".[cuda]" # from a clone
125
108
  ```
109
+ This pulls in JAX's own `cuda12` extra, which bundles a matching CUDA/cuDNN runtime as pip packages — no system CUDA module needs to be loaded alongside it.
126
110
 
127
- Build the static site:
111
+ **Apple Silicon (M-series) GPUs are not supported.** JAX's Metal backend cannot do `float64`, which some `psyphy` examples require for published-precision comparisons (Apple/Google's own `jax-metal` package is also no longer maintained). On a Mac, `psyphy` runs on CPU.
128
112
 
129
- ```bash
130
- mkdocs build
131
- ```
113
+ ## [Quickstart](https://flatironinstitute.github.io/psyphy/examples/wppm/quick_start/)
114
+ - Go [here](https://flatironinstitute.github.io/psyphy/examples/wppm/quick_start/) for a light-weight tutorial that demonstrates how to instantiate, evaluate and fit a model quickly. You should be able to run the underlying [script](https://github.com/flatironinstitute/psyphy/blob/main/docs/examples/wppm/quick_start.py) on your CPU.
115
+ - Go [here](https://flatironinstitute.github.io/psyphy/examples/wppm/full_wppm_fit_example/) for a more comprehensive example visualizing a spatially varying covariance field, also explaining the underlying math. The underlying [script](https://github.com/flatironinstitute/psyphy/blob/main/docs/examples/wppm/full_wppm_fit_example.py) for this tutorial requires a GPU.
132
116
 
133
- Deploy to GitHub Pages (manual):
134
117
 
135
- ```bash
136
- mkdocs gh-deploy --clean
137
- ```
118
+ ## Contributing
138
119
 
139
- For contributors, see CONTRIBUTING.md for full doc guidelines and NumPy-style docstrings.
120
+ For contributors, see [`CONTRIBUTING.md`](CONTRIBUTING.md) for full doc guidelines and NumPy-style docstrings.
psyphy-0.0.5/README.md ADDED
@@ -0,0 +1,60 @@
1
+
2
+ <div align="center">
3
+ <picture>
4
+ <source srcset="docs/images/psyphy_logo.png" media="(prefers-color-scheme: light)"/>
5
+ <source srcset="docs/images/psyphy_logo.png" media="(prefers-color-scheme: dark)"/>
6
+ <img alt="psyphy logo" src="docs/images/psyphy_logo.png" width="200">
7
+ </picture>
8
+ <h3>Active-learning-driven adaptive experimentation in psychophysics</h3>
9
+ </div>
10
+
11
+
12
+ <h4 align="center">
13
+ <a href="https://flatironinstitute.github.io/psyphy/#install/">Installation</a> |
14
+ <a href="https://flatironinstitute.github.io/psyphy/reference/">Documentation</a> |
15
+ <a href="https://flatironinstitute.github.io/psyphy/examples/">Examples</a> |
16
+ <a href="https://flatironinstitute.github.io/psyphy/CONTRIBUTING/">Contributing</a>
17
+ </h4>
18
+
19
+ ## Overview
20
+
21
+ `psyphy` is an open-source, JAX-based framework for psychophysics research. It leverages GPU acceleration and efficient approximate inference to power Bayesian, active-learning-driven adaptive experiments.
22
+
23
+ Designed to be modular and extensible, `psyphy` accelerates research workflows and enables real-time adaptive experiments. While currently focused on human color perception, it can be adapted to other perceptual modalities.
24
+
25
+ The package is under active development, and we welcome contributions.
26
+
27
+ ## Install
28
+ `psyphy` only supports python 3.10+. We recommend installing `psyphy` under a virtual environment. Once you've created a virtual environment for `psyphy` and activated it, you can install `psyphy` using pip:
29
+
30
+ ```bash
31
+ pip install psyphy
32
+ ```
33
+
34
+ If you're developer or want to use the latest features, you can install from GitHub using:
35
+ ```bash
36
+ git clone https://flatironinstitute.github.io/psyphy.git
37
+ cd psyphy
38
+ pip install -e .
39
+
40
+ ```
41
+ Contributors can also use [uv](https://docs.astral.sh/uv/), which installs from the committed `uv.lock` for a reproducible environment instead of resolving the loose ranges above fresh each time; see [CONTRIBUTING.md](CONTRIBUTING.md) for the uv-based workflow.
42
+
43
+ ### GPU support
44
+ The commands above install a **CPU-only** `jax`. For an NVIDIA/CUDA GPU (including the Flatiron cluster), install the `cuda` extra instead:
45
+ ```bash
46
+ pip install "psyphy[cuda]" # from PyPI
47
+ pip install -e ".[cuda]" # from a clone
48
+ ```
49
+ This pulls in JAX's own `cuda12` extra, which bundles a matching CUDA/cuDNN runtime as pip packages — no system CUDA module needs to be loaded alongside it.
50
+
51
+ **Apple Silicon (M-series) GPUs are not supported.** JAX's Metal backend cannot do `float64`, which some `psyphy` examples require for published-precision comparisons (Apple/Google's own `jax-metal` package is also no longer maintained). On a Mac, `psyphy` runs on CPU.
52
+
53
+ ## [Quickstart](https://flatironinstitute.github.io/psyphy/examples/wppm/quick_start/)
54
+ - Go [here](https://flatironinstitute.github.io/psyphy/examples/wppm/quick_start/) for a light-weight tutorial that demonstrates how to instantiate, evaluate and fit a model quickly. You should be able to run the underlying [script](https://github.com/flatironinstitute/psyphy/blob/main/docs/examples/wppm/quick_start.py) on your CPU.
55
+ - Go [here](https://flatironinstitute.github.io/psyphy/examples/wppm/full_wppm_fit_example/) for a more comprehensive example visualizing a spatially varying covariance field, also explaining the underlying math. The underlying [script](https://github.com/flatironinstitute/psyphy/blob/main/docs/examples/wppm/full_wppm_fit_example.py) for this tutorial requires a GPU.
56
+
57
+
58
+ ## Contributing
59
+
60
+ For contributors, see [`CONTRIBUTING.md`](CONTRIBUTING.md) for full doc guidelines and NumPy-style docstrings.
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "psyphy"
7
- version = "0.0.2"
7
+ version = "0.0.5"
8
8
 
9
9
  authors = [
10
10
  { name = "Hanna Dettki" },
@@ -39,28 +39,69 @@ dev = [
39
39
  "mypy>=1.0",
40
40
  "pre-commit>=3.0",
41
41
  ]
42
+ # Toolchain for `mkdocs build --strict`. Kept separate from `examples` so CI's
43
+ # docs job does not have to install JupyterLab on every push to main.
44
+ #
45
+ # The `<2` bound is deliberate: MkDocs 2.0 removes the plugin system outright
46
+ # (mkdocs-material warns about this at build time, and states there is no
47
+ # migration path). This site depends on the `search` and `mkdocstrings`
48
+ # plugins, so it cannot build under 2.x. Revisit when the ecosystem settles.
42
49
  docs = [
50
+ "mkdocs>=1.6,<2",
51
+ "mkdocs-material>=9.7",
52
+ "mkdocstrings[python]>=1.0",
53
+ "pymdown-extensions>=11.0",
54
+ ]
55
+ # Plotting backend for psyphy.viz. Kept separate from `examples` so a user who
56
+ # only wants to draw covariance ellipses does not also install JupyterLab.
57
+ viz = [
58
+ "matplotlib>=3.5",
59
+ ]
60
+ # Needed only to *run* the example scripts under docs/examples/ and regenerate
61
+ # their figures. The committed plots mean the site builds without these.
62
+ examples = [
43
63
  "matplotlib>=3.5",
44
64
  "seaborn>=0.13",
45
65
  "jupyterlab>=4.0",
46
66
  ]
67
+ # GPU (NVIDIA/CUDA) support, e.g. for running the example scripts on the
68
+ # Flatiron cluster. `jax[cuda12]` pulls in jaxlib's CUDA plugin plus matching
69
+ # nvidia-*-cu12 wheels; JAX bundles its own CUDA/cuDNN runtime this way, so no
70
+ # system CUDA/cuDNN module should be loaded alongside it -- doing so puts an
71
+ # older system libcusparse/libcudnn ahead of the bundled ones on
72
+ # LD_LIBRARY_PATH and breaks GPU detection (`module load python` is enough).
73
+ #
74
+ # There is no equivalent extra for Apple Silicon GPUs: JAX's Metal backend
75
+ # does not support float64, which the WPPM examples require for their
76
+ # published-precision comparisons, so Mac users run CPU-only. Third-party
77
+ # Metal backends exist (jax-mps / applejax) but are not wired up here.
78
+ cuda = [
79
+ "jax[cuda12]>=0.4.28",
80
+ ]
47
81
 
48
82
  [project.urls]
49
83
  Homepage = "https://flatironinstitute.github.io/psyphy"
50
84
  Repository = "https://github.com/flatironinstitute/psyphy"
51
85
  Issues = "https://github.com/flatironinstitute/psyphy/issues"
86
+ Changelog = "https://flatironinstitute.github.io/psyphy/changelog/"
52
87
 
53
88
  [tool.hatch.build.targets.wheel]
54
89
  packages = ["src/psyphy"]
55
90
 
56
91
  [tool.hatch.build.targets.sdist]
57
- include = ["src/psyphy", "README.md", "LICENSE.md", "tests"]
92
+ include = ["src/psyphy", "README.md", "LICENSE.md", "CHANGELOG.md", "tests"]
58
93
 
59
94
  # Ruff configuration
60
95
  [tool.ruff]
61
96
  line-length = 88
62
97
  target-version = "py39"
63
98
  src = ["src", "tests"]
99
+ # Ruff >=0.16 formats Python code blocks inside Markdown. The docs pages embed
100
+ # snippets from docs/examples/*.py via pymdownx.snippets' `--8<--` includes, so
101
+ # the code is already formatted at its source; letting the formatter rewrite the
102
+ # rendered copies would only churn the prose files and desync them from CI,
103
+ # which lints src/ and tests/ only.
104
+ extend-exclude = ["*.md"]
64
105
 
65
106
  [tool.ruff.lint]
66
107
  select = [
@@ -82,7 +82,7 @@ from . import posterior as posterior
82
82
  # from . import session as session
83
83
  from . import trial_placement as trial_placement
84
84
  from . import utils as utils
85
- from .data.dataset import ResponseData, TrialBatch
85
+ from .data.dataset import ResponseData, TrialBatch, TrialData
86
86
  from .inference.langevin import LangevinSampler
87
87
  from .inference.laplace import LaplaceApproximation
88
88
 
@@ -116,6 +116,7 @@ __all__ = [
116
116
  # Data handling
117
117
  "ResponseData",
118
118
  "TrialBatch",
119
+ "TrialData",
119
120
  # Subpackages
120
121
  "model",
121
122
  "inference",
@@ -8,8 +8,10 @@ Includes:
8
8
  - dataset: ResponseData, TrialBatch, loaders
9
9
  - transforms: color/model space conversions
10
10
  - io: save/load datasets
11
+ - published: loaders for published third-party datasets (downloaded on request)
11
12
  """
12
13
 
14
+ from . import published as published
13
15
  from .dataset import ResponseData, TrialBatch, TrialData
14
16
 
15
- __all__ = ["ResponseData", "TrialBatch", "TrialData"]
17
+ __all__ = ["ResponseData", "TrialBatch", "TrialData", "published"]