Skip to content

Commit 6f148da

Browse files
authored
Merge pull request #14 from NimaSarajpoor/add_test
Add test for challenger and warning
2 parents 25e81b3 + 6720f80 commit 6f148da

File tree

11 files changed

+500
-127
lines changed

11 files changed

+500
-127
lines changed

.flake8

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[flake8]
2+
ignore =
3+
E741,
4+
W503,
5+
E203,
6+
D100,
7+
D401,
8+
D200,
9+
D205,
10+
D400,
11+
D301
12+
max-line-length = 88
13+
docstring-convention=numpy
14+
per-file-ignores =
15+
./test.py:D101,D102,D103
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Tests
2+
on:
3+
push:
4+
branches: main
5+
pull_request:
6+
branches: main
7+
8+
jobs:
9+
unit-testing:
10+
defaults:
11+
run:
12+
# Set default shell to login-bash
13+
# This is required to properly activate the conda environment
14+
# https://github.com/conda-incubator/setup-miniconda?tab=readme-ov-file#use-a-default-shell
15+
shell: bash -el {0}
16+
17+
runs-on: ${{ matrix.os }}
18+
strategy:
19+
matrix:
20+
os: [ubuntu-latest, macos-latest, windows-latest]
21+
22+
steps:
23+
- name: Install xmllint on Linux
24+
if: runner.os == 'Linux'
25+
run: sudo apt-get install libxml2-utils
26+
27+
- name: Get Safe PYTHON_VERSION
28+
run: echo "PYTHON_VERSION=$(curl --location https://devguide.python.org/versions | xmllint --html --xpath '//section[@id="supported-versions"]//table/tbody/tr[count(//section[@id="supported-versions"]//table/tbody/tr[td[.="security"]]/preceding-sibling::*)]/td[1]/p/text()' - 2> /dev/null)" >> $GITHUB_ENV
29+
30+
- name: Checkout Repository
31+
uses: actions/checkout@v4
32+
33+
- name: Update environment.yml with PYTHON_VERSION
34+
run: sed -r 's/- python[>=]+[0-9]+\.[0-9]+/- python==${{ env.PYTHON_VERSION }}/' environment.yml > environment_new.yml
35+
36+
- name: Display environment_new.yml
37+
run: cat environment_new.yml
38+
39+
- name: Set up Miniconda and Install New Dependencies
40+
uses: conda-incubator/setup-miniconda@v3
41+
with:
42+
environment-file: environment_new.yml
43+
44+
- name : Remove environment_new.yml
45+
run: rm -rf environment_new.yml
46+
47+
- name : Display Conda Environments
48+
run: conda env list
49+
50+
- name: Display All Installed Packages
51+
run: conda list
52+
53+
- name: Display Python Version
54+
run: python -c "import sys; print(sys.version)"
55+
56+
- name: Show Full Numba Environment
57+
run: python -m numba -s
58+
59+
- name: Run Unit Tests and Coverage
60+
run: ./test.sh

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
__pycache__
22
*csv
33
.ipynb_checkpoints
4+
.coverage

environment.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ dependencies:
88
- numba>=0.59.1
99
- fftw
1010
- pyfftw
11-
- jax
1211
- panel
1312
- pandas>=0.20.0
1413
- flake8>=3.7.7
1514
- black>=22.1.0
1615
- jupyterlab>=3.0
1716
- matplotlib>=3.3.0
18-
- isort>=5.11.0
17+
- pytest>=4.4.1
18+
- coverage>=4.5.3

sdp/njit_sdp.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import numpy as np
22
from numba import njit
3-
import sdp
43

54

65
@njit(fastmath=True)

sdp/numpy_fft_sdp.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ def sliding_dot_product(Q, T, order="F"):
1414
tmp = np.empty((2, shape), order=order)
1515
tmp[0, :m] = Q[::-1]
1616
tmp[0, m:] = 0.0
17-
tmp[1, :] = T
17+
tmp[1, :n] = T
18+
tmp[1, n:] = 0.0
1819
fft_2d = np.fft.rfft(tmp, axis=-1)
1920

20-
return np.fft.irfft(np.multiply(fft_2d[0], fft_2d[1]))[m - 1 : n]
21+
return np.fft.irfft(np.multiply(fft_2d[0], fft_2d[1]), n=shape)[m - 1 : n]

0 commit comments

Comments
 (0)