Skip to content

Commit 6a94096

Browse files
authored
Merge pull request #55 from alan-turing-institute/45-publish-in-pypi
Merging a release branch off of dev into main, to publish on PyPI. Will keep the branch alive for further updates
2 parents 47e025f + b638248 commit 6a94096

File tree

78 files changed

+4917
-441
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+4917
-441
lines changed

.github/workflows/ci.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- dev
8+
pull_request:
9+
branches:
10+
- main
11+
- dev
12+
13+
jobs:
14+
15+
build-conda:
16+
name: Conda environment
17+
runs-on: "ubuntu-latest"
18+
defaults:
19+
run:
20+
shell: bash -el {0}
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@v4
24+
25+
- name: Create environment.yml
26+
run: |
27+
echo "name: myenv" > environment.yml
28+
echo "channels:" >> environment.yml
29+
echo " - conda-forge" >> environment.yml
30+
echo " - defaults" >> environment.yml
31+
echo "dependencies:" >> environment.yml
32+
echo " - pip" >> environment.yml
33+
34+
- name: Set up Conda
35+
uses: conda-incubator/setup-miniconda@v3
36+
with:
37+
activate-environment: myenv
38+
environment-file: environment.yml
39+
python-version: '3.10'
40+
auto-activate-base: false
41+
42+
- name: Install dependencies
43+
run: |
44+
python -m pip install --upgrade pip
45+
pip install setuptools --upgrade
46+
pip install ./
47+
48+
- name: Run tests
49+
run: |
50+
python -m unittest discover -s tests
51+
52+
build-venv:
53+
name: Python virtual environment
54+
runs-on: ubuntu-latest
55+
56+
steps:
57+
- name: Checkout code
58+
uses: actions/checkout@v4
59+
60+
- name: Set up Python
61+
uses: actions/setup-python@v4
62+
with:
63+
python-version: '3.10'
64+
65+
- name: Set up environment
66+
run: |
67+
python -m venv venv
68+
source venv/bin/activate
69+
70+
- name: Install dependencies
71+
run: |
72+
source venv/bin/activate
73+
python -m pip install --upgrade pip
74+
pip install ./
75+
76+
- name: Run tests
77+
run: |
78+
source venv/bin/activate
79+
python -m unittest discover -s tests

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,3 +163,12 @@ cython_debug/
163163
*.csv
164164
/Tutorials
165165
.DS_Store
166+
/playground_files
167+
168+
*.pyc
169+
170+
# Ignore the PyPI configuration file
171+
.pypirc
172+
173+
# Ignore vscode settings
174+
.vscode/

README.md

Lines changed: 72 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,67 @@
11
# ModularCirc
22

3+
[![Actions Status][actions-badge]][actions-link]
4+
[![PyPI version][pypi-version]][pypi-link]
5+
[![PyPI platforms][pypi-platforms]][pypi-link]
6+
37
The scope of this package is to provide a framework for building **0D models** and **simulating cardiovascular flow** and **mechanics**. Conceptually, the models can be split into three types of components:
48
1. **Heart chambers**
59
2. **Valves**
6-
3. **Vessels**
10+
3. **Vessels**
11+
12+
## Clone the ModularCirc GitHub repo locally
13+
14+
Run:
15+
16+
```
17+
git clone https://github.com/alan-turing-institute/ModularCirc
18+
cd ModularCirc
19+
```
20+
21+
## Setup Conda or python virtual environment
22+
23+
Before installation of the ModularCirc package, please setup a virtual environment using either Conda or python virtual environment.
24+
25+
### Conda setup
26+
27+
Install Conda from https://docs.conda.io/projects/conda/en/stable/user-guide/install/index.html
28+
29+
Run:
30+
31+
```
32+
conda create --name <yourenvname>
33+
conda activate <yourenvname>
34+
```
35+
36+
Proceed to installing the ModularCirc package.
37+
38+
### Python virtual environment setup
39+
40+
Run `python3 -m venv venv`. This creates a virtual environment called `venv` in your base directory.
41+
42+
Activate the python environment: `source venv/bin/activate`
43+
44+
Proceed to installing the ModularCirc package.
745

846
## Installation
47+
48+
To install the pip package:
49+
50+
```bash
51+
python -m pip install ModularCirc_LevanBokeria
52+
```
53+
54+
From source:
55+
56+
After downloading the GitHub repository, from the repo directory run:
57+
958
```bash
10-
pip install git+https://github.com/alan-turing-institute/ModularCirc.git
59+
pip install ./
1160
```
1261

62+
This will install the package based on the `pyproject.toml` file specifications.
63+
64+
1365
## Steps for running basic models
1466
1. Load the classes for the model of interest and the parameter object used to paramterise the said model:
1567
```python
@@ -63,9 +115,25 @@ solver.solve()
63115

64116
8. Extract the state variable values of interest.
65117
```python
66-
v_lv = solver.model.commponents['lv'].V.values
67-
p_lv = solver.model.commponents['lv'].P_i.values
118+
v_lv = solver.model.components['lv'].V.values
119+
p_lv = solver.model.components['lv'].P_i.values
68120
```
69121

70122
## Example values pv loops for all 4 chambers:
71123
![Example PV loops!](Figures/PV_loops.png)
124+
125+
## Run tests
126+
127+
You can run locally the tests by running the following command:
128+
```bash
129+
python -m unittest discover -s tests
130+
```
131+
there is also a autamtated test pipeline that runs the tests on every push to the repository (see [here](.github/workflows/ci.yml)).
132+
133+
<!-- prettier-ignore-start -->
134+
[actions-badge]: https://github.com/alan-turing-institute/ModularCirc/workflows/CI/badge.svg
135+
[actions-link]: https://github.com/alan-turing-institute/ModularCirc/actions
136+
[pypi-link]: https://test.pypi.org/project/ModularCirc-LevanBokeria/
137+
[pypi-platforms]: https://img.shields.io/pypi/pyversions/ModularCirc-LevanBokeria
138+
[pypi-version]: https://img.shields.io/pypi/v/ModularCirc-LevanBokeria
139+
<!-- prettier-ignore-end -->

Tutorials/Tutorial_01/circ_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def run_case(row, output_path, N_cycles, dt):
9797
ind = model.time_object.n_c
9898

9999
# Get the raw pressure signal...
100-
raw_signal = model.commponents["ao"].P[-ind:]
100+
raw_signal = model.components["ao"].P[-ind:]
101101

102102
# Resamples the raw signals (variable length) to a standard 100 time points resolution
103103
resampled_dt, resampled_signal = signal_get_pulse(raw_signal, model.time_object.dt)

0 commit comments

Comments
 (0)