From 0d9f5b9cf783e1db737718e93ed6fadbee569663 Mon Sep 17 00:00:00 2001 From: TreshMom Date: Wed, 21 Feb 2024 22:58:40 +0300 Subject: [PATCH 1/4] =?UTF-8?q?=D0=9D=D0=B5=D1=82=20=D0=BF=D1=80=D0=B5?= =?UTF-8?q?=D0=B4=D0=B5=D0=BB=D0=B0=20=D1=81=D0=BE=D0=B2=D0=B5=D1=80=D1=88?= =?UTF-8?q?=D0=B5=D0=BD=D1=81=D1=82=D0=B2=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- project/task_1.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/project/task_1.py b/project/task_1.py index 2ee3d3f4d..d9ad64e62 100644 --- a/project/task_1.py +++ b/project/task_1.py @@ -4,15 +4,17 @@ def graph_info(name_graph: str) -> Tuple[int, int, Set[str]]: + graph_path = cfpq_data.download(name_graph) + graph = cfpq_data.graph_from_csv(graph_path) labels = set() - for _, _, data in name_graph.edges(data=True): + for _, _, data in graph.edges(data=True): if 'label' in data: labels.add(data['label']) return ( - name_graph.number_of_nodes(), - name_graph.number_of_edges(), + graph.number_of_nodes(), + graph.number_of_edges(), labels ) From 5e468b84ce214d8ddc95bfeb6ad312ddebe53a7b Mon Sep 17 00:00:00 2001 From: TreshMom Date: Wed, 21 Feb 2024 23:04:56 +0300 Subject: [PATCH 2/4] =?UTF-8?q?=D1=84=D0=B8=D0=BD=D0=B0=D0=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- project/task_1.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/project/task_1.py b/project/task_1.py index d9ad64e62..c04262208 100644 --- a/project/task_1.py +++ b/project/task_1.py @@ -4,17 +4,15 @@ def graph_info(name_graph: str) -> Tuple[int, int, Set[str]]: - graph_path = cfpq_data.download(name_graph) - graph = cfpq_data.graph_from_csv(graph_path) labels = set() - for _, _, data in graph.edges(data=True): + for _, _, data in name_graph.edges(data=True): if 'label' in data: labels.add(data['label']) return ( - graph.number_of_nodes(), - graph.number_of_edges(), + name_graph.number_of_nodes(), + name_graph.number_of_edges(), labels ) @@ -29,4 +27,6 @@ def create_labeled_two_cycle_graph( labels=nameLabels, ), path=path, - ) \ No newline at end of file + ) + +create_labeled_two_cycle_graph(3,4,("a","b"),'1') From 33b80f771859ced57dfcdc4041beffb630f2e780 Mon Sep 17 00:00:00 2001 From: TreshMom Date: Fri, 1 Mar 2024 20:43:14 +0300 Subject: [PATCH 3/4] fix style and pre-commit --- .github/workflows/code_style.yml | 19 ++++++++++++++----- project/__init__.py | 2 +- project/__main__.py | 2 +- project/task_1.py | 17 +++++------------ tests/test_task_1.py | 15 +++++++++------ 5 files changed, 30 insertions(+), 25 deletions(-) diff --git a/.github/workflows/code_style.yml b/.github/workflows/code_style.yml index 441925730..710ffa9da 100644 --- a/.github/workflows/code_style.yml +++ b/.github/workflows/code_style.yml @@ -23,20 +23,19 @@ jobs: matrix: # Each option you define in the matrix has a key and value - python-version: [ 3.12 ] + python-version: [ 3.8 ] # Steps represent a sequence of tasks that will be executed as part of the job steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - name: Set up Git repository - uses: actions/checkout@v4 + uses: actions/checkout@v2 # Setup Python with version from matrix - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 + uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} - cache: 'pip' # Install requirements - name: Install requirements @@ -45,4 +44,14 @@ jobs: run: | python -m pip install --upgrade pip wheel setuptools python -m pip install -r requirements.txt - python -m pip list \ No newline at end of file + python -m pip list + + # Install pre-commit from .pre-commit-config.yaml + - name: Install pre-commit + run: | + pre-commit install + + # Run pre-commit on all the files in the repo + - name: Run pre-commit + run: | + pre-commit run --all-files --color always --verbose --show-diff-on-failure \ No newline at end of file diff --git a/project/__init__.py b/project/__init__.py index 3aed2427d..0db7b35dd 100644 --- a/project/__init__.py +++ b/project/__init__.py @@ -1,3 +1,3 @@ from .task_1 import graph_info, create_labeled_two_cycle_graph -__all__ = ["graph_info", "create_labeled_two_cycle_graph"] \ No newline at end of file +__all__ = ["graph_info", "create_labeled_two_cycle_graph"] diff --git a/project/__main__.py b/project/__main__.py index e3e636e47..344b363ad 100644 --- a/project/__main__.py +++ b/project/__main__.py @@ -1 +1 @@ -print("exec sources directory") \ No newline at end of file +print("exec sources directory") diff --git a/project/task_1.py b/project/task_1.py index c04262208..d0759fc3b 100644 --- a/project/task_1.py +++ b/project/task_1.py @@ -6,20 +6,15 @@ def graph_info(name_graph: str) -> Tuple[int, int, Set[str]]: labels = set() for _, _, data in name_graph.edges(data=True): - if 'label' in data: - labels.add(data['label']) + if "label" in data: + labels.add(data["label"]) - - return ( - name_graph.number_of_nodes(), - name_graph.number_of_edges(), - labels - ) + return (name_graph.number_of_nodes(), name_graph.number_of_edges(), labels) def create_labeled_two_cycle_graph( - countNode1: int, countNode2: int, nameLabels: Tuple[str, str], - path: str) -> None: + countNode1: int, countNode2: int, nameLabels: Tuple[str, str], path: str +) -> None: pydot.write_dot( G=cfpq_data.labeled_two_cycles_graph( n=countNode1, @@ -28,5 +23,3 @@ def create_labeled_two_cycle_graph( ), path=path, ) - -create_labeled_two_cycle_graph(3,4,("a","b"),'1') diff --git a/tests/test_task_1.py b/tests/test_task_1.py index 8a4129049..5e3adb92f 100644 --- a/tests/test_task_1.py +++ b/tests/test_task_1.py @@ -4,29 +4,32 @@ import pytest from project import create_labeled_two_cycle_graph, graph_info + @pytest.fixture() def start(): print("Start test") + def test_create_labeled_two_cycle_graph(): - with tempfile.NamedTemporaryFile(suffix='.dot') as tmp_file: - create_labeled_two_cycle_graph(3, 4, ('a', 'b'), tmp_file.name) + with tempfile.NamedTemporaryFile(suffix=".dot") as tmp_file: + create_labeled_two_cycle_graph(3, 4, ("a", "b"), tmp_file.name) assert os.path.exists(tmp_file.name) G = nx.drawing.nx_pydot.read_dot(tmp_file.name) assert G.number_of_nodes() == 8 - assert G.number_of_edges() == 9 + assert G.number_of_edges() == 9 for _, _, data in G.edges(data=True): - assert data['label'] in ['a', 'b'] + assert data["label"] in ["a", "b"] + def test_graph_info(): G = nx.Graph() G.add_nodes_from([1, 2, 3]) - G.add_edges_from([(1, 2, {'label': 'a'}), (2, 3, {'label': 'b'})]) + G.add_edges_from([(1, 2, {"label": "a"}), (2, 3, {"label": "b"})]) node_count, edge_count, labels = graph_info(G) assert node_count == 3 assert edge_count == 2 - assert labels == {'a', 'b'} + assert labels == {"a", "b"} From 6986859f5a3cd4523eb69df2f51ae3f286e3cb4b Mon Sep 17 00:00:00 2001 From: TreshMom Date: Fri, 1 Mar 2024 21:10:22 +0300 Subject: [PATCH 4/4] fix pre-commit --- .github/workflows/code_style.yml | 2 +- .github/workflows/test.yml | 2 +- README.md | 16 ++++++++-------- requirements.txt | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/code_style.yml b/.github/workflows/code_style.yml index 710ffa9da..bd1ae2797 100644 --- a/.github/workflows/code_style.yml +++ b/.github/workflows/code_style.yml @@ -54,4 +54,4 @@ jobs: # Run pre-commit on all the files in the repo - name: Run pre-commit run: | - pre-commit run --all-files --color always --verbose --show-diff-on-failure \ No newline at end of file + pre-commit run --all-files --color always --verbose --show-diff-on-failure diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7832dcd52..23658c414 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -22,4 +22,4 @@ jobs: - name: Run tests run: | - python scripts/run_tests.py \ No newline at end of file + python scripts/run_tests.py diff --git a/README.md b/README.md index b18fdf77f..ffc866079 100644 --- a/README.md +++ b/README.md @@ -168,28 +168,28 @@ - Синтаксический анализ языков программирования: в компиляторах, интерпертаторах, средах разработки, других инстументах. - Анализ естественных языков. Активность в этой области несколько спала, так как на передний план сейчас вышли различные методы машинного обучения. - Однако и в этой области ведуться работы.Например, [International Conference on Parsing Technologies](http://www.wikicfp.com/cfp/program?id=1853). + Однако и в этой области ведуться работы.Например, [International Conference on Parsing Technologies](http://www.wikicfp.com/cfp/program?id=1853). - Статический анализ кода. - Различные задачи межпроцедурного анализа. Основной подход --- language reachability. Основоположник --- Томас Репс. Примеры работ. - Thomas Reps. 1997. Program analysis via graph reachability. In Proceedings of the 1997 international symposium on Logic programming (ILPS ’97). MIT Press, Cambridge, MA, USA, 5–19. - Qirun Zhang and Zhendong Su. 2017. Context-sensitive data-dependence analysis via linear conjunctive language reachability. In Proceedings of the 44th ACM SIGPLAN Symposium on Principles of Programming Languages (POPL 2017). Association for Computing Machinery, New York, NY, USA, 344–358. DOI:https://doi.org/10.1145/3009837.3009848 - Kai Wang, Aftab Hussain, Zhiqiang Zuo, Guoqing Xu, and Ardalan Amiri Sani. 2017. Graspan: A Single-machine Disk-based Graph System for Interprocedural Static Analyses of Large-scale Systems Code. In Proceedings of the Twenty-Second International Conference on Architectural Support for Programming Languages and Operating Systems (ASPLOS ’17). Association for Computing Machinery, New York, NY, USA, 389–404. DOI:https://doi.org/10.1145/3037697.3037744 - - Lu Y., Shang L., Xie X., Xue J. (2013) An Incremental Points-to Analysis with CFL-Reachability. In: Jhala R., De Bosschere K. (eds) Compiler Construction. CC 2013. Lecture Notes in Computer Science, vol 7791. Springer, Berlin, Heidelberg + - Lu Y., Shang L., Xie X., Xue J. (2013) An Incremental Points-to Analysis with CFL-Reachability. In: Jhala R., De Bosschere K. (eds) Compiler Construction. CC 2013. Lecture Notes in Computer Science, vol 7791. Springer, Berlin, Heidelberg - Интерливинг (или шафл) языков для верификаци многопоточных программ. - [Approximating the Shuffle of Context-free Languages to Find Bugs in Concurrent Recursive Programs](http://uu.diva-portal.org/smash/get/diva2:442518/FULLTEXT01.pdf) - Flick N.E. (2015) Quotients of Unbounded Parallelism. In: Leucker M., Rueda C., Valencia F. (eds) Theoretical Aspects of Computing - ICTAC 2015. ICTAC 2015. Lecture Notes in Computer Science, vol 9399. Springer, Cham - + - Система типов Java: [Radu Grigore, Java Generics are Turing Complete](https://arxiv.org/abs/1605.05274). - Графовые базы данных. Поиск путей с ограничениями. - Maurizio Nolé and Carlo Sartiani. 2016. Regular Path Queries on Massive Graphs. In Proceedings of the 28th International Conference on Scientific and Statistical Database Management (SSDBM ’16). Association for Computing Machinery, New York, NY, USA, Article 13, 1–12. DOI:https://doi.org/10.1145/2949689.2949711 - Jochem Kuijpers, George Fletcher, Nikolay Yakovets, and Tobias Lindaaker. 2019. An Experimental Study of Context-Free Path Query Evaluation Methods. In Proceedings of the 31st International Conference on Scientific and Statistical Database Management (SSDBM ’19). Association for Computing Machinery, New York, NY, USA, 121–132. DOI:https://doi.org/10.1145/3335783.3335791 - [Jelle Hellings. Querying for Paths in Graphs using Context-Free Path Queries.](https://arxiv.org/abs/1502.02242) - + - Биоинформатика. В основном это анализ геномных и белковых последовательностей. - [Witold Dyrka, Mateusz Pyzik, Francois Coste, and Hugo Talibart. Estimating probabilistic context-free grammars for proteins using contact map constraints.](https://www.ncbi.nlm.nih.gov/pmc/articles/PMC6428041/) - [James WJ Anderson, Paula Tataru, Joe Staines, Jotun Hein, and Rune Lyngso. Evolving stochastic context-free grammars for RNA secondary structure prediction.](https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3464655/) - - [Ryan Zier-Vogel. Predicting RNA secondary structure using a stochastic conjunctive grammar.](https://www.semanticscholar.org/paper/Predicting-RNA-secondary-structure-using-a-grammar-Zier-Vogel/90bb312cb1a0f61eddb7a8b5b782bb40630894dd). + - [Ryan Zier-Vogel. Predicting RNA secondary structure using a stochastic conjunctive grammar.](https://www.semanticscholar.org/paper/Predicting-RNA-secondary-structure-using-a-grammar-Zier-Vogel/90bb312cb1a0f61eddb7a8b5b782bb40630894dd). - Машинное обучение. - [Matt J. Kusner, Brooks Paige, José Miguel Hernández-Lobato. Grammar Variational Autoencoder](https://arxiv.org/abs/1703.01925). Опубликована в 2017 году и уже [больше 950 цитирований.](https://scholar.google.com/scholar?cites=4080460899049502885&as_sdt=2005&sciodt=0,5&hl=ru) @@ -203,17 +203,17 @@ - [HYPEREDGE REPLACEMENT GRAPH GRAMMARS](https://people.cs.umu.se/drewes/biblio/ps-files/hrg.pdf) - [(Re)introducing Regular Graph Languages](https://www.aclweb.org/anthology/W17-3410.pdf) - [Hyperedge Replacement: Grammars and Languages](https://www.springer.com/gp/book/9783540560050) - - $\ldots$ + - $\ldots$ - Теория групп. Как правило, это проблема слов группы или дополнение к ней. - Anisimov, A.V. Group languages. Cybern Syst Anal (1971) 7: 594. - David E. Muller, Paul E. Schupp, Groups, the Theory of ends, and context-free languages, Journal of Computer and System Sciences, Volume 26, Issue 3, 1983, Pages 295-310, ISSN 0022-0000 - HOLT, D., REES, S., ROVER, C., \& THOMAS, R. (2005). GROUPS WITH CONTEXT-FREE CO-WORD PROBLEM. Journal of the London Mathematical Society, 71(3), 643-657. doi:10.1112/S002461070500654X - [Groups with Context-Free Co-Word Problem and Embeddings into Thompson's Group V](https://arxiv.org/abs/1407.7745) - [Kropholler, R. \& Spriano, D. (2019). Closure properties in the class of multiple context-free groups. Groups Complexity Cryptology, 11(1), pp. 1-15. Retrieved 13 Feb. 2020, from doi:10.1515/gcc-2019-2004](https://www.degruyter.com/view/j/gcc.2019.11.issue-1/gcc-2019-2004/gcc-2019-2004.xml) - - [Word problems of groups, formal languages and decidability](https://personalpages.manchester.ac.uk/staff/Mark.Kambites/events/nbsan/nbsan17_thomas.pdf) + - [Word problems of groups, formal languages and decidability](https://personalpages.manchester.ac.uk/staff/Mark.Kambites/events/nbsan/nbsan17_thomas.pdf) - Прочая интересная математика. - Немного топологии в теории формальных языков: [Salvati S. On is an n-MCFL. – 2018.](https://hal.archives-ouvertes.fr/hal-01771670/) - Salvati S. MIX is a 2-MCFL and the word problem in Z2 is captured by the IO and the OI hierarchies //Journal of Computer and System Sciences. -- 2015. -- Т. 81. -- \textnumero. 7. -- С. 1252-1277. - О том, как задачи из теории графов связаны с теорией формальных языков: Abboud, Amir \& Backurs, Arturs \& Williams, Virginia. (2015). If the Current Clique Algorithms are Optimal, So is Valiant's Parser. 98-117. 10.1109/FOCS.2015.16. - - [A context-free grammar for the Ramanujan-Shor polynomials](https://www.sciencedirect.com/science/article/abs/pii/S0196885819300739) + - [A context-free grammar for the Ramanujan-Shor polynomials](https://www.sciencedirect.com/science/article/abs/pii/S0196885819300739) diff --git a/requirements.txt b/requirements.txt index 9963f260f..6e223e1ca 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,4 +4,4 @@ cfpq-data pre-commit pydot pytest -scipy \ No newline at end of file +scipy