Skip to content

Commit

Permalink
[HW-#1.2] Style fixes and python version decrement
Browse files Browse the repository at this point in the history
  • Loading branch information
IThror10 committed Feb 14, 2024
1 parent f68f8cc commit d4d2ea0
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 18 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ jobs:
tests:
runs-on: ubuntu-latest
steps:
- name: Set up Python 3.10
uses: actions/setup-python@v3
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: "3.10"
python-version: "3.8"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
- name: Test with pytest
run: |
python ./scripts/run_tests.py
python ./scripts/run_tests.py
11 changes: 7 additions & 4 deletions project/hw1/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@
def getGraphInfoByName(graphName: str):
graph_csv = cfpq_data.download(graphName)
graph = cfpq_data.graph_from_csv(graph_csv)
return graph.number_of_nodes(),\
graph.number_of_edges(),\
set(map(lambda x: x[2]['label'], graph.edges(data=True)))
return (
graph.number_of_nodes(),
graph.number_of_edges(),
set(map(lambda x: x[2]["label"], graph.edges(data=True))),
)


def createBiSycleGraph(cSize1: int, cSize2: int, labels: set[str], path: str):
graph = labeled_two_cycles_graph(n=cSize1, m=cSize2, labels=labels)
print(path)
write_dot(graph, path)
write_dot(graph, path)
30 changes: 20 additions & 10 deletions tests/test_hw1_task.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,34 @@
import pytest

from tempfile import NamedTemporaryFile
from project.hw1.task import (
createBiSycleGraph,
getGraphInfoByName
)
from project.hw1.task import createBiSycleGraph, getGraphInfoByName


def test_get_graph_info_by_bzip_name():
nodes, edge, labels = getGraphInfoByName("bzip")
assert nodes == 632
assert edge == 556
assert labels == {'a', 'd'}
assert labels == {"a", "d"}


def test_get_graph_info_by_biomedical_name():
nodes, edge, labels = getGraphInfoByName("biomedical")
assert nodes == 341
assert edge == 459
assert labels == {'type', 'label', 'subClassOf', 'comment', 'versionInfo',
'title', 'language', 'publisher', 'description', 'creator'}

assert labels == {
"type",
"label",
"subClassOf",
"comment",
"versionInfo",
"title",
"language",
"publisher",
"description",
"creator",
}


def test_create_bisycle_graph():
target = ["digraph {"]
for i in [1, 2, 3, 0]:
Expand All @@ -33,6 +43,6 @@ def test_create_bisycle_graph():
target.append("")

with NamedTemporaryFile("w+") as tmp:
createBiSycleGraph(3, 5, ('a', 'b'), tmp.name)
createBiSycleGraph(3, 5, ("a", "b"), tmp.name)
result = tmp.read()
assert result == "\n".join(target)
assert result == "\n".join(target)

0 comments on commit d4d2ea0

Please sign in to comment.