Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
f24d515
Add test to check challenger's functionality
NimaSarajpoor Mar 1, 2025
8b494c6
add warning to catch issue when function cannot be imported
NimaSarajpoor Mar 1, 2025
5549abf
rename file to reflect expanded scope
NimaSarajpoor Mar 2, 2025
cf79b9a
move functions to utils.py
NimaSarajpoor Mar 2, 2025
a761bc6
testing all modules
NimaSarajpoor Mar 2, 2025
c8efd4c
removed unnecssary import
NimaSarajpoor Mar 2, 2025
69226bb
minor fix
NimaSarajpoor Mar 2, 2025
d0b3324
catch the name of module when there is error
NimaSarajpoor Mar 2, 2025
b1e443a
Merge branch 'main' into add_test
NimaSarajpoor Mar 5, 2025
461fdf6
rename files
NimaSarajpoor Mar 5, 2025
f60b215
remove unnecessary imports and minor changes
NimaSarajpoor Mar 5, 2025
c0008ca
enhance test functions
NimaSarajpoor Mar 5, 2025
e2a097d
minor fixes
NimaSarajpoor Mar 5, 2025
64fc128
Improve msg when assetion fails
NimaSarajpoor Mar 6, 2025
667da6c
add test.sh and other files and clean up scripts
NimaSarajpoor Mar 6, 2025
164e061
add requirements file and github-actions
NimaSarajpoor Mar 6, 2025
e0788b5
Empty commit
NimaSarajpoor Mar 6, 2025
cf607dd
add pytest installation to github actions
NimaSarajpoor Mar 6, 2025
0334788
To run github actions on push on any branch
NimaSarajpoor Mar 6, 2025
6c6058c
minor fix
NimaSarajpoor Mar 6, 2025
8342667
Add pyFFTW to requirements
NimaSarajpoor Mar 6, 2025
ef517dd
Removed python 3.9 and OpenMP
NimaSarajpoor Mar 6, 2025
e43758a
change file mode
NimaSarajpoor Mar 6, 2025
0b1f7f7
fix shape of irfft output
NimaSarajpoor Mar 6, 2025
0c578d3
clean up cache in sdp/
NimaSarajpoor Mar 6, 2025
1570538
change push branch in github-actions
NimaSarajpoor Mar 8, 2025
34b1c93
fix python version in Github Action
NimaSarajpoor Mar 8, 2025
2355ebe
empty commit
NimaSarajpoor Mar 8, 2025
f6f817d
revert a change in github actions
NimaSarajpoor Mar 8, 2025
d5ae710
Add brackets to fix bash script
NimaSarajpoor Mar 9, 2025
aaa062f
temporarily hardcoded python version
NimaSarajpoor Mar 9, 2025
4f6cb91
temporarily
NimaSarajpoor Mar 9, 2025
d4b0c0b
set python version based on the output of a shell script
NimaSarajpoor Mar 9, 2025
f58f8ab
remove leading dash for run
NimaSarajpoor Mar 9, 2025
1751dc4
fixed running shell script
NimaSarajpoor Mar 9, 2025
c27d50f
revised flow to directly assign output to python version variable
NimaSarajpoor Mar 9, 2025
8e90ad5
clean up output
NimaSarajpoor Mar 9, 2025
d180987
minor change
NimaSarajpoor Mar 9, 2025
fc3516e
check version in bash
NimaSarajpoor Mar 9, 2025
031a49f
add python version to GITHUB_ENV in two steps
NimaSarajpoor Mar 9, 2025
35c19f5
fixed assigning value
NimaSarajpoor Mar 9, 2025
dcb8b09
removed echo for python-version
NimaSarajpoor Mar 9, 2025
cd9fd38
directly echo using output of shell script
NimaSarajpoor Mar 9, 2025
ac760e3
Revert change in github action and update python_version to make it m…
NimaSarajpoor Mar 9, 2025
6fedc8d
Removed flag verbose
NimaSarajpoor Mar 9, 2025
734ba7f
Add different cases for tests
NimaSarajpoor Mar 9, 2025
ac940d3
minor changes
NimaSarajpoor Mar 9, 2025
dcad2d0
install xmllint on linux
NimaSarajpoor Mar 10, 2025
8483776
Add shell bash
NimaSarajpoor Mar 10, 2025
30a42fe
improve test functions
NimaSarajpoor Mar 11, 2025
94f3835
fixed black format
NimaSarajpoor Mar 11, 2025
595841f
minor fix
NimaSarajpoor Mar 11, 2025
45cb28f
set push-to-branch to main
NimaSarajpoor Mar 11, 2025
8818cbd
empty commit
NimaSarajpoor Mar 11, 2025
70eb9df
revert change in github-action
NimaSarajpoor Mar 11, 2025
789a0a3
minor fix
NimaSarajpoor Mar 11, 2025
c246a70
add coverage check
NimaSarajpoor Mar 11, 2025
1e030da
only test for some n_Q
NimaSarajpoor Mar 12, 2025
90da515
improve docstring
NimaSarajpoor Mar 12, 2025
9c08d09
fix black formatting
NimaSarajpoor Mar 12, 2025
17c12cd
remove shell script and move code to Github-Actions
NimaSarajpoor Mar 12, 2025
a570f87
Add coverage installation to workflow
NimaSarajpoor Mar 12, 2025
948f7e8
ignore untested lines in coverage
NimaSarajpoor Mar 13, 2025
f0ec471
testing for more values of n_Q
NimaSarajpoor Mar 13, 2025
53de511
use conda to install dependencies on Github Actions
NimaSarajpoor Mar 16, 2025
37a024b
update environment.yml and workflow
NimaSarajpoor Mar 17, 2025
afc2eb2
Removed requirements.txt
NimaSarajpoor Mar 17, 2025
8671d1d
add test for setup function
NimaSarajpoor Mar 17, 2025
9a67f19
including setup for coverage
NimaSarajpoor Mar 17, 2025
4077e08
update gitignore
NimaSarajpoor Mar 17, 2025
092a033
change push branch
NimaSarajpoor Mar 17, 2025
b14b43d
Removed unnecessary check for ENV VAR
NimaSarajpoor Mar 17, 2025
72f74f4
Removed manipulation of unnecessary env var
NimaSarajpoor Mar 17, 2025
aac2bc3
execute instead of sourcing
NimaSarajpoor Mar 17, 2025
93432db
remove test from timing
NimaSarajpoor Mar 18, 2025
7cf868b
minor fix
NimaSarajpoor Mar 18, 2025
279f4ad
revise test_setup
NimaSarajpoor Mar 18, 2025
74e8118
addressed comments
NimaSarajpoor Mar 19, 2025
f8da7e7
add comment to describe test_inputs
NimaSarajpoor Mar 19, 2025
2c5c631
fix format
NimaSarajpoor Mar 19, 2025
47bcaf1
change push branches to main
NimaSarajpoor Mar 19, 2025
a568ff4
Removed unnecessary step in Github Action
NimaSarajpoor Mar 19, 2025
1ff353a
minor change
NimaSarajpoor Mar 19, 2025
6720f80
improve description of step
NimaSarajpoor Mar 19, 2025
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
48 changes: 1 addition & 47 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,53 +10,7 @@
import time
import warnings


def func_exists(mod_path, func_name):
try:
with open(mod_path, "r") as file:
module_content = file.read()
except FileNotFoundError:
return False # Module file not found

try:
tree = ast.parse(module_content)
except SyntaxError:
return False # Syntax error in module

for node in ast.walk(tree):
if isinstance(node, ast.FunctionDef) and node.name == func_name:
return True
return False


def import_sdp_mods(include=None, ignore=None):
mods = []
for m in sorted(list(pkgutil.iter_modules(sdp.__path__))):
mod_path = f"sdp/{m[1]}.py"
if (
include is not None
and len(include)
and not any(mod in mod_path for mod in include)
):
continue
if (
ignore is not None
and len(ignore)
and any(mod in mod_path for mod in ignore)
):
continue

if (
"sdp" in m[1]
and func_exists(mod_path, "sliding_dot_product")
and func_exists(mod_path, "setup")
):
mod_name = f"sdp.{m[1]}"
mod = importlib.import_module(mod_name)
mods.append(mod)

return mods

from utils import import_sdp_mods

if __name__ == "__main__":
parser = argparse.ArgumentParser(
Expand Down
1 change: 1 addition & 0 deletions test.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/bash

pytest test_modules.py
rm -rf sdp/__pycache__
./test.py > timing.csv
rm -rf sdp/__pycache__
38 changes: 38 additions & 0 deletions test_modules.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import numpy as np
import pytest

from numpy import testing as npt
from sdp import challenger_sdp

from utils import import_sdp_mods


def naive_sliding_dot_product(Q, T):
m = len(Q)
l = T.shape[0] - m + 1
out = np.empty(l)
for i in range(l):
out[i] = np.dot(Q, T[i : i + m])
return out


def test_modules():
pmin = 3
pmax = 13

modules = import_sdp_mods()
for mod in modules:
try:
for q in range(pmin, pmax + 1):
for p in range(q, pmax + 1):
Q = np.random.rand(2 ** q)
T = np.random.rand(2 ** p)
ref = naive_sliding_dot_product(Q, T)
comp = mod.sliding_dot_product(Q, T)

np.testing.assert_allclose(comp, ref)
except Exception as e:
print(f"Error in {mod.__name__}: {str(e)}")
raise e

return
57 changes: 57 additions & 0 deletions utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import ast
import importlib
import pkgutil
import warnings

import sdp


def func_exists(mod_path, func_name):
try:
with open(mod_path, "r") as file:
module_content = file.read()
except FileNotFoundError as e:
warnings.warn(f"SKIPPED: {mod_path},{func_name}: \n{e}")
return False # Module file not found

try:
tree = ast.parse(module_content)
except SyntaxError as e:
warnings.warn(f"SKIPPED: {mod_path},{func_name}: \n{e}")
return False # Syntax error in module

for node in ast.walk(tree):
if isinstance(node, ast.FunctionDef) and node.name == func_name:
return True
e = f"Function {func_name} not found in {mod_path}"
warnings.warn(f"SKIPPED: {mod_path},{func_name}: \n{e}")
return False


def import_sdp_mods(include=None, ignore=None):
mods = []
for m in sorted(list(pkgutil.iter_modules(sdp.__path__))):
mod_path = f"sdp/{m[1]}.py"
if (
include is not None
and len(include)
and not any(mod in mod_path for mod in include)
):
continue
if (
ignore is not None
and len(ignore)
and any(mod in mod_path for mod in ignore)
):
continue

if (
"sdp" in m[1]
and func_exists(mod_path, "sliding_dot_product")
and func_exists(mod_path, "setup")
):
mod_name = f"sdp.{m[1]}"
mod = importlib.import_module(mod_name)
mods.append(mod)

return mods