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

Features/updated notebooks #76

Merged
merged 11 commits into from
Oct 14, 2024
39 changes: 39 additions & 0 deletions .github/workflows/notebooks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Test notebooks

on:
pull_request:
branches:
- main

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.11" # Specify the Python version you need

- name: Install gfortran
run: |
sudo apt-get -y update
sudo apt-get -y install gfortran

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest nbmake pytest-xdist jupyter

- name: Install package in editable mode
run: |
pip install -e .

- name: Test notebooks
run: |
pytest -n auto --nbmake --nbmake-timeout=2400 --nbmake-kernel=python3 notebooks


12 changes: 8 additions & 4 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Run pytest
name: Test install and interface

on:
pull_request:
Expand Down Expand Up @@ -27,13 +27,17 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest
pip install pytest pytest-xdist

- name: Install package in editable mode
run: |
pip install -e .

- name: Run pytest
- name: Run pytest install test
run: |
pytest tests/ # Specify the path to your 'tests' directory
pytest tests/test_install.py

- name: Run pytest install test
run: |
pytest -n auto tests/{test_ode_conservation.py,test_run_stages.py}

3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ build
dist
*/__pycache__
.venv
conda*
conda*
.conda
15 changes: 15 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.6.9
hooks:
# Run the linter.
- id: ruff
args: [ --fix ]
# Run the formatter.
- id: ruff-format
- repo: https://github.com/kynan/nbstripout
rev: 0.7.1
hooks:
- id: nbstripout

8 changes: 6 additions & 2 deletions Makerates/comparenetworks.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,15 @@

print("\nReading reactions")
reactions1, drops = read_reaction_file(reactionsFile1, speciesList, "UCL")
print(f"I found {len(reactions1)} reactions in the file {reactionsFile1}, I dropped {len(drops)} reactions.")
print(
f"I found {len(reactions1)} reactions in the file {reactionsFile1}, I dropped {len(drops)} reactions."
)
# If you need to see which reactions are dropped:
# print("\n".join([str(drop) for drop in drops]))
reactions2, drops = read_reaction_file(reactionsFile2, speciesList, "UCL")
print(f"I found {len(reactions2)} reactions in the file {reactionsFile2}, I dropped {len(drops)} reactions.")
print(
f"I found {len(reactions2)} reactions in the file {reactionsFile2}, I dropped {len(drops)} reactions."
)


print("\nReactions from file 1 not in file 2")
Expand Down
48 changes: 36 additions & 12 deletions Makerates/speciesnetwork.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,44 @@
#simple python script that reads a Makerates produced reaction file and prints every reaction that forms or destroys a chosen species.
# simple python script that reads a Makerates produced reaction file and prints every reaction that forms or destroys a chosen species.
from __future__ import print_function
import csv

species='HCN'
species = "HCN"

f=open('outputFiles/reactions.csv')
reader=csv.reader(f, delimiter=',', quotechar='|')
f = open("outputFiles/reactions.csv")
reader = csv.reader(f, delimiter=",", quotechar="|")

forms='Species Formed in: \n'
dest='Species Destroyed in: \n'
forms = "Species Formed in: \n"
dest = "Species Destroyed in: \n"
for row in reader:
if len(row)>1:
if species in [row[0],row[1],row[2]]:
dest=dest+row[0]+' + '+row[1]+' --> '+row[3]+' + '+row[4]+' + '+row[5]+'\n'
elif species in [row[3],row[4],row[5]]:
forms=forms+row[0]+' + '+row[1]+' --> '+row[3]+' + '+row[4]+' + '+row[5]+'\n'
if len(row) > 1:
if species in [row[0], row[1], row[2]]:
dest = (
dest
+ row[0]
+ " + "
+ row[1]
+ " --> "
+ row[3]
+ " + "
+ row[4]
+ " + "
+ row[5]
+ "\n"
)
elif species in [row[3], row[4], row[5]]:
forms = (
forms
+ row[0]
+ " + "
+ row[1]
+ " --> "
+ row[3]
+ " + "
+ row[4]
+ " + "
+ row[5]
+ "\n"
)

print(forms)
print(dest)
print(dest)
Loading
Loading