dasjax 0.0.2__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.
dasjax-0.0.2/LICENSE ADDED
@@ -0,0 +1,167 @@
1
+ dasjax is licensed under LGPL version 3 license:
2
+
3
+ GNU LESSER GENERAL PUBLIC LICENSE
4
+ Version 3, 29 June 2007
5
+
6
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
7
+ Everyone is permitted to copy and distribute verbatim copies
8
+ of this license document, but changing it is not allowed.
9
+
10
+
11
+ This version of the GNU Lesser General Public License incorporates
12
+ the terms and conditions of version 3 of the GNU General Public
13
+ License, supplemented by the additional permissions listed below.
14
+
15
+ 0. Additional Definitions.
16
+
17
+ As used herein, "this License" refers to version 3 of the GNU Lesser
18
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
19
+ General Public License.
20
+
21
+ "The Library" refers to a covered work governed by this License,
22
+ other than an Application or a Combined Work as defined below.
23
+
24
+ An "Application" is any work that makes use of an interface provided
25
+ by the Library, but which is not otherwise based on the Library.
26
+ Defining a subclass of a class defined by the Library is deemed a mode
27
+ of using an interface provided by the Library.
28
+
29
+ A "Combined Work" is a work produced by combining or linking an
30
+ Application with the Library. The particular version of the Library
31
+ with which the Combined Work was made is also called the "Linked
32
+ Version".
33
+
34
+ The "Minimal Corresponding Source" for a Combined Work means the
35
+ Corresponding Source for the Combined Work, excluding any source code
36
+ for portions of the Combined Work that, considered in isolation, are
37
+ based on the Application, and not on the Linked Version.
38
+
39
+ The "Corresponding Application Code" for a Combined Work means the
40
+ object code and/or source code for the Application, including any data
41
+ and utility programs needed for reproducing the Combined Work from the
42
+ Application, but excluding the System Libraries of the Combined Work.
43
+
44
+ 1. Exception to Section 3 of the GNU GPL.
45
+
46
+ You may convey a covered work under sections 3 and 4 of this License
47
+ without being bound by section 3 of the GNU GPL.
48
+
49
+ 2. Conveying Modified Versions.
50
+
51
+ If you modify a copy of the Library, and, in your modifications, a
52
+ facility refers to a function or data to be supplied by an Application
53
+ that uses the facility (other than as an argument passed when the
54
+ facility is invoked), then you may convey a copy of the modified
55
+ version:
56
+
57
+ a) under this License, provided that you make a good faith effort to
58
+ ensure that, in the event an Application does not supply the
59
+ function or data, the facility still operates, and performs
60
+ whatever part of its purpose remains meaningful, or
61
+
62
+ b) under the GNU GPL, with none of the additional permissions of
63
+ this License applicable to that copy.
64
+
65
+ 3. Object Code Incorporating Material from Library Header Files.
66
+
67
+ The object code form of an Application may incorporate material from
68
+ a header file that is part of the Library. You may convey such object
69
+ code under terms of your choice, provided that, if the incorporated
70
+ material is not limited to numerical parameters, data structure
71
+ layouts and accessors, or small macros, inline functions and templates
72
+ (ten or fewer lines in length), you do both of the following:
73
+
74
+ a) Give prominent notice with each copy of the object code that the
75
+ Library is used in it and that the Library and its use are
76
+ covered by this License.
77
+
78
+ b) Accompany the object code with a copy of the GNU GPL and this license
79
+ document.
80
+
81
+ 4. Combined Works.
82
+
83
+ You may convey a Combined Work under terms of your choice that,
84
+ taken together, effectively do not restrict modification of the
85
+ portions of the Library contained in the Combined Work and reverse
86
+ engineering for debugging such modifications, if you also do each of
87
+ the following:
88
+
89
+ a) Give prominent notice with each copy of the Combined Work that
90
+ the Library is used in it and that the Library and its use are
91
+ covered by this License.
92
+
93
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
94
+ document.
95
+
96
+ c) For a Combined Work that displays copyright notices during
97
+ execution, include the copyright notice for the Library among
98
+ these notices, as well as a reference directing the user to the
99
+ copies of the GNU GPL and this license document.
100
+
101
+ d) Do one of the following:
102
+
103
+ 0) Convey the Minimal Corresponding Source under the terms of this
104
+ License, and the Corresponding Application Code in a form
105
+ suitable for, and under terms that permit, the user to
106
+ recombine or relink the Application with a modified version of
107
+ the Linked Version to produce a modified Combined Work, in the
108
+ manner specified by section 6 of the GNU GPL for conveying
109
+ Corresponding Source.
110
+
111
+ 1) Use a suitable shared library mechanism for linking with the
112
+ Library. A suitable mechanism is one that (a) uses at run time
113
+ a copy of the Library already present on the user's computer
114
+ system, and (b) will operate properly with a modified version
115
+ of the Library that is interface-compatible with the Linked
116
+ Version.
117
+
118
+ e) Provide Installation Information, but only if you would otherwise
119
+ be required to provide such information under section 6 of the
120
+ GNU GPL, and only to the extent that such information is
121
+ necessary to install and execute a modified version of the
122
+ Combined Work produced by recombining or relinking the
123
+ Application with a modified version of the Linked Version. (If
124
+ you use option 4d0, the Installation Information must accompany
125
+ the Minimal Corresponding Source and Corresponding Application
126
+ Code. If you use option 4d1, you must provide the Installation
127
+ Information in the manner specified by section 6 of the GNU GPL
128
+ for conveying Corresponding Source.)
129
+
130
+ 5. Combined Libraries.
131
+
132
+ You may place library facilities that are a work based on the
133
+ Library side by side in a single library together with other library
134
+ facilities that are not Applications and are not covered by this
135
+ License, and convey such a combined library under terms of your
136
+ choice, if you do both of the following:
137
+
138
+ a) Accompany the combined library with a copy of the same work based
139
+ on the Library, uncombined with any other library facilities,
140
+ conveyed under the terms of this License.
141
+
142
+ b) Give prominent notice with the combined library that part of it
143
+ is a work based on the Library, and explaining where to find the
144
+ accompanying uncombined form of the same work.
145
+
146
+ 6. Revised Versions of the GNU Lesser General Public License.
147
+
148
+ The Free Software Foundation may publish revised and/or new versions
149
+ of the GNU Lesser General Public License from time to time. Such new
150
+ versions will be similar in spirit to the present version, but may
151
+ differ in detail to address new problems or concerns.
152
+
153
+ Each version is given a distinguishing version number. If the
154
+ Library as you received it specifies that a certain numbered version
155
+ of the GNU Lesser General Public License "or any later version"
156
+ applies to it, you have the option of following the terms and
157
+ conditions either of that published version or of any later version
158
+ published by the Free Software Foundation. If the Library as you
159
+ received it does not specify a version number of the GNU Lesser
160
+ General Public License, you may choose any version of the GNU Lesser
161
+ General Public License ever published by the Free Software Foundation.
162
+
163
+ If the Library as you received it specifies that a proxy can decide
164
+ whether future versions of the GNU Lesser General Public License shall
165
+ apply, that proxy's public statement of acceptance of any version is
166
+ permanent authorization for you to choose that version for the
167
+ Library.
dasjax-0.0.2/PKG-INFO ADDED
@@ -0,0 +1,126 @@
1
+ Metadata-Version: 2.4
2
+ Name: dasjax
3
+ Version: 0.0.2
4
+ Summary: A dascore compatibility layer for JAX.
5
+ License-Expression: LGPL-3.0-or-later
6
+ Requires-Python: >=3.12
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE
9
+ Requires-Dist: dascore>=0.1.15
10
+ Requires-Dist: jax>=0.4.33
11
+ Requires-Dist: scipy
12
+ Requires-Dist: pandas
13
+ Provides-Extra: test
14
+ Requires-Dist: pytest; extra == "test"
15
+ Requires-Dist: pytest-benchmark; extra == "test"
16
+ Requires-Dist: pytest-codspeed; extra == "test"
17
+ Provides-Extra: dev
18
+ Requires-Dist: prek>=0.3.8; extra == "dev"
19
+ Requires-Dist: ruff>=0.14.5; extra == "dev"
20
+ Dynamic: license-file
21
+
22
+ # dasjax
23
+
24
+ An experimental package for accelerating [DASCore](dascore.org) with [JAX](https://github.com/jax-ml/jax).
25
+
26
+ ## Installation
27
+
28
+ ```bash
29
+ python -m pip install -e ".[dev]"
30
+ ```
31
+
32
+ ## Usage
33
+
34
+ `dasjax`'s main feature is the ability to create compiled DAS pipelines that can run on CPU, GPU, or TPU. These also perform kernel fusions for increased efficiency.
35
+
36
+ ### Compiled pipeline
37
+
38
+ Use `JaxPatchPipeline` when you want to compile a reusable sequence once and run it across many compatible patches.
39
+
40
+ ```python
41
+ import dascore as dc
42
+ from dasjax import JaxPatchPipeline
43
+
44
+ patch = dc.get_example_patch("example_event_1")
45
+
46
+ pipeline = (
47
+ JaxPatchPipeline()
48
+ .scale(2.0)
49
+ .add(1.0)
50
+ .detrend(dim="time", type="constant")
51
+ .normalize(dim="time")
52
+ )
53
+ compiled = pipeline.compile()
54
+
55
+ out = patch.pipe(compiled)
56
+
57
+ print(out.shape)
58
+ ```
59
+
60
+ ## Development
61
+
62
+ ### Three-Tier Architecture
63
+
64
+ `dasjax` is organized as a small three-tier stack:
65
+
66
+ 1. Pipeline layer:
67
+ `src/dasjax/pipeline.py` records operation chains and compiles reusable patch transforms. This is the main user-facing API.
68
+ 2. Operation and pipeline layer:
69
+ `src/dasjax/operations.py` defines the operation registry, validation rules, internal eager implementations, and compiled behavior.
70
+ 3. Kernel layer:
71
+ `src/dasjax/kernels.py` contains the array-level JAX and callback-backed kernels that actually do the numerical work.
72
+
73
+ This split keeps the package easier to extend: add or update numerical behavior in the kernel layer, describe how it plugs into compiled execution in the operation layer, and expose it through the pipeline layer.
74
+
75
+
76
+ ### Roadmap
77
+
78
+ The table below tracks what is missing and roughly how much effort each addition requires.
79
+
80
+ #### Near-term — straightforward pure-JAX array ops
81
+
82
+ No new infrastructure needed; each maps directly to one or two `jnp` calls.
83
+
84
+ | Method | Implementation notes |
85
+ |---|---|
86
+ | `real`, `imag`, `angle`, `conj` | `jnp` one-liners for complex patches |
87
+ | `flip` | `jnp.flip` along a named dim |
88
+ | `roll` | `jnp.roll` circular shift along a dim |
89
+ | `pad` | `jnp.pad` with DASCore coordinate extension |
90
+ | `standardize` | zero-mean + unit-std (compare `normalize`) |
91
+ | `differentiate` | `jnp.diff` finite differences along a dim |
92
+ | `integrate` | `jnp.cumsum` / trapezoid along a dim |
93
+ | `dft` / `idft` | `jnp.fft.rfft` / `irfft` with coord reconstruction |
94
+ | `hilbert` / `envelope` | hilbert via FFT; `envelope = abs(hilbert(data))` |
95
+ | `taper` / `taper_range` | hann / cosine windows broadcast along axis |
96
+ | `whiten` | spectral divide-by-amplitude via FFT |
97
+
98
+ #### Medium-term — moderate effort or shape-changing
99
+
100
+ These need either more work in kernels.py or are shape-changing (segmented pipeline execution, same mechanism as `fbe`).
101
+
102
+ | Method | Implementation notes |
103
+ |---|---|
104
+ | `notch_filter` | SOS filter; same pattern as `pass_filter` |
105
+ | `savgol_filter` | polynomial fitting per frame; JAX-doable |
106
+ | `rolling` | rolling-window reductions (mean, std, …); needs strided views |
107
+ | `correlate` | cross-correlation via `jnp.fft` |
108
+ | `stft` / `istft` | expose the STFT kernel already used by `fbe` |
109
+ | `decimate` | anti-aliased downsampling; shape-changing |
110
+ | `aggregate` / `mean` / `std` / `sum` | axis reductions; shape-changing |
111
+
112
+ ## Performance Notes
113
+
114
+ - The intended fast path is to build a `JaxPatchPipeline`, call `.compile()` once, and reuse the returned callable across many patches of compatible shape and dtype.
115
+ - Equivalent pipeline definitions reuse cached compiled callables automatically.
116
+ - Benchmarks live under `benchmarks/` and compare compiled `dasjax` pipelines against equivalent DASCore operation chains.
117
+
118
+ ## Development Guidelines
119
+
120
+ - Add new JAX patch methods by defining an array kernel in `src/dasjax/kernels.py` and one operation spec in `src/dasjax/operations.py`.
121
+ - The operation spec is the single source of truth for pipeline support, validation, and shared parity test cases.
122
+ - Every new patch method must be tested against a DASCore baseline across the shared mixed-patch fixture in `tests/conftest.py`.
123
+ - Prefer comparing internal operation behavior and compiled pipeline outputs against the closest native DASCore method or operator. If DASCore has no direct method, compare against an equivalent `Patch.update(...)` baseline.
124
+ - Method-equivalence assertions should check data closeness with `equal_nan=True` when needed and should also verify coordinate preservation.
125
+ - Compiled pipeline parity should come from the same declared operation cases rather than a separate hand-maintained test matrix.
126
+ - Install Git hooks locally with `prek install`.
dasjax-0.0.2/README.md ADDED
@@ -0,0 +1,105 @@
1
+ # dasjax
2
+
3
+ An experimental package for accelerating [DASCore](dascore.org) with [JAX](https://github.com/jax-ml/jax).
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ python -m pip install -e ".[dev]"
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ `dasjax`'s main feature is the ability to create compiled DAS pipelines that can run on CPU, GPU, or TPU. These also perform kernel fusions for increased efficiency.
14
+
15
+ ### Compiled pipeline
16
+
17
+ Use `JaxPatchPipeline` when you want to compile a reusable sequence once and run it across many compatible patches.
18
+
19
+ ```python
20
+ import dascore as dc
21
+ from dasjax import JaxPatchPipeline
22
+
23
+ patch = dc.get_example_patch("example_event_1")
24
+
25
+ pipeline = (
26
+ JaxPatchPipeline()
27
+ .scale(2.0)
28
+ .add(1.0)
29
+ .detrend(dim="time", type="constant")
30
+ .normalize(dim="time")
31
+ )
32
+ compiled = pipeline.compile()
33
+
34
+ out = patch.pipe(compiled)
35
+
36
+ print(out.shape)
37
+ ```
38
+
39
+ ## Development
40
+
41
+ ### Three-Tier Architecture
42
+
43
+ `dasjax` is organized as a small three-tier stack:
44
+
45
+ 1. Pipeline layer:
46
+ `src/dasjax/pipeline.py` records operation chains and compiles reusable patch transforms. This is the main user-facing API.
47
+ 2. Operation and pipeline layer:
48
+ `src/dasjax/operations.py` defines the operation registry, validation rules, internal eager implementations, and compiled behavior.
49
+ 3. Kernel layer:
50
+ `src/dasjax/kernels.py` contains the array-level JAX and callback-backed kernels that actually do the numerical work.
51
+
52
+ This split keeps the package easier to extend: add or update numerical behavior in the kernel layer, describe how it plugs into compiled execution in the operation layer, and expose it through the pipeline layer.
53
+
54
+
55
+ ### Roadmap
56
+
57
+ The table below tracks what is missing and roughly how much effort each addition requires.
58
+
59
+ #### Near-term — straightforward pure-JAX array ops
60
+
61
+ No new infrastructure needed; each maps directly to one or two `jnp` calls.
62
+
63
+ | Method | Implementation notes |
64
+ |---|---|
65
+ | `real`, `imag`, `angle`, `conj` | `jnp` one-liners for complex patches |
66
+ | `flip` | `jnp.flip` along a named dim |
67
+ | `roll` | `jnp.roll` circular shift along a dim |
68
+ | `pad` | `jnp.pad` with DASCore coordinate extension |
69
+ | `standardize` | zero-mean + unit-std (compare `normalize`) |
70
+ | `differentiate` | `jnp.diff` finite differences along a dim |
71
+ | `integrate` | `jnp.cumsum` / trapezoid along a dim |
72
+ | `dft` / `idft` | `jnp.fft.rfft` / `irfft` with coord reconstruction |
73
+ | `hilbert` / `envelope` | hilbert via FFT; `envelope = abs(hilbert(data))` |
74
+ | `taper` / `taper_range` | hann / cosine windows broadcast along axis |
75
+ | `whiten` | spectral divide-by-amplitude via FFT |
76
+
77
+ #### Medium-term — moderate effort or shape-changing
78
+
79
+ These need either more work in kernels.py or are shape-changing (segmented pipeline execution, same mechanism as `fbe`).
80
+
81
+ | Method | Implementation notes |
82
+ |---|---|
83
+ | `notch_filter` | SOS filter; same pattern as `pass_filter` |
84
+ | `savgol_filter` | polynomial fitting per frame; JAX-doable |
85
+ | `rolling` | rolling-window reductions (mean, std, …); needs strided views |
86
+ | `correlate` | cross-correlation via `jnp.fft` |
87
+ | `stft` / `istft` | expose the STFT kernel already used by `fbe` |
88
+ | `decimate` | anti-aliased downsampling; shape-changing |
89
+ | `aggregate` / `mean` / `std` / `sum` | axis reductions; shape-changing |
90
+
91
+ ## Performance Notes
92
+
93
+ - The intended fast path is to build a `JaxPatchPipeline`, call `.compile()` once, and reuse the returned callable across many patches of compatible shape and dtype.
94
+ - Equivalent pipeline definitions reuse cached compiled callables automatically.
95
+ - Benchmarks live under `benchmarks/` and compare compiled `dasjax` pipelines against equivalent DASCore operation chains.
96
+
97
+ ## Development Guidelines
98
+
99
+ - Add new JAX patch methods by defining an array kernel in `src/dasjax/kernels.py` and one operation spec in `src/dasjax/operations.py`.
100
+ - The operation spec is the single source of truth for pipeline support, validation, and shared parity test cases.
101
+ - Every new patch method must be tested against a DASCore baseline across the shared mixed-patch fixture in `tests/conftest.py`.
102
+ - Prefer comparing internal operation behavior and compiled pipeline outputs against the closest native DASCore method or operator. If DASCore has no direct method, compare against an equivalent `Patch.update(...)` baseline.
103
+ - Method-equivalence assertions should check data closeness with `equal_nan=True` when needed and should also verify coordinate preservation.
104
+ - Compiled pipeline parity should come from the same declared operation cases rather than a separate hand-maintained test matrix.
105
+ - Install Git hooks locally with `prek install`.
@@ -0,0 +1,47 @@
1
+ [build-system]
2
+ requires = ["setuptools>=80", "setuptools-git-versioning"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [tool.setuptools-git-versioning]
6
+ enabled = true
7
+
8
+ [tool.setuptools]
9
+ include-package-data = true
10
+
11
+ [tool.setuptools.packages.find]
12
+ where = ["src"]
13
+
14
+ [project]
15
+ name = "dasjax"
16
+ dynamic = ["version"]
17
+ description = "A dascore compatibility layer for JAX."
18
+ readme = "README.md"
19
+ requires-python = ">=3.12"
20
+ license = "LGPL-3.0-or-later"
21
+ dependencies = [
22
+ "dascore>=0.1.15",
23
+ "jax>=0.4.33",
24
+ "scipy",
25
+ "pandas",
26
+ ]
27
+
28
+ [project.optional-dependencies]
29
+ test = [
30
+ "pytest",
31
+ "pytest-benchmark",
32
+ "pytest-codspeed",
33
+ ]
34
+ dev = [
35
+ "prek>=0.3.8",
36
+ "ruff>=0.14.5",
37
+ ]
38
+
39
+ [tool.pytest.ini_options]
40
+ testpaths = ["tests"]
41
+ markers = [
42
+ "benchmark: performance benchmark tests",
43
+ ]
44
+
45
+ [tool.ruff]
46
+ line-length = 88
47
+ target-version = "py312"
dasjax-0.0.2/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,22 @@
1
+ """DASCore extensions for JAX-backed patch processing."""
2
+
3
+ # Ruff would normally require imports before executable statements, but this
4
+ # flag must be set before importing package modules that initialize JAX objects.
5
+ # ruff: noqa: E402
6
+
7
+ from importlib.metadata import PackageNotFoundError, version
8
+
9
+ import jax
10
+
11
+ jax.config.update("jax_enable_x64", True)
12
+
13
+ from . import pytree as pytree
14
+ from .operations import JaxPatchOperation, list_operations
15
+ from .pipeline import JaxPatchPipeline
16
+
17
+ __all__ = ["JaxPatchOperation", "JaxPatchPipeline", "list_operations"]
18
+
19
+ try:
20
+ __version__ = version("dasjax")
21
+ except PackageNotFoundError:
22
+ __version__ = "0+unknown"