Skip to content

Commit 3f9c0b5

Browse files
authored
Merge pull request #57 from DynamicsAndNeuralSystems/jmoo2880-add-new-spi-testing
New benchmarking dataset and dependency updates
2 parents 9da4258 + 409208a commit 3f9c0b5

File tree

11 files changed

+135
-71
lines changed

11 files changed

+135
-71
lines changed

.github/workflows/run_unit_tests.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ jobs:
2525
python -m pip install --upgrade pip
2626
pip install -r requirements.txt
2727
pip install .
28-
pip install pandas==1.3.3 numpy==1.22.0
2928
- name: Run pyspi calculator unit tests
3029
run: |
3130
pytest -v ./tests/test_calc.py

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<p align="center">
22
<picture>
3-
<source srcset="img/pyspi_logo_dark.png" media="(prefers-color-scheme: dark)">
3+
<source srcset="img/pyspi_logo_darkmode.png" media="(prefers-color-scheme: dark)">
44
<img src="img/pyspi_logo.png" alt="pyspi logo" height="200"/>
55
</picture>
66
</p>

img/pyspi_logo_dark.png

-59.7 KB
Binary file not shown.

img/pyspi_logo_darkmode.png

83 KB
Loading

pyspi/data/cml7.npy

5.59 KB
Binary file not shown.

requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
pytest
2-
scikit-learn==0.24.1
2+
scikit-learn==1.0.1
33
scipy==1.7.3
44
numpy>=1.21.1
5-
pandas>=1.3.3
5+
pandas==1.5.0
66
statsmodels==0.12.1
77
pyyaml==5.4
88
tqdm==4.50.2

setup.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
# http://www.diveintopython3.net/packaging.html
44
# https://pypi.python.org/pypi?:action=list_classifiers
55

6-
with open('README.md') as file:
6+
with open('README.md', 'r', encoding='utf-8') as file:
77
long_description = file.read()
88

99

1010
install_requires = [
11-
'scikit-learn==0.24.1',
11+
'scikit-learn==1.0.1',
1212
'scipy==1.7.3',
1313
'numpy>=1.21.1',
14-
'pandas>=1.3.3',
14+
'pandas==1.5.0',
1515
'statsmodels==0.12.1',
1616
'pyyaml==5.4',
1717
'tqdm==4.50.2',
@@ -59,9 +59,10 @@
5959
'lib/PhiToolbox/utility/Gauss/logdet.m',
6060
'data/cml.npy',
6161
'data/forex.npy',
62-
'data/standard_normal.npy']},
62+
'data/standard_normal.npy',
63+
'data/cml7.npy']},
6364
include_package_data=True,
64-
version='0.4.1',
65+
version='0.4.2',
6566
description='Library for pairwise analysis of time series data.',
6667
author='Oliver M. Cliff',
6768
author_email='[email protected]',

tests/CML7_benchmark_tables.pkl

484 KB
Binary file not shown.

tests/calc_standard_normal.pkl

-1.1 MB
Binary file not shown.

tests/conftest.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import pytest
2+
3+
@pytest.fixture(scope="session")
4+
def spi_warning_logger(request):
5+
warnings_log = list()
6+
7+
def add_warning(spi, module_name, max_z, num_exceed, num_iteractions):
8+
warnings_log.append((spi, module_name, max_z, num_exceed, num_iteractions))
9+
10+
request.session.spi_warnings = warnings_log
11+
return add_warning
12+
13+
def pytest_sessionfinish(session, exitstatus):
14+
# retrieve the spi warnings from the session object
15+
spi_warnings = getattr(session, 'spi_warnings', [])
16+
17+
# styling
18+
header_line = "=" * 80
19+
content_line = "-" * 80
20+
footer_line = "=" * 80
21+
header = " SPI BENCHMARKING SUMMARY"
22+
footer = f" Session completed with exit status: {exitstatus} "
23+
padded_header = f"{header:^80}"
24+
padded_footer = f"{footer:^80}"
25+
26+
print("\n")
27+
print(header_line)
28+
print(padded_header)
29+
print(header_line)
30+
31+
# print problematic SPIs in table format
32+
if spi_warnings:
33+
print(f"\nDetected {len(spi_warnings)} SPI(s) with outputs exceeding the specified 2 sigma threshold.\n")
34+
35+
# table header
36+
print(f"{'SPI':<25}{'Cat':<10}{'Max ZSc.':>10}{'# Exceed. Pairs':>20}{'Unq. Pairs':>15}")
37+
print(content_line)
38+
39+
# table content
40+
for est, module_name, max_z, num_exceed, num_iteractions in spi_warnings:
41+
# add special character for v.large zscores
42+
error = ""
43+
if max_z > 10:
44+
error = " **"
45+
print(f"{est+error:<25}{module_name:<10}{max_z:>10.4g}{num_exceed:>15}{num_iteractions:>20}")
46+
else:
47+
print("\n\nNo SPIs exceeded the sigma threshold.\n")
48+
49+
print(footer_line)
50+
print(padded_footer)

0 commit comments

Comments
 (0)