toolsandogh 0.1.0__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 (35) hide show
  1. toolsandogh-0.1.0/.gitignore +139 -0
  2. toolsandogh-0.1.0/.pre-commit-config.yaml +45 -0
  3. toolsandogh-0.1.0/DESIGN.md +150 -0
  4. toolsandogh-0.1.0/LICENSE +621 -0
  5. toolsandogh-0.1.0/PKG-INFO +88 -0
  6. toolsandogh-0.1.0/README.md +40 -0
  7. toolsandogh-0.1.0/pyproject.toml +130 -0
  8. toolsandogh-0.1.0/setup.cfg +4 -0
  9. toolsandogh-0.1.0/src/toolsandogh/__init__.py +23 -0
  10. toolsandogh-0.1.0/src/toolsandogh/_canonicalize_video.py +242 -0
  11. toolsandogh-0.1.0/src/toolsandogh/_generate_video.py +72 -0
  12. toolsandogh-0.1.0/src/toolsandogh/_load_video.py +263 -0
  13. toolsandogh-0.1.0/src/toolsandogh/_plot_video.py +0 -0
  14. toolsandogh-0.1.0/src/toolsandogh/_rolling.py +155 -0
  15. toolsandogh-0.1.0/src/toolsandogh/_rvt.py +107 -0
  16. toolsandogh-0.1.0/src/toolsandogh/_store_video.py +55 -0
  17. toolsandogh-0.1.0/src/toolsandogh/_validate_video.py +69 -0
  18. toolsandogh-0.1.0/src/toolsandogh/_version.py +34 -0
  19. toolsandogh-0.1.0/src/toolsandogh/scripts/__init__.py +0 -0
  20. toolsandogh-0.1.0/src/toolsandogh/scripts/convert.py +92 -0
  21. toolsandogh-0.1.0/src/toolsandogh/scripts/iscat_analysis.py +1495 -0
  22. toolsandogh-0.1.0/src/toolsandogh/tests/__init__.py +1 -0
  23. toolsandogh-0.1.0/src/toolsandogh/tests/conftest.py +8 -0
  24. toolsandogh-0.1.0/src/toolsandogh/tests/test_io.py +103 -0
  25. toolsandogh-0.1.0/src/toolsandogh/tests/test_iscat_analysis.py +106 -0
  26. toolsandogh-0.1.0/src/toolsandogh/tests/test_rolling.py +47 -0
  27. toolsandogh-0.1.0/src/toolsandogh/tests/testfile.tiff +0 -0
  28. toolsandogh-0.1.0/src/toolsandogh/utils/__init__.py +0 -0
  29. toolsandogh-0.1.0/src/toolsandogh/utils/mproctest.py +86 -0
  30. toolsandogh-0.1.0/src/toolsandogh.egg-info/PKG-INFO +88 -0
  31. toolsandogh-0.1.0/src/toolsandogh.egg-info/SOURCES.txt +33 -0
  32. toolsandogh-0.1.0/src/toolsandogh.egg-info/dependency_links.txt +1 -0
  33. toolsandogh-0.1.0/src/toolsandogh.egg-info/requires.txt +36 -0
  34. toolsandogh-0.1.0/src/toolsandogh.egg-info/top_level.txt +1 -0
  35. toolsandogh-0.1.0/uv.lock +3976 -0
@@ -0,0 +1,139 @@
1
+ # --------------------------------------------------------------
2
+ # Python / package build artefacts
3
+ # --------------------------------------------------------------
4
+ # Byte‑compiled / optimized / DLL files
5
+ __pycache__/
6
+ *.py[cod]
7
+ *$py.class
8
+
9
+ # C extensions (rare, but safe to ignore)
10
+ *.so
11
+
12
+ # Distribution / packaging
13
+ build/
14
+ dist/
15
+ *.egg-info/
16
+ *.egg
17
+ *.whl # wheels that might be built locally
18
+
19
+ # Poetry / pip‑tools / uv lock files – keep the lock file!
20
+ # uv.lock <-- **DO NOT** ignore, it is version‑controlled
21
+ # poetry.lock <-- (if you ever add Poetry) keep it
22
+
23
+ # --------------------------------------------------------------
24
+ # Virtual environments & local Python tools
25
+ # --------------------------------------------------------------
26
+ .venv/
27
+ venv/
28
+ ENV/
29
+ env/
30
+ # pipenv
31
+ Pipfile.lock # keep if you ever use Pipenv
32
+ # conda
33
+ conda-env/
34
+ # pyenv
35
+ .python-version
36
+
37
+ # --------------------------------------------------------------
38
+ # Linting / formatting / static analysis caches
39
+ # --------------------------------------------------------------
40
+ # ruff cache (fast, safe to delete)
41
+ .ruff_cache/
42
+
43
+ # mypy cache
44
+ .mypy_cache/
45
+ .dmypy.json
46
+ .dmypy.json.0
47
+
48
+ # pyright / pyrightcache (if you use it)
49
+ pyrightconfig.json
50
+ .pyright/
51
+
52
+ # --------------------------------------------------------------
53
+ # Testing / coverage artefacts
54
+ # --------------------------------------------------------------
55
+ .pytest_cache/
56
+ htmlcov/
57
+ .coverage
58
+ .coverage.*
59
+ nosetests.xml
60
+ coverage.xml
61
+ *.cover
62
+ *.py,cover
63
+
64
+ # --------------------------------------------------------------
65
+ # Jupyter / notebook artefacts
66
+ # --------------------------------------------------------------
67
+ # Notebook checkpoints created by the Jupyter UI
68
+ .ipynb_checkpoints/
69
+
70
+ # JupyterLab workspace files (optional)
71
+ *.jupyterlab-settings
72
+
73
+ # Exported notebooks (HTML, PDF, etc.)
74
+ *.nb.html
75
+ *.nb.pdf
76
+ *.nbconvert.ipynb
77
+
78
+ # --------------------------------------------------------------
79
+ # IDE / editor specific files
80
+ # --------------------------------------------------------------
81
+ # VS Code
82
+ .vscode/
83
+ *.code-workspace
84
+
85
+ # PyCharm / IntelliJ
86
+ .idea/
87
+ *.iml
88
+ *.ipr
89
+ *.iws
90
+
91
+ # Sublime Text
92
+ *.sublime-project
93
+ *.sublime-workspace
94
+
95
+ # Emacs
96
+ *~
97
+ \#*\#
98
+ .#*
99
+ *.elc
100
+
101
+ # Vim
102
+ *.swp
103
+ *.swo
104
+ Session.vim
105
+ viminfo
106
+
107
+ # --------------------------------------------------------------
108
+ # Data / large scientific files (keep them out of VCS)
109
+ # --------------------------------------------------------------
110
+ data/
111
+ tmp/
112
+ *.h5
113
+ *.hdf5
114
+ *.zarr/
115
+ *.nc
116
+ *.tif
117
+ *.tiff
118
+ *.ome.tif
119
+ *.ome.tiff
120
+ *.raw
121
+ *.csv
122
+ *.tsv
123
+ *.parquet
124
+ *.feather
125
+
126
+ # Cache files generated by Dask (e.g., temporary spill to disk)
127
+ .dask/
128
+ dask-worker-space/
129
+
130
+ # --------------------------------------------------------------
131
+ # Miscellaneous / OS generated files
132
+ # --------------------------------------------------------------
133
+ .DS_Store # macOS Finder metadata
134
+ Thumbs.db # Windows image preview cache
135
+ ehthumbs.db
136
+ Desktop.ini
137
+
138
+ # Logs (if you ever write them)
139
+ *.log
@@ -0,0 +1,45 @@
1
+ repos:
2
+ - repo: https://github.com/pre-commit/pre-commit-hooks
3
+ rev: v5.0.0
4
+ hooks:
5
+ - id: check-case-conflict
6
+ - id: check-illegal-windows-names
7
+ - id: check-symlinks
8
+ - id: destroyed-symlinks
9
+ - id: trailing-whitespace
10
+ - id: end-of-file-fixer
11
+ - id: check-yaml
12
+ - id: check-added-large-files
13
+
14
+ - repo: https://github.com/astral-sh/ruff-pre-commit
15
+ rev: v0.13.1
16
+ hooks:
17
+ - id: ruff-format
18
+ - id: ruff
19
+ args: [ --fix ]
20
+
21
+ - repo: https://github.com/numpy/numpydoc
22
+ rev: v1.9.0
23
+ hooks:
24
+ - id: numpydoc-validation
25
+
26
+ - repo: https://github.com/abravalheri/validate-pyproject
27
+ rev: v0.23
28
+ hooks:
29
+ - id: validate-pyproject
30
+ additional_dependencies: ["validate-pyproject-schema-store[all]"]
31
+
32
+ - repo: https://github.com/RobertCraigie/pyright-python
33
+ rev: v1.1.405
34
+ hooks:
35
+ - id: pyright
36
+
37
+ - repo: local
38
+ hooks:
39
+ - id: pytest
40
+ name: pytest
41
+ entry: uv run ./.venv/bin/pytest
42
+ language: system
43
+ types: [python]
44
+ pass_filenames: false
45
+ always_run: true
@@ -0,0 +1,150 @@
1
+ *Design & Architecture Overview for the **toolsandogh** scientific‑data‑processing package*
2
+
3
+ *Last updated: 2025‑09‑24*
4
+
5
+ ---
6
+
7
+ ## Project Overview
8
+
9
+ **toolsandogh** is a Python library (≥ 3.12) that provides a lightweight, extensible toolbox for processing large‑scale scientific data sets (e.g., microscopy volumes, multi‑modal imaging, high‑throughput experiments).
10
+
11
+ The library embraces **lazy, parallel computation** via Dask, **labeled, N‑dimensional arrays** via xarray, and **type‑safe, well‑documented** code.
12
+
13
+ ---
14
+
15
+ ## Repository Layout
16
+
17
+ ```
18
+ toolsandogh/
19
+
20
+ ├─ DESIGN.md # ← THIS FILE (design & conventions)
21
+ ├─ README.md # User‑oriented introduction, installation, examples
22
+ ├─ pyproject.toml # Build system, metadata, dependencies, ruff config
23
+ ├─ .pre-commit-config.yaml # Pre‑commit hooks (ruff, isort, pyright, etc.)
24
+ ├─ .gitignore # Files/folders that Git should ignore
25
+ ├─ uv.lock # Deterministic lockfile generated by uv
26
+
27
+ ├─ notebooks/ # Jupyter notebooks showing typical workflows
28
+ │ ├─ 01-quickstart.ipynb
29
+ │ └─ ...
30
+
31
+ └─ src/
32
+ └─ toolsandogh/ # The actual Python package
33
+ ├─ __init__.py
34
+ ├─ _generate_video.py # All file names start with an underscore
35
+ ├─ _load_video.py
36
+ ├─ _store_video.py
37
+ ├─ ... # One file per logical piece of functionality
38
+
39
+ ├─ scripts/ # The scripts directory contains executable files
40
+ │ ├─ __init__.py
41
+ │ ├─ iscat_analysis.py
42
+ │ └─ ...
43
+
44
+ └─ tests/ # tests for all toolsandogh functionality
45
+ ├─ __init__.py
46
+ └─ test_load_video.py
47
+ ```
48
+
49
+ ---
50
+
51
+ ## Coding Conventions
52
+
53
+ ### 1. Documentation – **numpydoc**
54
+
55
+ All public objects (functions, classes, methods) must be documented using the **numpydoc** style. This format is machine‑parsable (e.g., for Sphinx) and familiar to scientific Python users.
56
+
57
+ #### Comprehensive Example
58
+
59
+ ```python
60
+ def median_filter(
61
+ data: xr.DataArray,
62
+ size: int | tuple[int, ...] = 3,
63
+ *,
64
+ preserve_nan: bool = True,
65
+ ) -> xr.DataArray:
66
+ """
67
+ Apply a median filter to an ``xarray.DataArray`` using a sliding window.
68
+
69
+ Parameters
70
+ ----------
71
+ data : xarray.DataArray
72
+ The input array. The array can be lazily backed by Dask; the
73
+ operation will therefore be executed in parallel when the result
74
+ is computed.
75
+
76
+ size : int or tuple of int, optional
77
+ The size of the filtering window along each dimension. If a
78
+ single integer is supplied it is used for all dimensions. The
79
+ default is ``3`` (a 3×3×… window).
80
+
81
+ preserve_nan : bool, optional
82
+ If ``True`` (default), NaN values are ignored when computing the
83
+ median, i.e. they act as “missing data”. If ``False`` any window
84
+ containing a NaN will produce a NaN in the output.
85
+
86
+ Returns
87
+ -------
88
+ xarray.DataArray
89
+ A new ``DataArray`` with the same coordinates and attributes as
90
+ ``data`` but containing the filtered values. The returned object
91
+ retains the original chunking layout, so the computation remains
92
+ lazy until ``compute()`` or ``persist()`` is called.
93
+
94
+ Notes
95
+ -----
96
+ * The implementation uses :func:`dask.array.map_overlap` under the
97
+ hood, which means that the filter works on arbitrarily large
98
+ datasets that do not fit into memory.
99
+ * For integer ``size`` values larger than the chunk size along a
100
+ dimension, the function will rechunk automatically. This may
101
+ trigger a temporary increase in memory usage.
102
+
103
+ References
104
+ ----------
105
+ .. [1] J. R. Smith, *Median filtering of large image stacks*, J. Imaging,
106
+ 2023, https://doi.org/10.1234/jim.2023.001
107
+
108
+ Examples
109
+ --------
110
+ >>> import xarray as xr, numpy as np
111
+ >>> arr = xr.DataArray(np.random.rand(100, 100), dims=('y', 'x'))
112
+ >>> filtered = median_filter(arr, size=5)
113
+ >>> filtered.compute() # triggers Dask execution
114
+ <xarray.DataArray (y: 100, x: 100)>
115
+ """
116
+ # implementation follows …
117
+ ```
118
+
119
+ *Key points*
120
+
121
+ * **Section order** – Parameters → Returns → (optional) Notes → References → Examples.
122
+ * Use **reST** syntax for cross‑references (`:func:` , `:class:`).
123
+ * Types are expressed in the signature; the docstring repeats them for clarity.
124
+ * Example code must be runnable and end with a comment showing the expected output when possible.
125
+
126
+ ### 2. Linting
127
+
128
+ Code must obey the following formatting rules (which are enforced by **ruff**):
129
+
130
+ - No pycodestyle errors and warnings, i.e., full complience with PEP-8
131
+
132
+ - No pyflakes errors
133
+
134
+ - Imports must be sorted as with **isort**
135
+
136
+ ### 3. Coding Conventions
137
+
138
+ The following coding conventions apply to the toolsandogh code base:
139
+
140
+ - All functions, methods, and class attributes must have full type hints. These type hints should be as specific as possible (e.g., `Literal["r", "w"]` instead of `str`)
141
+
142
+ - Publicly visible functions should liberal in what inputs they accept, and conservative in what they emit.
143
+
144
+ - Simplicity is king. Functionality should be provided mainly via free functions. Each function should have a clear purpose that can be summed up in a one-line docstring.
145
+
146
+ - All parallelization should be handled via xarrays and Dask. Kernels should be written such that they support both Numpy and Cupy.
147
+
148
+ - Data should be encapsulated as either a `xarray.DataArray` or a `xarray.Dataset`.
149
+
150
+ - Error handling should be rigorous. Exceptions should provide a clear explanation of what went wrong and why.