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

[21, 22] Remaned package to robust_fourier; dropped Cython implementation of Hermite functions #23

Merged
merged 8 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,6 @@ jobs:
run: |
make ruff-check

- name: Run Cython check
run: |
make cython-check

- name: Run tests
run: |
make test-xmlcov
Expand Down
12 changes: 3 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,9 @@ ruff-check:
@echo Checking code style with 'ruff' ...
ruff check $(SRC_DIRS)

# Cython lint checking
.PHONY: cython-check
cython-check:
@echo Checking Cython code with 'cython-lint' ...
cython-lint src/robust_hermite_ft/hermite_functions/_c_hermite.pyx

# All checks combined
.PHONY: check
check: black-check isort-check pyright-check mypy-check pycodestyle-check ruff-check cython-check
check: black-check isort-check pyright-check mypy-check pycodestyle-check ruff-check

# === Test Commands ===

Expand All @@ -87,12 +81,12 @@ test:
.PHONY: test-htmlcov
test-htmlcov:
@echo Running the tests with HTML coverage report ...
pytest --cov=robust_hermite_ft ./tests -n="auto" --cov-report=html -x --no-jit
pytest --cov=robust_fourier ./tests -n="auto" --cov-report=html -x --no-jit

.PHONY: test-xmlcov
test-xmlcov:
@echo Running the tests with XML coverage report ...
pytest --cov=robust_hermite_ft ./tests -n="auto" --cov-report=xml -x --no-jit
pytest --cov=robust_fourier ./tests -n="auto" --cov-report=xml -x --no-jit


# === Documentation ===
Expand Down
27 changes: 11 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# `robust_hermite_ft`
# `robust_fourier`

[![python-3.9](https://img.shields.io/badge/python-3.9-blue.svg)](https://www.python.org/downloads/release/python-390/)
[![python-3.10](https://img.shields.io/badge/python-3.10-blue.svg)](https://www.python.org/downloads/release/python-3100/)
Expand All @@ -7,8 +7,8 @@
[![code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![code style: isort](https://img.shields.io/badge/code%20style-isort-000000.svg)](https://pycqa.github.io/isort/)
[![Checked with mypy](http://www.mypy-lang.org/static/mypy_badge.svg)](http://mypy-lang.org/)
[![codecov](https://codecov.io/gh/MothNik/robust_hermite_ft/branch/10-improve-and-add-coverage-to-CI/graph/badge.svg)](https://codecov.io/gh/MothNik/robust_hermite_ft/branch/10-improve-and-add-coverage-to-CI)
![tests](https://github.com/MothNik/robust_hermite_ft/actions/workflows/python-package.yml/badge.svg)
[![codecov](https://codecov.io/gh/MothNik/robust_fourier/branch/10-improve-and-add-coverage-to-CI/graph/badge.svg)](https://codecov.io/gh/MothNik/robust_fourier/branch/10-improve-and-add-coverage-to-CI)
![tests](https://github.com/MothNik/robust_fourier/actions/workflows/python-package.yml/badge.svg)
<br><br>

You want to compute the Fourier transform of a signal, but your signal can be corrupted by outliers? If so, this package is for you even though you will have to say goodbye to the _"fast"_ in _Fast Fourier Transform_ 🏃🙅‍♀️
Expand All @@ -24,7 +24,7 @@ Currently under construction. Please check back later.
Currently, the package is not yet available on PyPI. To install it, you can clone the repository

```bash
git clone https://github.com/MothNik/robust_hermite_ft.git
git clone https://github.com/MothNik/robust_fourier.git
```

For the following commands, a Makefile is provided to simplify the process. Its use is
Expand All @@ -47,20 +47,17 @@ make install-dev
pip install --upgrade .["dev"]
```

⚠️ **Warning**: This will require a C-compiler to be installed on your system to
compile the Cython code.

When working in developer mode, an environment variable has to be added to run certain
scripts.

```
ROBHERMFT_DEVELOPER = true
ROBFT_DEVELOPER = true
```

### 🔎 Code quality

The following checks for `black`, `isort`, `pyright`, `mypy`, `pycodestyle`, `ruff`, and
`cython-lint` - that are also part of the CI pipeline - can be run with
The following checks for `black`, `isort`, `pyright`, `mypy`, `pycodestyle`, and
`ruff` - that are also part of the CI pipeline - can be run with

```bash
make black-check
Expand All @@ -69,7 +66,6 @@ make pyright-check
make mypy-check
make pycodestyle-check
make ruff-check
make cython-check

# or for all at once
make check
Expand All @@ -81,7 +77,6 @@ pyright ./auxiliary_scripts ./examples ./src ./tests
mypy ./auxiliary_scripts ./examples ./src ./tests
ruff check ./auxiliary_scripts ./examples ./src ./tests
pycodestyle ./auxiliary_scripts ./examples ./src ./tests --max-line-length=88 --ignore=E203,W503
cython-lint src/robust_hermite_ft/hermite_functions/_c_hermite.pyx
```

### ✅❌ Tests
Expand All @@ -93,8 +88,8 @@ make test-xmlcov # for an XML report
make test-htmlcov # for an HTML report

# equivalent to
pytest --cov=robust_hermite_ft ./tests -n="auto" --cov-report=xml -x --no-jit
pytest --cov=robust_hermite_ft ./tests -n="auto" --cov-report=html -x --no-jit
pytest --cov=robust_fourier ./tests -n="auto" --cov-report=xml -x --no-jit
pytest --cov=robust_fourier ./tests -n="auto" --cov-report=html -x --no-jit
```

for parallelized testing whose coverage report will be stored in the file
Expand Down Expand Up @@ -163,15 +158,15 @@ As a sanity check, their orthogonality is part of the tests together with a test
the fact that the absolute values of the Hermite functions for real input cannot exceed
the value $\frac{1}{\sqrt[4]{\pi\cdot\alpha^{2}}}$.

On top of that `robust_hermite_ft` comes with utility functions to approximate some
On top of that `robust_fourier` comes with utility functions to approximate some
special points of the Hermite functions, namely the x-positions of their

- largest root (= outermost zero),
- largest extrema in the outermost oscillation, and
- the point where they numerically fade to zero.

```python
from robust_hermite_ft import (
from robust_fourier import (
approximate_hermite_funcs_fadeout_x,
approximate_hermite_funcs_largest_extrema_x,
approximate_hermite_funcs_largest_zeros_x,
Expand Down
15 changes: 6 additions & 9 deletions auxiliary_scripts/01_hermite_functions_largest_zeros.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
represent the largest zeros of the Hermite functions with a decent accuracy.
Therefore, this script auto-generates the B-spline coefficients for the largest zeros
of the Hermite functions and stores them in the Python file that will then be available
within ``robust_hermite_ft``.
within ``robust_fourier``.

NOTE: THIS SCRIPT CAN ONLY BE RUN IF THE DEVELOPER MODE IS ENABLED BY SETTING THE
ENVIRONMENT VARIABLE ``ROBHERMFT_DEVELOPER`` TO ``true``.
ENVIRONMENT VARIABLE ``ROBFT_DEVELOPER`` TO ``true``.

"""

Expand All @@ -35,7 +35,7 @@
from tqdm import tqdm

plt.style.use(
os.path.join(os.path.dirname(__file__), "../docs/robust_hermite_ft.mplstyle")
os.path.join(os.path.dirname(__file__), "../docs/robust_fourier.mplstyle")
)


Expand All @@ -51,7 +51,7 @@

# the path where to store the spline specifications (relative to the current file)
SPLINE_SPECS_FILE_PATH = (
"../src/robust_hermite_ft/hermite_functions/_hermite_largest_roots_spline.py"
"../src/robust_fourier/hermite_functions/_hermite_largest_roots_spline.py"
)
# the template for storing the spline specifications in the Python file
SPLINE_SPECS_TEMPLATE = """
Expand Down Expand Up @@ -117,10 +117,7 @@

# === Main ===

if (
__name__ == "__main__"
and os.getenv("ROBHERMFT_DEVELOPER", "false").lower() == "true"
):
if __name__ == "__main__" and os.getenv("ROBFT_DEVELOPER", "false").lower() == "true":

# --- Reference data loading / computation ---

Expand Down Expand Up @@ -293,5 +290,5 @@
elif __name__ == "__main__":
print(
"This script can only be run if the developer mode is enabled by setting the "
"environment variable 'ROBHERMFT_DEVELOPER' to 'true'."
"environment variable 'ROBFT_DEVELOPER' to 'true'."
)
17 changes: 7 additions & 10 deletions auxiliary_scripts/02_hermite_functions_largest_extremum.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
represent the largest extrema of the Hermite functions with a decent accuracy.
Therefore, this script auto-generates the B-spline coefficients for the largest
extrema of the Hermite functions and stores them in the Python file that will then be
available within ``robust_hermite_ft``.
available within ``robust_fourier``.

NOTE: THIS SCRIPT CAN ONLY BE RUN IF THE DEVELOPER MODE IS ENABLED BY SETTING THE
ENVIRONMENT VARIABLE ``ROBHERMFT_DEVELOPER`` TO ``true``.
ENVIRONMENT VARIABLE ``ROBFT_DEVELOPER`` TO ``true``.

"""

Expand All @@ -34,14 +34,14 @@
from scipy.optimize import minimize
from tqdm import tqdm

from robust_hermite_ft.hermite_functions import (
from robust_fourier.hermite_functions import (
approximate_hermite_funcs_fadeout_x,
approximate_hermite_funcs_largest_zeros_x,
single_hermite_function,
)

plt.style.use(
os.path.join(os.path.dirname(__file__), "../docs/robust_hermite_ft.mplstyle")
os.path.join(os.path.dirname(__file__), "../docs/robust_fourier.mplstyle")
)

# === Constants ===
Expand All @@ -56,7 +56,7 @@

# the path where to store the spline specifications (relative to the current file)
SPLINE_SPECS_FILE_PATH = (
"../src/robust_hermite_ft/hermite_functions/_hermite_largest_extrema_spline.py"
"../src/robust_fourier/hermite_functions/_hermite_largest_extrema_spline.py"
)
# the template for storing the spline specifications in the Python file
SPLINE_SPECS_TEMPLATE = """
Expand Down Expand Up @@ -235,10 +235,7 @@ def find_hermite_functions_largest_extremum_x(n: int) -> float:

# === Main ===

if (
__name__ == "__main__"
and os.getenv("ROBHERMFT_DEVELOPER", "false").lower() == "true"
):
if __name__ == "__main__" and os.getenv("ROBFT_DEVELOPER", "false").lower() == "true":

# --- Reference data loading / computation ---

Expand Down Expand Up @@ -414,5 +411,5 @@ def find_hermite_functions_largest_extremum_x(n: int) -> float:
elif __name__ == "__main__":
print(
"This script can only be run if the developer mode is enabled by setting the "
"environment variable 'ROBHERMFT_DEVELOPER' to 'true'."
"environment variable 'ROBFT_DEVELOPER' to 'true'."
)
9 changes: 3 additions & 6 deletions auxiliary_scripts/03_write_docs_equations.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
https://medium.com/@ealbanez/how-to-easily-convert-latex-to-images-with-python-9062184dc815

NOTE: THIS SCRIPT CAN ONLY BE RUN IF THE DEVELOPER MODE IS ENABLED BY SETTING THE
ENVIRONMENT VARIABLE ``ROBHERMFT_DEVELOPER`` TO ``true``.
ENVIRONMENT VARIABLE ``ROBFT_DEVELOPER`` TO ``true``.

""" # noqa: E501

Expand Down Expand Up @@ -211,10 +211,7 @@ def latex2image(

# === Main ===

if (
__name__ == "__main__"
and os.getenv("ROBHERMFT_DEVELOPER", "false").lower() == "true"
):
if __name__ == "__main__" and os.getenv("ROBFT_DEVELOPER", "false").lower() == "true":

# the previews are enabled for the specified indices or disabled if None
preview_names = [None] * len(EQUATION_SPECIFICATIONS)
Expand Down Expand Up @@ -248,5 +245,5 @@ def latex2image(
elif __name__ == "__main__":
print(
"This script can only be run if the developer mode is enabled by setting the "
"environment variable 'ROBHERMFT_DEVELOPER' to 'true'."
"environment variable 'ROBFT_DEVELOPER' to 'true'."
)
Loading