Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dsp tests #310

Merged
merged 33 commits into from Aug 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
e1a8acc
[docs] Add Sphinx napoleon setting
gipert Jul 6, 2022
7ae1822
[dsp] fix missing annotations import
gipert Jul 6, 2022
0832876
[dsp] [tests] add some first tests
gipert Jul 6, 2022
67bb592
[pre-commit] style fixes
gipert Jul 6, 2022
0e724df
[dsp] rename _processors -> processors
gipert Jul 6, 2022
643296d
style: pre-commit fixes
pre-commit-ci[bot] Jul 6, 2022
e012e4b
[raw] make overwrite=False by default in build_raw (safer)
gipert Jul 6, 2022
70fd85e
Merge branch 'dsp-tests' of github.com:gipert/pygama into dsp-tests
gipert Jul 6, 2022
7b4fc82
style: pre-commit fixes
pre-commit-ci[bot] Jul 6, 2022
555d96f
[raw] [tests] add further build_raw test
gipert Jul 6, 2022
231fa75
[dsp] update type hints and docstrings
gipert Jul 6, 2022
20ad6b7
[dsp] [tests] add first build_dsp tests with L200 HPGe DSP file
gipert Jul 6, 2022
c73e916
style: pre-commit fixes
pre-commit-ci[bot] Jul 6, 2022
7778e44
[dsp] fix Python 3.9 tests
gipert Jul 6, 2022
fc0d4a8
[dsp] do not overwrite output file by default
gipert Jul 7, 2022
6adee4b
[raw] [tests] add build_raw test
gipert Jul 7, 2022
c2a4d48
[dsp] add more build_dsp tests
gipert Jul 7, 2022
429082a
[dsp] [tests] test also n_max argument
gipert Jul 7, 2022
6da0203
style: pre-commit fixes
pre-commit-ci[bot] Jul 7, 2022
728379d
[dsp.processors] add type hints, fix docstrings
gipert Jul 8, 2022
326b783
[docs] update DSP processor template
gipert Jul 8, 2022
0b09a58
Merge branch 'dsp-tests' of github.com:gipert/pygama into dsp-tests
gipert Jul 8, 2022
92f0ad9
[pre-commit] disable numpydoc testing, bad hook
gipert Jul 8, 2022
1bef253
Merge branch 'refactor' into dsp-tests
gipert Jul 8, 2022
03a7690
Merge branch 'vis' into dsp-tests
gipert Jul 11, 2022
4d4fa46
[pre-commit] add JSON file linter
gipert Jul 14, 2022
7c29d98
[dsp] fix NumPy array type hints
gipert Jul 14, 2022
3ecc88f
Merge branch 'main' into dsp-tests
jasondet Jul 21, 2022
4228916
Merge branch 'main' into dsp-tests
jasondet Jul 21, 2022
6f25d17
Merge branch 'main' into dsp-tests
Jul 26, 2022
1dbc1b5
[dsp] [tests] add array output processor test
gipert Aug 1, 2022
e30078c
Merge branch 'main' into dsp-tests
gipert Aug 1, 2022
7d67619
[math] fix docstring
gipert Aug 1, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 7 additions & 7 deletions .pre-commit-config.yaml
Expand Up @@ -24,12 +24,6 @@ repos:
- id: requirements-txt-fixer
- id: trailing-whitespace

- repo: https://github.com/Carreau/velin.git
rev: "0.0.12"
hooks:
- id: velin
args: ["--check", "--write"]

- repo: https://github.com/asottile/setup-cfg-fmt
rev: "v1.20.1"
hooks:
Expand All @@ -41,7 +35,7 @@ repos:
- id: isort

- repo: https://github.com/asottile/pyupgrade
rev: "v2.34.0"
rev: "v2.37.1"
hooks:
- id: pyupgrade
args: ["--py36-plus"]
Expand Down Expand Up @@ -87,3 +81,9 @@ repos:
- id: rst-backticks
- id: rst-directive-colons
- id: rst-inline-touching-normal

- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v2.7.1"
hooks:
- id: prettier
types_or: [json]
4 changes: 3 additions & 1 deletion docs/source/conf.py
Expand Up @@ -64,7 +64,9 @@
# enforce consistent usage of NumPy-style docstrings
napoleon_numpy_docstring = True
napoleon_google_docstring = False
napoleon_use_rtype = False
napoleon_use_ivar = True
napoleon_custom_sections = ["JSON Configuration Example"]


# intersphinx
intersphinx_mapping = {
Expand Down
42 changes: 38 additions & 4 deletions docs/source/manuals/build_dsp.rst
Expand Up @@ -39,6 +39,8 @@ Writing custom processors

# 1) Import Python modules
#
from __future__ import annotations

import numpy as np
from numba import guvectorize

Expand Down Expand Up @@ -67,14 +69,46 @@ Writing custom processors
# - Use "w_" for waveforms, "t_" for indexes, "a_" for amplitudes
# - Use underscore casing for the name of the processor and variables, e.g.,
# "a_trap_energy_in" or "t_trigger_in"
# - use type annotations
#
def the_processor_template(w_in, t_in, a_in, w_out, t_out):
def the_processor_template(w_in: np.ndarray,
t_in: float,
a_in: float,
w_out: np.ndarray,
t_out: float) -> None:

# 4) Document the algorithm
#
"""
Add here a complete description of what the processor does, including the
meaning of input and output variables.
"""One-liner description of the processor.

Add here a more detailed description of what the processor does.
Document input parameters in the "Parameters" section. Add a JSON
example for ProcessingChain configuration in the last section.

Parameters
----------
w_in
the input waveform.
t_in
a scalar parameter in the time domain
a_in
a scalar parameter in the amplitude domain
w_out
the output waveform
t_out
an output scalar value in the time domain

JSON Configuration Example
--------------------------

.. code-block :: json

"wf_bl": {
"function": "the_processor_template",
"module": "pygama.dsp.processors",
"args": ["waveform", "t_a", "a_b", "wf_filtered", "t_result"],
"unit": "ADC"
}
"""

# 5) Initialize output parameters
Expand Down
9 changes: 4 additions & 5 deletions src/pygama/dsp/__init__.py
@@ -1,14 +1,13 @@
"""
r"""
The pygama signal processing framework is contained in the :mod:`.dsp`
submodule. This code is responsible for running a variety of discrete signal
processors on data, producing tier 2 (dsp) files from tier 1 (raw) files. The
main contents of this submodule are:

* :mod:`.processors`: A collection of Numba functions that perform individual
DSP transforms and reductions on our data. Individual processors are held in
the ``_processors`` directory, which is where contributors will write new
processors for inclusion in the analysis. Available processors include all
numpy ufuncs as well.
DSP transforms and reductions on our data. Here is where contributors will
write new processors for inclusion in the analysis. Available processors
include all :class:`numpy.ufunc`\ s as well.
* :class:`.ProcessingChain`: A class that manages and efficiently runs a list
of DSP processors
* :func:`.build_processing_chain`: A function that builds a :class:`.ProcessingChain`
Expand Down
3 changes: 0 additions & 3 deletions src/pygama/dsp/_processors/__init__.py

This file was deleted.

123 changes: 0 additions & 123 deletions src/pygama/dsp/_processors/fftw.py

This file was deleted.

26 changes: 0 additions & 26 deletions src/pygama/dsp/_processors/param_lookup.py

This file was deleted.

47 changes: 0 additions & 47 deletions src/pygama/dsp/_processors/pulse_injector.py

This file was deleted.