-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added abstract class to select appropriate Cython classes
- Loading branch information
1 parent
1b02bdc
commit dee3c65
Showing
3 changed files
with
42 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from ...abc import Graph as GraphABC | ||
from ..decorator import boundable, undirectable | ||
|
||
from .plain_graph import CythonGraph as _PlainGraph | ||
|
||
|
||
@boundable | ||
@undirectable | ||
class CythonGraph(GraphABC): | ||
""" | ||
Optimised Cython Graph Implementations | ||
.. note:: This is an abstract class that merely picks the most suitable implementation. | ||
""" | ||
def __new__(cls, *args, **kwargs): | ||
return _PlainGraph(*args, **kwargs) | ||
|
||
|
||
CythonGraph.register(_PlainGraph) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
graphi_unittests/types_unittests/test_cython_graph/test_public_graph.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import platform | ||
try: | ||
import unittest2 as unittest | ||
except ImportError: | ||
import unittest | ||
|
||
try: | ||
from graphi.types.cython_graph import CythonGraph | ||
except ImportError as err: | ||
class CythonGraph(object): | ||
failure_reason = str(err) | ||
|
||
def __new__(cls, *args, **kwargs): | ||
raise ImportError(cls.failure_reason) | ||
del err | ||
|
||
from graphi_unittests.types_unittests import _graph_interface_mixins as mixins | ||
|
||
|
||
@unittest.skipIf(platform.python_implementation() != 'CPython', 'Cython extension not available outside of CPython') | ||
class TestCythonGraphInterface(mixins.Mixin.GraphInitMixin, mixins.Mixin.GraphInterfaceMixin): | ||
graph_cls = CythonGraph |