Skip to content

Commit 6a75777

Browse files
authoredNov 20, 2024··
Merge pull request #91 from bio-ontology-research-group/develop
Develop
2 parents 7a215ba + b0a2013 commit 6a75777

File tree

9 files changed

+172
-202
lines changed

9 files changed

+172
-202
lines changed
 

‎.github/workflows/python-package_3_10.yml

-48
This file was deleted.

‎.github/workflows/python-package_3_11.yml

-48
This file was deleted.

‎.github/workflows/python-package_3_12.yml

-48
This file was deleted.

‎.github/workflows/python-package_3_9.yml

-48
This file was deleted.

‎.github/workflows/unittests.yml

+159
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
3+
4+
name: Python Unit Tests
5+
6+
on:
7+
push:
8+
branches: [ "main", develop ]
9+
pull_request:
10+
branches: [ "main", develop ]
11+
12+
jobs:
13+
python-3-9:
14+
runs-on: ${{ matrix.os }}
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
os: ["ubuntu-latest"]
19+
python-version: ["3.9"]
20+
defaults:
21+
run:
22+
shell: bash -l {0}
23+
steps:
24+
- uses: actions/checkout@v3
25+
- uses: conda-incubator/setup-miniconda@v2
26+
with:
27+
auto-update-conda: true
28+
python-version: ${{ matrix.python-version }}
29+
activate-environment: anaconda-client-env
30+
environment-file: envs/environment_3_9.yml
31+
auto-activate-base: false
32+
channels: conda-forge
33+
use-mamba: true
34+
- name: Install dependencies
35+
run: |
36+
python -m pip install --upgrade pip
37+
python -m pip install flake8 nose pinocchio nose-exclude coverage
38+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
39+
- name: Lint with flake8
40+
run: |
41+
# stop the build if there are Python syntax errors or undefined names
42+
# flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
43+
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
44+
flake8 mowl --count --exit-zero --max-complexity=20 --max-line-length=127 --statistics
45+
- name: Test with nose
46+
run: |
47+
nosetests tests
48+
49+
python-3-10:
50+
51+
runs-on: ${{ matrix.os }}
52+
strategy:
53+
fail-fast: false
54+
matrix:
55+
os: ["ubuntu-latest"]
56+
python-version: ["3.10"]
57+
defaults:
58+
run:
59+
shell: bash -l {0}
60+
steps:
61+
- uses: actions/checkout@v3
62+
- uses: conda-incubator/setup-miniconda@v2
63+
with:
64+
auto-update-conda: true
65+
python-version: ${{ matrix.python-version }}
66+
activate-environment: anaconda-client-env
67+
environment-file: envs/environment_3_10.yml
68+
auto-activate-base: false
69+
channels: conda-forge
70+
use-mamba: true
71+
- name: Install dependencies
72+
run: |
73+
python -m pip install --upgrade pip
74+
python -m pip install flake8 pytest coverage pytest-faulthandler
75+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
76+
- name: Lint with flake8
77+
run: |
78+
# stop the build if there are Python syntax errors or undefined names
79+
# flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
80+
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
81+
flake8 mowl --count --exit-zero --max-complexity=20 --max-line-length=127 --statistics
82+
- name: Test with pytest
83+
run: |
84+
pytest -m "not slow" -p no:faulthandler
85+
86+
87+
python-3-11:
88+
89+
runs-on: ${{ matrix.os }}
90+
strategy:
91+
fail-fast: false
92+
matrix:
93+
os: ["ubuntu-latest"]
94+
python-version: ["3.11"]
95+
defaults:
96+
run:
97+
shell: bash -l {0}
98+
steps:
99+
- uses: actions/checkout@v3
100+
- uses: conda-incubator/setup-miniconda@v2
101+
with:
102+
auto-update-conda: true
103+
python-version: ${{ matrix.python-version }}
104+
activate-environment: anaconda-client-env
105+
environment-file: envs/environment_3_11.yml
106+
auto-activate-base: false
107+
channels: conda-forge
108+
use-mamba: true
109+
- name: Install dependencies
110+
run: |
111+
python -m pip install --upgrade pip
112+
python -m pip install flake8 pytest coverage pytest-faulthandler
113+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
114+
- name: Lint with flake8
115+
run: |
116+
# stop the build if there are Python syntax errors or undefined names
117+
# flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
118+
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
119+
flake8 mowl --count --exit-zero --max-complexity=20 --max-line-length=127 --statistics
120+
- name: Test with pytest
121+
run: |
122+
pytest -m "not slow" -p no:faulthandler
123+
124+
python-3-12:
125+
126+
runs-on: ${{ matrix.os }}
127+
strategy:
128+
fail-fast: false
129+
matrix:
130+
os: ["ubuntu-latest"]
131+
python-version: ["3.12"]
132+
defaults:
133+
run:
134+
shell: bash -l {0}
135+
steps:
136+
- uses: actions/checkout@v3
137+
- uses: conda-incubator/setup-miniconda@v2
138+
with:
139+
auto-update-conda: true
140+
python-version: ${{ matrix.python-version }}
141+
activate-environment: anaconda-client-env
142+
environment-file: envs/environment_3_12.yml
143+
auto-activate-base: false
144+
channels: conda-forge
145+
use-mamba: true
146+
- name: Install dependencies
147+
run: |
148+
python -m pip install --upgrade pip
149+
python -m pip install flake8 pytest coverage pytest-faulthandler
150+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
151+
- name: Lint with flake8
152+
run: |
153+
# stop the build if there are Python syntax errors or undefined names
154+
# flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
155+
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
156+
flake8 mowl --count --exit-zero --max-complexity=20 --max-line-length=127 --statistics
157+
- name: Test with pytest
158+
run: |
159+
pytest -m "not slow" -p no:faulthandler

‎docs/source/conf.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
copyright = '2023, Bio-Ontology Research Group'
2323
author = 'BORG'
2424

25-
release = '1.0.1'
26-
version = '1.0.1'
25+
release = '1.0.2-dev'
26+
version = '1.0.2-dev'
2727
# -- General configuration
2828

2929
extensions = [

‎docs/source/index.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Getting started
2727
**mOWL** can be installed from `source code <https://github.com/bio-ontology-research-group/mowl>`_ or from `PyPi <https://pypi.org/project/mowl-borg/>`_. For more details on installation check out the how to :doc:`install/index` section of the project.
2828

2929
.. note::
30-
This version of documentation corresponds to mOWL-1.0.1.
30+
This version of documentation corresponds to mOWL-1.0.2-dev.
3131

3232

3333
mOWL, JPype and the JVM

‎mowl/projection/edge.py

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from pykeen.triples import TriplesFactory
2-
from deprecated.sphinx import versionadded, deprecated
2+
from deprecated.sphinx import versionadded, deprecated, versionchanged
33
import numpy as np
44
import torch as th
55

@@ -69,14 +69,15 @@ def getEntitiesAndRelations(edges):
6969
return Edge.get_entities_and_relations(edges)
7070

7171
@staticmethod
72+
@versionchanged(version="1.0.2", reason="Method return type changed to tuple of lists")
7273
def get_entities_and_relations(edges):
7374
'''
7475
:param edges: list of edges
7576
:type edges: :class:`Edge`
7677
7778
:returns: Returns a 2-tuple containing the list of entities (heads and tails) and the \
7879
list of relations
79-
:rtype: (Set of str, Set of str)
80+
:rtype: (list of str, list of str)
8081
'''
8182

8283
entities = set()
@@ -86,6 +87,9 @@ def get_entities_and_relations(edges):
8687
entities |= {edge.src, edge.dst}
8788
relations |= {edge.rel}
8889

90+
entities = sorted(list(entities))
91+
relations = sorted(list(relations))
92+
8993
return (entities, relations)
9094

9195
@staticmethod
@@ -109,12 +113,11 @@ def as_pykeen(edges, create_inverse_triples=True, entity_to_id=None, relation_to
109113
"""
110114
if entity_to_id is None or relation_to_id is None:
111115
classes, relations = Edge.getEntitiesAndRelations(edges)
112-
classes, relations = set(classes), set(relations)
113116

114117
if entity_to_id is None:
115-
entity_to_id = {v: k for k, v in enumerate(list(classes))}
118+
entity_to_id = {v: k for k, v in enumerate(classes)}
116119
if relation_to_id is None:
117-
relation_to_id = {v: k for k, v in enumerate(list(relations))}
120+
relation_to_id = {v: k for k, v in enumerate(relations)}
118121

119122
def map_edge(edge):
120123
return [entity_to_id[edge.src], relation_to_id[edge.rel], entity_to_id[edge.dst]]

‎tests/projection/test_edge.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ def test_get_ents_and_rels_method(self):
3737

3838
ents, rels = Edge.get_entities_and_relations([edge1, edge2])
3939

40-
self.assertEqual(ents, {"src1", "src2", "dst1", "dst2"})
41-
self.assertEqual(rels, {"rel1", "rel2"})
40+
self.assertEqual(ents, ["dst1", "dst2", "src1", "src2"])
41+
self.assertEqual(rels, ["rel1", "rel2"])
4242

4343
def test_zip_method(self):
4444
"""This checks if Edge.zip method works correctly"""

0 commit comments

Comments
 (0)
Please sign in to comment.