-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 856e977
Showing
11 changed files
with
251 additions
and
0 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,32 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- '**' | ||
pull_request: | ||
branches: | ||
- '**' | ||
|
||
env: | ||
UV_SYSTEM_PYTHON: 1 | ||
|
||
jobs: | ||
uv-example: | ||
name: python | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Install uv | ||
uses: astral-sh/setup-uv@v4 | ||
|
||
- name: Set up Python | ||
run: uv python install | ||
|
||
- name: Install the project | ||
run: uv sync --all-extras --dev | ||
|
||
- name: Run tests | ||
run: uv run pytest tests |
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,13 @@ | ||
# Python-generated files | ||
__pycache__/ | ||
*.py[oc] | ||
build/ | ||
dist/ | ||
wheels/ | ||
*.egg-info | ||
|
||
# Virtual environments | ||
.venv | ||
|
||
# Project files | ||
.idea/ |
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 @@ | ||
3.13 |
Empty file.
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,30 @@ | ||
import networkx as nx | ||
import time | ||
|
||
|
||
class Graph: | ||
def __init__(self, concept_ids, hierarchy): | ||
""" | ||
:param concept_ids: list of concept ids to create a hierarchy from | ||
:param hierarchy: full hierarchy edge list (e.g. SNOMED's | ||
CONCEPT_ANCESTOR.csv) | ||
""" | ||
self.graph = nx.DiGraph() | ||
start = time.time() | ||
|
||
|
||
|
||
delta = time.time() - start | ||
print(f"Processed data in {delta:.2f} seconds") | ||
|
||
def add_edge(self, u, v): | ||
self.graph.add_edge(u, v) | ||
|
||
def remove_edge(self, u, v): | ||
self.graph.remove_edge(u, v) | ||
|
||
def has_edge(self, u, v): | ||
return self.graph.has_edge(u, v) | ||
|
||
def get_neighbors(self, u): | ||
return list(self.graph.successors(u)) |
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,9 @@ | ||
from context.graph import Graph | ||
import networkx as nx | ||
import polars as pl | ||
|
||
concept_ids = [1, 2, 3, 4] | ||
hierarchy = pl.read_csv("~/Desktop/snomed_vocabulary/CONCEPT_ANCESTOR.csv") | ||
|
||
g = Graph(concept_ids, hierarchy) | ||
|
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,6 @@ | ||
def main(): | ||
print("Hello from context!") | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
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,16 @@ | ||
[project] | ||
name = "context" | ||
version = "0.1.0" | ||
description = "Add your description here" | ||
readme = "README.md" | ||
requires-python = ">=3.13" | ||
dependencies = [ | ||
"networkx>=3.4.2", | ||
"numpy>=2.2.0", | ||
"polars>=1.17.1", | ||
] | ||
|
||
[dependency-groups] | ||
dev = [ | ||
"pytest>=8.3.4", | ||
] |
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,3 @@ | ||
"""Requests test package initialisation.""" | ||
|
||
import warnings |
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,13 @@ | ||
from context.graph import Graph | ||
import networkx as nx | ||
|
||
|
||
def test_addition(): | ||
assert (1 + 1) == 2 | ||
|
||
|
||
def test_directed_graph(): | ||
concept_ids = [1, 2, 3, 4] | ||
hierarchy = [(1, 2), (2, 3), (3, 4)] | ||
g = Graph(concept_ids, hierarchy) | ||
assert isinstance(g.graph, nx.DiGraph), "Graph is not a directed graph" |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.