Skip to content

Commit

Permalink
Merge pull request #13 from josek98:develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
josek98 committed May 15, 2024
2 parents 1b351d7 + 26d4b69 commit 9848e45
Show file tree
Hide file tree
Showing 17 changed files with 726 additions and 169 deletions.
166 changes: 101 additions & 65 deletions README.md

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[pytest]
markers =
deprecated: mark test as deprecated
addopts =
-m "not deprecated"
31 changes: 0 additions & 31 deletions pywgraph/_utils.py

This file was deleted.

27 changes: 27 additions & 0 deletions pywgraph/_wrappers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import warnings


def deprecation_warning(message):
def decorator(func):
def wrapper(*args, **kwargs):
# Issue a deprecation warning with the provided message
warnings.warn(message, category=DeprecationWarning, stacklevel=2)
# Call the original function
return func(*args, **kwargs)

return wrapper

return decorator


def behavior_change_warning(message):
def decorator(func):
def wrapper(*args, **kwargs):
# Issue a FutureWarning about the change in behavior
warnings.warn(message, category=FutureWarning, stacklevel=2)
# Call the original function
return func(*args, **kwargs)

return wrapper

return decorator
3 changes: 2 additions & 1 deletion pywgraph/graphs/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from ._edge import *
from ._graph import *
from ._paths import *

__all__ = [s for s in dir() if not s.startswith("_")]
__all__ = [s for s in dir() if not s.startswith("_")]
12 changes: 7 additions & 5 deletions pywgraph/graphs/_edge.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
from typing import TypeVar
from ..groups import Group
from ..groups import Group, real_multiplicative_group

T = TypeVar("T")
_default_group = Group(
"Real numbers with multiplication", 1.0, lambda x, y: x * y, lambda x: 1 / x
)


class DirectedEdge:
Expand Down Expand Up @@ -46,9 +43,14 @@ def __repr__(self) -> str:
class WeightedDirectedEdge(DirectedEdge):

def __init__(
self, start: str, end: str, weight: T, group: Group = _default_group
self,
start: str,
end: str,
weight: T,
group: Group = real_multiplicative_group,
) -> None:
super().__init__(start, end)

self._weight = weight
self._group = group

Expand Down
Loading

0 comments on commit 9848e45

Please sign in to comment.