Skip to content

Commit

Permalink
Merge pull request #89 from bio-ontology-research-group/37-randomness…
Browse files Browse the repository at this point in the history
…-in-the-embedding-indices

🐛 Issue #37
  • Loading branch information
ferzcam authored Nov 20, 2024
2 parents e6724a9 + 6323c9c commit ac8ff10
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 12 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ name: Publish Python 🐍 distribution 📦 to PyPI and TestPyPI

on:
push:
branches: ["main"]
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build:
Expand Down
4 changes: 2 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
copyright = '2023, Bio-Ontology Research Group'
author = 'BORG'

release = '1.0.1'
version = '1.0.1'
release = '1.0.2-dev'
version = '1.0.2-dev'
# -- General configuration

extensions = [
Expand Down
2 changes: 1 addition & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Getting started
**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.

.. note::
This version of documentation corresponds to mOWL-1.0.1.
This version of documentation corresponds to mOWL-1.0.2-dev.


mOWL, JPype and the JVM
Expand Down
13 changes: 8 additions & 5 deletions mowl/projection/edge.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from pykeen.triples import TriplesFactory
from deprecated.sphinx import versionadded, deprecated
from deprecated.sphinx import versionadded, deprecated, versionchanged
import numpy as np
import torch as th

Expand Down Expand Up @@ -69,14 +69,15 @@ def getEntitiesAndRelations(edges):
return Edge.get_entities_and_relations(edges)

@staticmethod
@versionchanged(version="1.0.2", reason="Method return type changed to tuple of lists")
def get_entities_and_relations(edges):
'''
:param edges: list of edges
:type edges: :class:`Edge`
:returns: Returns a 2-tuple containing the list of entities (heads and tails) and the \
list of relations
:rtype: (Set of str, Set of str)
:rtype: (list of str, list of str)
'''

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

entities = sorted(list(entities))
relations = sorted(list(relations))

return (entities, relations)

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

if entity_to_id is None:
entity_to_id = {v: k for k, v in enumerate(list(classes))}
entity_to_id = {v: k for k, v in enumerate(classes)}
if relation_to_id is None:
relation_to_id = {v: k for k, v in enumerate(list(relations))}
relation_to_id = {v: k for k, v in enumerate(relations)}

def map_edge(edge):
return [entity_to_id[edge.src], relation_to_id[edge.rel], entity_to_id[edge.dst]]
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

setuptools.setup(
name="mowl-borg",
version="1.0.2-dev.1",
version="1.0.2-dev.2",
author="Bio-Ontology Research Group",
author_email="fernando.zhapacamacho@kaust.edu.sa",
description="mOWL: A machine learning library with ontologies",
Expand Down
4 changes: 2 additions & 2 deletions tests/projection/test_edge.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ def test_get_ents_and_rels_method(self):

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

self.assertEqual(ents, {"src1", "src2", "dst1", "dst2"})
self.assertEqual(rels, {"rel1", "rel2"})
self.assertEqual(ents, ["dst1", "dst2", "src1", "src2"])
self.assertEqual(rels, ["rel1", "rel2"])

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

0 comments on commit ac8ff10

Please sign in to comment.