-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #66 from DynamicsAndNeuralSystems/jmoo2880-pypi-pu…
…blish Add new SPI (GWTau) and benchmark generation script + workflow.
- Loading branch information
Showing
10 changed files
with
171 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: Generate benchmarking dataset tables | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
test-ubuntu: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: ["3.9"] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Setup python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
cache: 'pip' | ||
- name: Install octave | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y build-essential octave | ||
- name: Install pyspi dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r requirements.txt | ||
pip install . | ||
- name: Run data generation | ||
run: | | ||
python tests/generate_benchmark_tables.py | ||
- name: Upload artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: benchmark-tables | ||
path: tests/CML7_benchmark_tables_new.pkl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,7 +32,3 @@ jobs: | |
- name: Run pyspi SPI unit tests | ||
run: | | ||
pytest -v ./tests/test_SPIs.py | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import numpy as np | ||
import dill | ||
from pyspi.calculator import Calculator | ||
|
||
""""Script to generate benchmarking dataset""" | ||
def get_benchmark_tables(calc_list): | ||
# get the spis from the first calculator | ||
spis = list(calc_list[1].spis.keys()) | ||
num_procs = calc_list[1].dataset.n_processes | ||
# create a dict to store the mean and std for each spi | ||
benchmarks = {key : {'mean': None, 'std': None} for key in spis} | ||
num_trials = len(calc_list) | ||
for spi in spis: | ||
mpi_tensor = np.zeros(shape=(num_trials, num_procs, num_procs)) | ||
for (index, calc) in enumerate(calc_list): | ||
mpi_tensor[index, :, :] = calc.table[spi].to_numpy() | ||
mean_matrix = np.mean(mpi_tensor, axis=0) # compute element-wise mean across the first dimension | ||
std_matrix = np.std(mpi_tensor, axis=0) # compute element-wise std across the first dimension | ||
benchmarks[spi]['mean'] = mean_matrix | ||
benchmarks[spi]['std'] = std_matrix | ||
|
||
return benchmarks | ||
|
||
# load and transpose dataset | ||
dataset = np.load("pyspi/data/cml7.npy").T | ||
|
||
# create list to store the calculator objects | ||
store_calcs = list() | ||
|
||
for i in range(75): | ||
np.random.seed(42) | ||
calc = Calculator(dataset=dataset) | ||
calc.compute() | ||
store_calcs.append(calc) | ||
|
||
mpi_benchmarks = get_benchmark_tables(store_calcs) | ||
|
||
# save data | ||
with open("tests/CML7_benchmark_tables_new.pkl", "wb") as f: | ||
dill.dump(mpi_benchmarks, f) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters